Skip to main content

Idempotency and retries

It's always safe to retry these calls:

CallIdempotent onReplay returns
POST /tax/documentsentityId + sourceSystem + sourceDocumentId + direction200 with the same document (Unchanged). New content replaces it until committed.
POST /tax/documents/{id}/creditsThe credit's sourceDocumentIdThe same credit
POST /tax/documents/{id}/commitDocument idThe committed document
POST /fx/locksPair + business date + sourceThe same lock (200 instead of 201)
POST /certificate-requests/resaleEntity + vendor + PO + regionThe open request
PUT /entities/{id}/customers/{code}Entity + codeThe party
MessagesThe same keys as the REST equivalent, plus the inbox's message idNo duplicate effects

So the rule for callers is: use your own stable ids (invoice id, bill id, credit memo id) as sourceDocumentId, and retry on network errors, 5xx and 409 concurrent_update.

What counts as "the same content"​

A replay is recognised by a content hash of a canonical form of the request (ContentHash in the Application layer): null members are left out, member order doesn't matter, and amounts compare by value (100.00 equals 100). So:

  • Adding an optional member to a contract doesn't turn replays of existing documents into changes, as long as callers that don't know it leave it out.
  • Hashes carry a version prefix (v1:). Rows stored before it still match their replays.

Races​

Two different requests that race for the same thing are serialized by the database, not by luck:

RaceGuardLoser gets
Two credits against one invoiceThe invoice's row version (each credit bumps credit_version)409 concurrent_update; the retry sees the winner's credit and is checked against what remains
Two resale requests for one vendor + region + POPartial unique index on open requestsThe winner's request (200)
Two first-time upserts of one customer or vendorUnique index on entity + type + code409 concurrent_update
Two locks for one pair and dayUnique index on pair + date + sourceThe winner's lock (200)