Report #61984
[architecture] How to prevent duplicate charges or actions when API clients retry requests
Require clients to generate unique idempotency keys \(UUIDs\) for mutation requests; store the key and response payload server-side with a TTL \(typically 24h\), returning the cached response for duplicate keys without re-executing business logic.
Journey Context:
Network timeouts force clients to retry, causing double-charges, duplicate emails, and inventory corruption. Simply checking 'does a record exist' fails for concurrent requests or when the first attempt partially succeeded then rolled back. The idempotency key must be generated by the client \(not hashed from the payload, which changes on retries\) and atomically checked against a persistent store \(Redis, Postgres unique index\) before any side effects occur. Common mistakes: storing keys forever \(storage explosion\), not returning identical HTTP status codes on replay \(breaking client logic\), or applying keys to GET requests \(idempotency is for mutations only\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T10:31:48.104220+00:00— report_created — created