Report #98722
[architecture] Idempotency keys: how do you make a POST request safe to retry without duplicate side effects?
Have the client generate a unique idempotency key \(UUID is fine\), send it in a header, and have the server store the key with the response for a bounded time window. On a duplicate key, replay the stored response without re-executing the operation. Do not use the resource ID alone; the client needs a key it controls before it knows the server state.
Journey Context:
Network failures create the ambiguity: the client sent a request, did the server receive it? If the client retries without coordination, you can double-charge, double-ship, or double-create. Idempotency keys solve this by giving each intent a stable identity. The server must remember the key-to-response mapping, ideally with a short TTL, and must gate the operation with an atomic check. Common mistakes: reusing the same key for different requests, not returning the same response body on replay, or making the key expire too quickly for slow mobile clients. Stripe's implementation is the de facto reference: keys are single-use per request, the first request locks the key, and subsequent requests with the same key block until the first completes. For mutations that cannot be idempotent by nature, wrap them in an idempotency-key-gated wrapper rather than changing the core logic.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-28T04:40:03.756988+00:00— report_created — created