Skip to content

API reference ​

Amounts are integer cents. Every POST needs an Idempotency-Key header. Errors are always { "error": { "code", "message", "details"? } }. No authentication yet.

Endpoints ​

MethodPathBodyResponse
POST/wallets{ owner }201 · wallet (409 if it exists)
GET/wallets/:owner{ owner, currency, available_cents, pending_cents, held_cents, owed_cents } (owed_cents = receivable, 0 if none)
GET/wallets/:owner/entries?limit=20&before=<id>{ entries[], next_cursor }
POST/wallets/:owner/deposits{ amount_cents }201 · pending deposit
GET/deposits/:iddeposit
POST/deposits/:id/settle200 · settled deposit
POST/deposits/:id/return200 · returned deposit
POST/wallets/:owner/holds{ amount_cents, ttl_seconds? }201 · active hold
GET/holds/:idhold
POST/holds/:id/capture200 · captured hold
POST/holds/:id/release200 · released hold
POST/transfers{ from, to, amount_cents }201 · { transaction_id, from, to, amount_cents }
GET/admin/reconciliation{ ok, system_sum_cents, mismatches }
GET/health{ ok: true }

Settle and return stand in for bank webhooks. Auth is on the roadmap.

Errors ​

Codes and statuses live in src/common/domain.error.ts.

CodeStatus
invalid_request, idempotency_key_required400
invalid_webhook_signature401
not_found404
wallet_exists, deposit_not_pending, hold_not_active, hold_expired, not_reversible409
insufficient_funds, idempotency_key_reused422
unbalanced_transaction, internal_error500

Idempotency ​

  • Key ≤ 255 characters. Same key again → stored response + Idempotent-Replayed: true, no money moves.
  • Same key, different body → 422 idempotency_key_reused.
  • Partner webhooks (none yet) take the key from the partner's event id (@Idempotent({ keyFrom })) and verify an HMAC signature first (src/webhooks/signature.ts, app created with rawBody: true).
  • How it works: Idempotency, ADR 0005.

Behaviour worth knowing ​

  • Status codes come from the route: 201 by default for POST, @HttpCode(200) for state transitions. The interceptor reads the same metadata, so a replayed success has the same status, and a stored business error is re-thrown with its original status.
  • Validation errors are not stored under the key (they are BadRequestException, not DomainError): the client can fix the body and retry with the same key.
  • Repeated transitions are no-ops: settling a settled deposit or capturing a captured hold returns it unchanged (a duplicate bank webhook does nothing).
  • Replayed bodies have the same content as the original but may list keys in a different order, because response_body is stored as jsonb.

Full flow to try: requests.http (WebStorm, VS Code REST Client) or the curl session.

Money is an integer number of cents. Every movement sums to zero.