A customer taps “Pay” and the mobile connection drops before the confirmation screen loads. The app does not know whether the server created the charge. Should it send the request again? API idempotency is the design answer to that question: a way for a client to retry a request so that the operation behind it happens no more than once.

Short answer: the client generates a unique key and sends it with the request. The server saves the result of the first request under that key and answers any retry that carries the same key and the same parameters with that saved result, without doing the work again. The protection is narrow. It covers one operation at one provider, for as long as that provider keeps the key (Stripe’s v1 API allows cleanup after 24 hours), and a server that stores no fingerprint of the request cannot tell a retry from a different request that reuses the key. Provider documentation and the IETF draft were re-read on December 1, 2026.

The idea is older than any particular payment API. HTTP defines which methods are idempotent by nature, and API providers such as Stripe and Amazon Web Services add keys or tokens so that a request that is not naturally idempotent can be retried safely. Reading those specifications side by side shows what an idempotency key protects and where its protection stops.

What HTTP already promises

RFC 9110, section 9.2.2 defines a request method as idempotent when “the intended effect on the server of multiple identical requests with that method is the same as the effect for a single such request.” Among the methods the RFC defines, PUT, DELETE and the safe methods such as GET qualify. POST does not.

The same section explains why the property matters. If a connection closes before the client reads the response, a client can retry an idempotent request knowing that a repeat has the same intended effect, “even if the original request succeeded, though the response might differ.” For other methods the RFC says a client should not retry automatically unless it has some means to know the request is idempotent in practice, or some means to detect that the original was never applied. It also says a proxy must not automatically retry non-idempotent requests.

Two details in that definition are easy to miss. The property covers the intended effect, so a server may still log every request separately. And it describes the method’s semantics, not a guarantee that every server implements them correctly.

A key turns a POST into a recognizable retry

Creating a payment or a customer record is usually a POST, which leaves the client with the problem the RFC describes. An idempotency key closes that gap by giving the server a way to recognize “this is the same request again.”

Stripe’s API reference describes the pattern. The client generates a unique key, Stripe suggests a V4 UUID or another random string with enough entropy, and sends it with the request. Keys can be up to 255 characters, and Stripe asks developers not to use sensitive data such as email addresses as keys. For its v1 API, Stripe saves the status code and body of the first request made with a key once endpoint execution begins, and a retry with the same key returns that saved response, including a 500 error. All v1 POST requests accept a key; Stripe says a key sent with a GET or DELETE request has no effect.

The v2 API behaves differently, and the same page says so: with API v2, retries do not repeat successful operations, and Stripe retries failed or partially failed work to completion when possible and returns an updated response. If a retry cannot succeed, Stripe returns an error explaining why. A client written against the v1 rule “a retry replays the saved response” should not assume the same for v2.

Amazon EC2’s API guide uses the same idea under a different name, and splits actions into two groups. Five actions are idempotent by default and need no token: AssociateAddress, CreateVpnConnection, DisassociateAddress, ReplaceNetworkAclAssociation and TerminateInstances. Many others, from RunInstances to CreateVolume, optionally accept a client token, a unique, case-sensitive string of up to 64 ASCII characters. If a request completed successfully and the client retries it with the same token and the same parameters, the retry succeeds without performing further actions, although the result may show updated information such as the current creation status.

The key is bound to the request it first described

A key is only meaningful if it keeps pointing at one operation. Both providers check this.

Stripe says its v1 idempotency layer compares incoming parameters with those of the original request and returns an error if they differ. EC2 returns an IdempotentParameterMismatch error when a retry reuses a client token with different parameters, other than the Region or Availability Zone.

The IETF HTTP APIs working group drafted a common header for this pattern. The Idempotency-Key HTTP Header Field is still an Internet-Draft, not an RFC. Its latest revision, -09, is dated November 21, 2026 and expires May 25, 2027; the -07 revision cited in this article until today had lapsed. Revision -09 proposes that a server answer 422 when a key is reused with a different payload, 409 when a retry arrives while the original request is still being processed, and 400 when a documented operation requires the header and it is missing. Its changes from -08 clarify how a resource defines key uniqueness, relax the duty to document idempotency behavior from MUST to SHOULD, and make request fingerprints optional. Individual APIs still define their own behavior.

Situation Stripe v1 Amazon EC2 client token IETF draft -09
Same key, same request Saved first response returned Success, no further action Response consistent with the completed request
Same key, different parameters Error IdempotentParameterMismatch 422 if the server stores a fingerprint; treated as a duplicate if it does not
Retry while the first is running Result not saved; can be retried Not stated in the cited section 409
Key lifetime or scope Can be removed after at least 24 hours Scoped by Region or Availability Zone Server publishes its own expiry policy

