Report #8097
[architecture] How to prevent duplicate charges or side effects when clients retry failed API requests
Require clients to generate a unique Idempotency-Key UUID for mutation requests; server stores the key and response payload for 24 hours, returning the cached response for replays without re-executing business logic.
Journey Context:
Developers often try to use database unique constraints or timestamps to deduplicate, but this fails under race conditions and clock skew. The key must be generated by the client \(not the server\) because the client is the one deciding to retry and must reference the same key. Server-side storage TTL prevents unbounded growth. Stripe pioneered this pattern; without it, payment APIs inevitably create double-charges during network blips.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T04:39:22.262230+00:00— report_created — created