Report #101983
[architecture] How do I make POST retries safe without duplicate side effects?
Have the client generate a unique Idempotency-Key header \(UUID\) for each logical operation and reuse it across retries. The server stores the completed response keyed by that key and replays it on duplicates. Lock the key during processing, expire keys \(e.g., 24 hours\), and return an error if the same key arrives with a different payload.
Journey Context:
Networks guarantee neither exactly-once delivery nor at-most-once execution. POST is not idempotent, so a timeout leaves the client unable to distinguish 'never processed' from 'processed but response lost.' Server-generated keys cannot help because the client must be able to retry without knowing server state. The hard production details: concurrent retries need an atomic lock so only one executes; the key and side effect must commit in the same transaction so a crash cannot lose the record; storing the full response matters because the retry must get the same answer. The pattern generalizes beyond payments to any irreversible side effect.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-08T04:46:31.388287+00:00— report_created — created