The fourth column’s second row is the one to read twice. The draft says a resource that does not use fingerprints “cannot detect a key reused with a different payload, and handles such a request as a duplicate.” In practice, if you build your own idempotency layer and store only the key, a client bug that reuses a key for a different order will quietly return the first order’s result.

Where the protection stops

The documentation also marks the edges of what a key does.

A key expires. Stripe says v1 keys can be pruned once they are at least 24 hours old, and a key reused after pruning creates a new request. A retry queue that can hold work for longer than the provider’s window needs its own record of what was already sent. The draft leaves the window to each server: a resource should define its expiry policy and publish it in its documentation.

Not every failure is stored. Stripe saves an idempotent result only after endpoint execution begins. A request that fails parameter validation, or that conflicts with another request executing concurrently, is not saved and can be retried.

The key belongs to one service. The provider’s idempotency layer protects the operation inside that provider. It does not know whether the client’s own database recorded the order, sent the receipt or updated a ledger. Those side effects need their own checks, often keyed by the same business identifier. The same reasoning applies to incoming events; our piece on webhook signatures and replay protection follows the receiving side of a payment integration, and payment retries after a declined card shows why a new attempt after a decline is a different operation from a retry of the same one.

A general client cannot assume the server honors the header. The draft says a client may send an Idempotency-Key with any valid value to indicate that it wants the action performed once, but “without a priori knowledge, a general client cannot assume the server will respect this request.” Read the API’s documentation before relying on it.

Methods that are already idempotent need no key. Stripe says sending a key with GET and DELETE requests has no effect, because those requests are idempotent by definition.

How to generate and store an idempotency key

The client creates the key, not the server. The IETF draft recommends that “a UUID or a similar random identifier” be used, and Stripe suggests V4 UUIDs or another random string with enough entropy to avoid collisions. The draft’s own example is a header, Idempotency-Key: "8e03978e-40d5-43e8-bc93-6894a57f9324", and its revision -09 also shows a structured key, "tenant-4821:1007", a tenant identifier plus a per-tenant request number, with the warning that such keys are predictable. Stripe’s API reference asks for the key as an additional element of the request options, separate from the object’s parameters. A browser page that sends this header to an API on another origin also triggers a CORS preflight, because the header is not CORS-safelisted; see Access-Control-Max-Age and the preflight cache.

Generate the key once per intended operation and save it before the first attempt. A key created fresh on each retry defeats the purpose, because the server sees a new request every time.

The server side stores the key with what it needs to recognize the request again. The draft describes an optional idempotency fingerprint: a checksum of the whole request payload, or of selected fields, so the server can tell a true retry from a different request that reuses the key. If the fingerprint covers only part of the payload, requests that differ only outside that part are treated as the same request.

Idempotency key vs request ID

The two identifiers travel in opposite directions. An idempotency key is chosen by the client and sent to the server to say “treat repeats of this as one operation.” A request ID is assigned by the server to each individual attempt. Stripe returns one in the Request-Id response header for every API call and asks developers to quote it when contacting support. Two retries of the same payment share one idempotency key but receive two request IDs.

Idempotency key Request ID (Stripe)
Who creates it Client Server
Direction Request header or option Response header
Scope One intended operation, across retries One HTTP attempt
Purpose Prevent a repeated effect Trace and support a specific call

Questions to ask before the next release

The useful review follows one retried request from the client to the final record. Where is the key generated, and is it stored before the first attempt so the same value survives an app restart? Does the retry send exactly the same parameters? How long does the provider keep keys, and can any of the system’s queues outlast that window? What does the client do with a 409 or a saved 500? If you run the idempotency layer yourself, do you store a fingerprint, or does a reused key silently return the old result? For a batch of items where some fail, see also batch API partial failures. These questions are analysis drawn from the documented behavior above, not results from testing a particular integration.

Reporting & Sources

Re-read on December 1, 2026: RFC 9110, HTTP Semantics, section 9.2.2 (June 2022); Stripe API reference: idempotent requests (v1 and v2 behavior, 255-character limit, 24-hour cleanup); Amazon EC2 developer guide: ensuring idempotency (default-idempotent actions, client tokens); IETF datatracker: The Idempotency-Key HTTP Header Field, revision -09 (November 21, 2026; text); Stripe API reference: request IDs. The review questions and design implications are analysis based on those documents.