Report #95070
[architecture] How to prevent duplicate financial transactions when retrying failed API requests
Require clients to generate a unique UUID for the Idempotency-Key header on mutation requests; the server atomically stores the response against this key for 24 hours, returning the cached response on replays without re-executing business logic.
Journey Context:
Teams often implement naive retries with POST retries, causing double charges during network blips. Client-generated keys are superior to server-generated IDs because the client remains uncertain of success after a timeout. The storage must be transactional with the business logic to prevent race conditions. Tradeoff: adds ~10-20ms latency for key lookup and requires storage, but prevents financial inconsistency and angry customers.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T18:09:18.284972+00:00— report_created — created