← Technical notes
Illustrative2 diagrams

One interface for many third-party APIs

Example domain: a shipping platform integrating several courier APIs, each with different auth, payload formats and status names.

Based on patterns I've built in production (details under NDA). The example domain below is illustrative.

TL;DR

Illustrative note: one internal interface and a registry of adapters for providers that differ in auth, payloads, and status names.

live trace · Inbound callback through an adapterfrom the original diagram
Third-party API Callback handler Handler Adapter Core service 01POST /callbacks/:account 02parse and verify signature 03normalised event, final or pending 04ingest; pending means no state change 05provider-specific ack
  1. 01
    Third-party API → Callback handlerPOST /callbacks/:account
  2. 02
    Handler → Adapterparse and verify signature
  3. 03
    Adapter → Handlernormalised event, final or pending
  4. 04
    Handler → Core serviceingest; pending means no state change
  5. 05
    Handler → Third-party APIprovider-specific ack
01

The problem

Every provider signs requests differently, names statuses differently, and some report an intermediate processing state before the final result.

02

How it works

  1. A single internal interface (create, query, parse callback) and a registry. Adding a provider means one adapter plus one registration.
  2. On boot, each active account is loaded with its credentials; a broken account is skipped and reported instead of crashing the service, and credentials are never logged.
  3. Each adapter verifies the callback signature and maps provider statuses to internal ones, including an explicit pending flag.
  4. Pending events are acknowledged but do not change state; only final events do.
  5. Every outbound call is written to an audit log on a best-effort basis, so logging failures never change the business result.
  6. Test tenants short-circuit to mock responses and never call the real API.
All diagrams

Other views

Tap a table to see what it links to.

PROVIDER_ACCOUNTstring codestring adapter_keybytes credentials
OUTBOUND_LOGstring directionstring endpointint http_status
  • PROVIDER_ACCOUNT records OUTBOUND_LOG 1 → many

← Technical notes on the home page