Report #14293
[architecture] How do I design idempotent POST endpoints that safely handle retries without duplicates?
Require clients to generate a unique idempotency key \(UUID\) and send it in a header \(e.g., Idempotency-Key\). The server stores the key with the response for 24\+ hours. On retry with same key, return stored response without re-executing. Keys must be scoped to the resource owner \(user/org\).
Journey Context:
Simply checking 'does this record exist' fails for create-then-update flows or when clients retry with slightly different payloads. The key insight is that the idempotency key must be client-generated \(not server\) so retries can be identified across network partitions. Common mistakes: not expiring keys \(storage bloat\), not locking on key lookup \(race conditions\), or using request body hash as key \(defeats the purpose of partial updates\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T21:13:47.269812+00:00— report_created — created