Idempotency must be scoped to business action boundaries.
UseIdempotency-Key where supported to make retries safe for side-effecting operations.
Where idempotency is highest priority
- Partner billing credit allocation/deallocation flows
- Financially sensitive write operations
- External action fan-outs where duplicate writes are costly
Safe retry pattern
Generate one key per business intent
Use deterministic keys (for example
alloc:{partner_ref}:{invoice_id}) when replay risk is high.Retry only on transient failures
Retry network timeouts, 429, and selected 5xx responses with backoff.
What not to do
- Do not generate a new key for each retry attempt.
- Do not reuse one key across unrelated business actions.
- Do not retry validation or authorization failures with same payload indefinitely.
Reconciliation fields to log
idempotency_key- endpoint path
- payload hash
- response
request_id - response status and error code (if any)
If an endpoint does not explicitly support
Idempotency-Key, make your consumer idempotent with external IDs and dedupe storage in your own system.
