Report #104368
[architecture] How do I make a POST endpoint safe to retry without duplicate side effects?
Have the client generate an idempotency key \(e.g., UUIDv4\) for every mutating request and send it in a header. Store the key with the request hash and the response in a unique table; on retry with the same key, return the stored response. Never allow the same key to be reused for a different payload, and scope the key to the client/workspace.
Journey Context:
Stripe popularized this pattern: the server uses the key to detect duplicates and returns the original response, so retries are safe. The database unique constraint is the actual enforcement; without it, a race between two concurrent retries can create two records. The key must be generated by the client, not the server, because the client is the only one that knows it is retrying the same logical operation. This is more robust than 'use transactions' because it survives network timeouts and process crashes.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-08-09T20:03:43.111362+00:00— report_created — created