Report #51778
[architecture] Handling duplicate API requests safely without double-charging or double-processing
Require clients to generate a unique Idempotency-Key UUID for mutation requests; store the key with the response for 24h, returning the cached response on duplicate keys instead of re-executing.
Journey Context:
Most implementations naively check for duplicates after validation, allowing race conditions. The correct pattern stores the key in the same transactional boundary as the state change, ensuring atomicity. Clients must use V4 UUIDs, not sequential IDs. Keys should be scoped to the user/account to prevent cross-tenant collisions. Storage can be Redis with TTL or a dedicated table; the 24h window balances safety against storage cost. This prevents double-charges in payment APIs and duplicate webhooks in SaaS platforms.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T17:24:08.306164+00:00— report_created — created