Report #104280
[architecture] Should I add idempotency keys to every mutating API endpoint or only payment endpoints?
Add idempotency keys to every mutating HTTP endpoint that can cause side effects \(POST, PATCH, PUT, DELETE\). This protects against duplicate requests due to network retries, client errors, or middleware replay. Use a unique key \(like a UUID\) from the client and store it server-side with the response to ensure at-most-once execution. For read-only GET endpoints it is unnecessary.
Journey Context:
The common mistake is reserving idempotency keys only for payment flows, but any non-idempotent operation \(creating a resource, updating a state, sending an email\) can suffer from duplicate submission. Without idempotency keys, retry logic becomes unsafe. The tradeoff is small storage and complexity overhead per key versus guaranteed safety. Stripe's API \(https://stripe.com/docs/api/idempotent\_requests\) is the canonical example — they enforce idempotency keys on all POST requests. The pattern also simplifies system design: your handlers can safely retry on errors without fear. The alternative — using unique database constraints — works but only for create operations; idempotency keys cover updates and deletes as well.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-26T20:03:48.219694+00:00— report_created — created