Skip to content
SD-47 · Back to the write-up

Design a Wire Transfer API

Commit the transfer, its idempotency key, a hold and an outbox row together; send from the outbox; settle with double-entry entries; reconcile daily.

Follow a request

Clients
Edge
Services
Delivery and network
ClientAPI or app
API gatewayAuth + limits
Transfer serviceStateless, many
Risk + sanctionsScreening
Ledger DB16 shards by account
Outbox queueCommitted sends
Network senderOutbox workers
Payment networkExternal rail
ReconcilerDaily + hourly
1user → gw · POST /v1/transfersThe client sends 1,000.00 to a beneficiary with Idempotency-Key: 7f3c….1 / 7

The numbers, at a glance

For every transfer created……clients read about 20 times
1 transfer ≈ 58/s20 reads ≈ 1,160/s
The ledger only growsEntries are never deleted, kept 7 years
One row in every transfer6 writes per transfer, 1 to the clearing account
So the clearing account is split into 32 buckets before it melts.

Creating a transfer, in order

The network is not called here; the 202 only promises the money is held and the send is queued.

Client
Gateway
Transfer service
Risk
Ledger shard
Outbox queue
1 POST + Idempotency-Key
2 authed request
3 screen
4 clear
5 txn: key, hold, transfer, outbox
6 committed
7 202 held
8 202 { id }
9 relay outbox row
RequestResponseAsync, does not block

Making retries safe

The decision this question is really about.

Retry and hope
Never
POSTtimeout
POST again
2 wires sent
+ Nothing to build.− Each retry is a second wire.
Dedupe by hash
Guesswork
hash(acct, bene, amt)
seen in 10 min?
rent blocked
+ No client change.− Blocks real repeat payments.
Key in the same txn
Our pick
POST + key
INSERT keyhold + outbox
retry → saved 202
+ Client names the retry; atomic.− Keys kept 30 days.

How it grows

Add a box only when a number forces you to. Highlighted boxes are new at each stage.

Stage 1 · ≈ 20 transfers/sMake it work
Client
Transfer server
Database
One server calls the network inline; retries pay twice.
Stage 2 · ≈ 175 transfers/sSafe to retry
Client
API gateway
Transfer × NRisk + sanctions
Ledger DB
Idempotency keys, holds and screening, more servers behind a gateway.
Stage 3 · ≈ 400 transfers/sSend from an outbox
Client
API gateway
Transfer × NRisk + sanctions
Ledger DBOutbox queue
Network senderPayment network
Commit and answer 202; workers send to the network.
Stage 4 · ≈ 5,000 transfers/sScale and prove it
Client
API gateway
Transfer × NRisk + sanctions
Ledger · 16 shardsOutbox queue
Network senderPayment networkReconciler
16 ledger shards, 32 clearing buckets, daily reconciliation.
Was this walkthrough useful?Your vote tells us what to improve next.