API documentation · Research synthesis
An Idempotency Key Is Not a Complete Retry Contract
Stripe, PayPal, Adyen and AWS document different retry guarantees. Compare their boundaries and use a practical worksheet to make your API docs complete.
An idempotency key can help a service recognize a repeated operation, but the key alone does not tell a developer where that protection applies, how long it lasts, or how to recover an unknown result. This report compares documented contracts from Stripe, PayPal, Adyen and Amazon EC2, then proposes an endpoint worksheet and acceptance scenarios for documentation teams. It is a source-based analysis, not a live API benchmark.
Key findings
Retry documentation needs an endpoint-specific contract. A provider name or a header example is not enough to establish retention, scope and recovery behavior.
Response equality and duplicate-effect prevention are different properties. The compared documentation describes both stored-response replay and updated results.
Key scope can change the meaning of a retry. Region, account, API namespace and Availability Zone are material boundaries in the sources.
A useful documentation review includes ambiguous outcomes, concurrent requests and late retries, not only a successful second request.
How we researched this
We reviewed eight primary sources on December 2, 2026: an HTTP standard and official documentation from four deliberately selected providers. Stripe’s v1 and v2 namespaces are separate comparison rows because their documented contracts differ. We selected these sources for their concrete differences, not as a representative sample of all APIs. Sonar Pro and Sonar Deep Research assisted discovery and challenge; the cited originals were opened independently, and generated answers were not treated as source evidence. We compared stated scope, retention, replay and recovery rules, retained unknowns, and did not call payment or provisioning APIs. The worksheet and scenarios are our proposed documentation review method, not a measured reliability score.
What does idempotency actually promise?
HTTP idempotency concerns the intended server-side effect of repeating an identical request. It does not require the response to be identical, prevent separate log entries, or guarantee success. RFC 9110 identifies PUT, DELETE and safe methods as idempotent. It also restricts automatic retries of non-idempotent requests unless the client knows the operation is effectively idempotent or knows the original was not applied. HTTP Semantics
That distinction matters when writing a POST example with a retry key. The example shows a mechanism. Readers still need the service’s contract for that operation. A page that only says “add this header for safe retries” leaves several decisions unresolved: whether the key survives a process restart, whether a new region shares the same record, and whether an error response means the original work failed.
Our editorial recommendation is to make three promises separately:
- Recognition: which attempts the service treats as the same operation.
- Effect: which work will not be repeated, and under what conditions.
- Recovery: how a caller obtains or reconciles the outcome.
These are proposed headings for clear documentation, not three standardized HTTP fields. A team can use different terminology, but a reader should be able to find all three answers without inferring them from sample code.
What the provider documentation actually says
The rows below describe specific documented behaviors, not an overall ranking. A longer retention period is not a measured reliability advantage. “Not established” means this review did not establish a value from the cited material, not that the provider has no limit.
| Contract | Time boundary | Recognition or scope | What a repeated request can return |
|---|---|---|---|
| Stripe API v1 | Keys may be removed after at least 24 hours | Reuse the key and matching parameters for the operation | Stored first status and body after execution begins, including a 500. Source |
| Stripe API v2 | Requests within 30 days | Same key, same API, same account or sandbox | Updated response after success; failed or partially failed work can be retried. Source |
| PayPal REST | Endpoint-specific; no universal duration asserted here | Supported APIs using PayPal-Request-Id | For supported APIs, latest status of the earlier request. Source |
| Adyen | Published validity is 7 to 14 days after first submission | Company account; duplication is not checked across regional endpoints | First response if already processed. Source |
| Amazon EC2 client-token operations | No single duration established here | Regional or zonal, depending on the action and request | Successful retry without further action when matching rules hold. Source |
Stripe: name the namespace
Stripe v1 saves a result only once endpoint execution begins. Validation failures and conflicts before execution do not save a result for replay; parameter mismatches are rejected. Once a key has been pruned, reuse can create a new request. Idempotent requests
For v2, successful work is not repeated, but the response can be updated. Failed work can be re-executed, and a replay that can no longer succeed can return an explanatory error. Its scope includes the API and account or sandbox. The v1/v2 distinction is a URL namespace distinction; a dated Stripe-Version header is not a substitute for identifying it. API v2 overview
PayPal: check the endpoint reference
PayPal’s general guide explicitly says that not every API supports its request-ID header and directs readers to the endpoint reference for retention. It also warns that simultaneous requests with the same ID can result in the second failing. This report therefore does not assign a universal PayPal retention window or concurrency status code. PayPal idempotency
Adyen: regional routing is part of the contract
Adyen’s stated regional boundary matters to failover design: retaining the same text key is not sufficient to establish cross-region deduplication. Its error guidance identifies a transient-error response header; true permits a later retry with the same key. An unfinished duplicate can return HTTP 422 or 409 with code 704. Those are documented conditions, not observations from a test we ran. Adyen idempotency
EC2: an Availability Zone can change the scope
EC2 RunInstances uses zonal idempotency when an Availability Zone is specified explicitly or implied by a subnet; otherwise it uses regional idempotency. For a zonal request, the same token can launch instances in another Availability Zone in that region. For a regional request, the same request and token can launch in another region. These can be new resources, not recovery of the original launch. Changed parameters, other than the region or zone exceptions, can produce IdempotentParameterMismatch. EC2 idempotency
The practical comparison is not “which company has idempotency?” The selected pages all publish relevant guidance, with different endpoint coverage and levels of detail. It is whether your documentation names the precise conditions that your client must preserve.
A timeout needs a documented recovery path
Stripe’s advanced error guide explains that a lost connection does not establish whether a request executed. For v1 it advises preserving the key and parameters within the first 24 hours, then stopping and reconciling if the outcome is still unknown. Stripe also treats a 500 outcome as indeterminate: inspect the relevant object, request record and webhook evidence before starting another operation with a new key. Reconciliation is not guaranteed to resolve every case. Advanced error handling
Our suggested documentation pattern is to present “unknown” as an explicit state. Avoid a diagram with only success and failure if an interrupted request can leave the caller unable to distinguish them. Give that state a next action, an owner and a stopping condition.
For example, an API guide could describe this decision sequence, customized to its real service contract:
- Identify the logical operation already attempted. Recover its saved request identity and relevant scope.
- Determine whether the documented retry window and matching rules still apply.
- If a retry is permitted, follow the endpoint’s error-specific timing and parameter rules.
- If the outcome remains ambiguous, use the documented lookup or support process.
- Start a genuinely new operation only after the product’s rules establish that doing so is appropriate.
This is an editorial outline, not universal executable retry logic. The service owner must supply the actual codes, endpoints, deadlines and escalation rules. In particular, “look it up” is incomplete unless the reader knows which identifier to search, where to search and what an absent result means.
A support handoff should request a useful evidence bundle: the operation’s local identifier, endpoint and environment, first-attempt time, available request IDs and the last observed response. Keep secrets and sensitive payload fields out of routine tickets. The documentation should state the approved diagnostic channel and redaction requirements.
Our earlier API error documentation report covers broader error recovery. The narrower concern here is keeping the identity of one attempted operation intact while its outcome is uncertain.
An endpoint worksheet your team can actually fill in
Use this proposed worksheet during an API documentation review. Complete one copy for each materially different endpoint contract. A shared guide can hold common rules, but an endpoint page should point to it and state its exceptions.
| Field | What the documentation should record | Evidence to attach |
|---|---|---|
| Operation | Endpoint, method, namespace and environment | Current reference URL and version |
| Logical identity | What counts as the same user intent; where the key is generated and retained | Client example and owner-approved explanation |
| Matching scope | Account, tenant, region, zone and any operation-specific boundary | Exact provider or service contract |
| Payload changes | Which changes are rejected, ignored or treated as new work | Documented comparison rules and error example |
| Time | Start of the retention window, supported duration and expiry behavior | Contract statement, with unknowns retained |
| In-progress duplicate | What happens before the first attempt finishes | Response or error rule and next action |
| Completed duplicate | Whether the body is replayed, refreshed or reconstructed | Example and defined invariant |
| Ambiguous result | How to find the original outcome and when to stop retrying | Lookup procedure and escalation route |
| Client behavior | SDK name/version, retry settings and restart behavior | Reproducible configuration |
| Review status | Owner, verification date and unresolved questions | Review record linked to the released docs |
The most useful answer is sometimes “not established.” That creates a concrete question for the service owner. A guessed number creates a hidden dependency in someone else’s integration.
A worked review finding
Imagine an internal draft for a job-creation API says: “Every request accepts an idempotency key. Retry failures automatically.” The team’s proposed client also generates a new key whenever its worker starts.
The review finding should not be “add more detail.” Record it as: the draft does not explain whether a restarted worker is retrying the original job or requesting a new job. Ask the implementation owner where logical job identity persists, how the server matches it, and what happens after retention ends. Until those answers exist, the example is incomplete.
This hypothetical finding does not claim that any provider in the table has that bug. It illustrates how to convert an ambiguous sentence into an actionable documentation issue.
Keep the example aligned with the promise
A sample should distinguish a new user action from another attempt at the same action. Label where the example obtains its stable operation identity; do not hide that decision inside a helper named generateKey. If the example is intentionally simplified, link to the production recovery procedure and name what was omitted.
Likewise, do not use a response-body equality assertion when the documented promise is about avoiding another resource. The assertion should match the contract, and any permitted changing fields should be stated. That is a review design recommendation, not a claim that every provider exposes the same observability tools.
Proposed acceptance scenarios, not completed benchmark results
A page can be complete enough to read and still leave the difficult client paths unexplained. The scenarios below are a proposed review plan. They have not been executed against the compared APIs. Run destructive or billable operations only in an authorized test environment, using the provider’s supported fixtures and cleanup process.
| Scenario | Question to resolve before testing | Evidence a reviewer should retain |
|---|---|---|
| Repeat after a confirmed success | Which effect should remain unchanged, and can the response change? | Resource identity, response and stated invariant |
| Lose the response after acceptance | How will the caller recover its original operation? | Correlation trail and documented recovery result |
| Submit matching attempts concurrently | Is the second queued, replayed, rejected or otherwise handled? | Both responses, timing and required next action |
| Reuse a key with changed input | Which fields define a mismatch? | Expected error or explicitly documented alternative |
| Restart the client | Does the retry retain the original identity and scope? | Persisted operation record and retry configuration |
| Change the region or account | Does the deduplication boundary change? | Endpoint routing and documented scope |
| Retry after the supported window | What prevents an unresolved old operation becoming new work? | Stop/reconcile behavior and owner decision |
| Delete or change the original resource | What does a later replay mean now? | Resource lifecycle rule and returned identity |
For each scenario, write the expected result before running it. Record the provider, endpoint, environment, SDK version and configuration. If the expected result is unknown, the immediate task is a contract clarification, not repeatedly running requests until something looks plausible.
AWS’s Builders’ Library provides an instructive counterexample to assuming that a replay returns a byte-identical snapshot: its EC2 example returns the same instance identity with a changed lifecycle state. It also discusses late requests after a resource has been deleted and explains that the appropriate behavior can differ by service. That supports including lifecycle questions in a review; it does not give every API the EC2 contract. AWS design discussion
Keep the final review honest about coverage. A successful sequential retry does not establish the concurrent, expired-key or cross-region result. Conversely, one expected conflict response is not evidence that idempotency failed. Interpret the observation against the published promise.
An evidence record should separate three labels: documented, observed in this configuration, and not verified. A reader can then distinguish a source comparison like this report from a future test campaign. Do not turn a documentation checklist into a numerical reliability ranking without a defensible measurement method.
Where these answers belong in the docs
A practical documentation layout has a short rule on the endpoint page, a shared retry guide and a recovery runbook. The endpoint should say whether the mechanism is supported and link directly to the applicable contract. The guide explains common concepts. The runbook addresses an unresolved operation in terms an on-call developer can follow.
Keep the central comparison close to the client examples. A sample that retries three times is not self-explanatory if the guide never says why those responses are eligible for retry or whether a restart preserves the key. Give the sample a defined scope rather than presenting it as a production-ready policy for every endpoint.
For a team maintaining several SDK examples, use a review inventory:
- List the endpoints and examples that share a retry contract.
- Assign a service owner to confirm the server rules and a client owner to confirm SDK behavior.
- Record links to authoritative reference pages and the date checked.
- Track unresolved differences instead of smoothing them into one generic paragraph.
- Revisit the examples when scope, retention, version or client defaults change.
This is a proposed maintenance process. We have not measured its effect on incident rates, support volume or integration speed. Its value is that it produces specific reviewable answers instead of a vague instruction to improve the docs.
The best next step is small: pick one endpoint whose failure could duplicate important work, fill the worksheet, and inspect the example that readers actually copy. If the team cannot explain a timeout, a simultaneous attempt and an expired key, the documentation still has work to do. A polished header example should be the beginning of that explanation, not the end.
Limitations
This is a purposive comparison of public documentation, not an exhaustive market survey, a compliance audit or a live reliability test. We did not make payment, provisioning or fault-injection requests, inspect provider internals, or measure duplicate rates, latency or cost. Documentation can change after the access date. Endpoint references, account terms and SDK versions can add conditions. PayPal retention is deliberately left endpoint-specific; no universal EC2 lifetime or universal changed-payload rule is inferred. Suggested worksheets and scenarios are our editorial synthesis, not a standard or a claim that a particular product passes them. The report does not establish an end-to-end exactly-once guarantee across a customer’s databases, queues and downstream services.
Sources
- HTTP Semantics, section 9.2.2RFC Editor · Accessed 2026-12-02
- Idempotent requestsStripe · Accessed 2026-12-02
- API v2 overview: idempotencyStripe · Accessed 2026-12-02
- Advanced error handlingStripe · Accessed 2026-12-02
- IdempotencyPayPal · Accessed 2026-12-02
- API idempotencyAdyen · Accessed 2026-12-02
- Ensuring idempotency in Amazon EC2 API requestsAmazon Web Services · Accessed 2026-12-02
- Making retries safe with idempotent APIsAmazon Web Services · Accessed 2026-12-02