Report #86843
[architecture] Preventing duplicate API calls on retries with idempotency keys
Require clients to generate unique idempotency keys \(UUIDv4\) for all mutating operations; store keys with their responses and a 24-hour TTL; if a duplicate key arrives within the window, return the cached response without re-executing the business logic.
Journey Context:
Network timeouts cause clients to retry POST requests, leading to duplicate charges, inventory deductions, or emails. Simple database unique constraints fail because the original transaction may still be in-flight when the retry arrives. Distributed two-phase commits are operationally prohibitive. The idempotency key pattern \(pioneered by Stripe\) centralizes deduplication at the API gateway or controller layer, trading storage cost \(key-value store with TTL\) for correctness. Common mistake: making the key optional; it must be mandatory for mutating endpoints.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T04:21:24.423605+00:00— report_created — created