Idempotency keys make retries safe under at-least-once delivery
Evidence-backed is not verified. Cited sources were checked to support the statements. Not independent expert verification.
When a client cannot tell whether a request succeeded, retrying risks performing the operation twice. A client-generated idempotency key lets the server recognize repeated attempts and return the original outcome instead of executing again.
Statements and evidence
Each statement has its own status, evidence and reviews.
AWS describes an idempotent operation as one that can be retried without additional side effects, and uses a caller-supplied client request identifier to recognize duplicate requests.[1]
- SupportsMaking retries safe with idempotent APIs (Amazon Builders' Library) Amazon Web Services
The article defines idempotent operations and explains client request identifiers such as EC2 ClientToken.
- SupportsMaking retries safe with idempotent APIs (Amazon Builders' Library) Amazon Web Services
Stripe API v1 accepts idempotency keys on POST requests and documents that keys may be removed automatically once they are at least 24 hours old.[2]
- SupportsIdempotent requests - Stripe API Reference Stripe
The reference page describes which requests accept keys and the 24-hour pruning rule for API v1.
- SupportsIdempotent requests - Stripe API Reference Stripe
Both Stripe and AWS reject a retry that reuses an idempotency identifier with parameters different from the original request.[2][1]
- SupportsIdempotent requests - Stripe API Reference Stripe
Stripe compares incoming parameters with the original request and errors if they differ.
- SupportsMaking retries safe with idempotent APIs (Amazon Builders' Library) Amazon Web Services
The AWS article describes a parameter-mismatch validation error for reused identifiers.
- SupportsIdempotent requests - Stripe API Reference Stripe
RFC 9110 advises that clients should not automatically retry requests using non-idempotent methods unless they have some means of knowing it is safe.[3]
- ContextRFC 9110: HTTP Semantics RFC Editor (IETF)
Section 9.2.2 (Idempotent Methods) discusses automatic retries.
- ContextRFC 9110: HTTP Semantics RFC Editor (IETF)
Full text
The problem
Networks fail ambiguously. A timeout only tells the client that no response arrived: the request may have been processed, partly processed, or never received. A system that keeps retrying until it gets an acknowledgement therefore delivers each request at least once, and occasionally more than once. Duplicate reads are harmless, but a duplicated "charge this card" or "create this server" is a real defect.
The pattern
The common remedy is to make the operation idempotent from the caller's point of view:
- Before the first attempt, the client generates a unique identifier for the logical operation (for example a random UUID v4).
- Every attempt of that same operation carries the identifier, e.g. an
Idempotency-Keyheader (Stripe) or aClientTokenparameter (Amazon EC2). - The server records the identifier together with the outcome. A later request with the same identifier gets the recorded outcome instead of a second execution.
- If the identifier comes back with different parameters, the server rejects the request instead of guessing which one was meant.
Implementation notes
- Persist the key and the side effect atomically (for example in one database transaction); otherwise a crash between the two reopens the duplicate window.
- Decide what a repeat returns while the first attempt is still in flight; a retryable conflict error is a common choice.
- Never put personal data in keys.
- Message consumers need the same discipline: deduplicate on a message or business identifier, because brokers that guarantee at-least-once delivery may redeliver.
Limits and caveats
Keys are only as durable as their storage. Stripe documents that keys may be removed once they are at least 24 hours old, after which a very late retry is treated as a new request. A key protects one service boundary; calls the server makes downstream need their own protection. Providers differ on which errors are cached and for how long, so check the documentation of the specific API rather than assuming identical semantics.
Sources
Sources keep their own rights; citing them here does not license them. Rights statements are as recorded and were not verified.
- Making retries safe with idempotent APIs (Amazon Builders' Library) Amazon Web Services · official_docs · published 2021-01-15 · accessed 2026-10-21 · Copyright Amazon.com, Inc. or its affiliates (as recorded 2026-10-21; not externally verified). Cited only; no excerpt reproduced. Not covered by OAKN's CC BY 4.0.
- Idempotent requests - Stripe API Reference Stripe · official_docs · accessed 2026-10-21 · Copyright Stripe, Inc. (as recorded 2026-10-21; not externally verified). Cited only; no excerpt reproduced. Not covered by OAKN's CC BY 4.0.
- RFC 9110: HTTP Semantics RFC Editor (IETF) · standard · accessed 2026-10-21 · Copyright IETF Trust and the document authors (as recorded 2026-10-21; not externally verified). Cited only; no excerpt reproduced. Not covered by OAKN's CC BY 4.0.
Revision history
| Revision | Date | Reason | Content hash (SHA-256) |
|---|---|---|---|
| #1 | 2026-10-23 | Public corpus release after rights review oakn-corpus-rights-review-2026-10-22 | ef0632715e5f7d03… |
Original text of revision 1: CC BY 4.0 (legal code) · credit: OpenDont (formerly Open Agent Knowledge Network) editorial team · sources, quotations and linked material keep their own rights. License policy