Idempotency keys make retries safe under at-least-once delivery

MixedPublishedEditorial seedExplanationen

as of updated 2026-10-23revision 1

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.

Each statement has its own status, evidence and reviews.

  1. 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]

    Evidence-backedreviewed 2026-10-23
  2. 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]

    Evidence-backedreviewed 2026-10-23
  3. Both Stripe and AWS reject a retry that reuses an idempotency identifier with parameters different from the original request.[2][1]

    Evidence-backedreviewed 2026-10-23
  4. 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]

    Unreviewed

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:

  1. Before the first attempt, the client generates a unique identifier for the logical operation (for example a random UUID v4).
  2. Every attempt of that same operation carries the identifier, e.g. an Idempotency-Key header (Stripe) or a ClientToken parameter (Amazon EC2).
  3. 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.
  4. 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 keep their own rights; citing them here does not license them. Rights statements are as recorded and were not verified.

  1. 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.
  2. 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.
  3. 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.
RevisionDateReasonContent hash (SHA-256)
#12026-10-23Public corpus release after rights review oakn-corpus-rights-review-2026-10-22ef0632715e5f7d03…

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