Make mutating operations idempotent
Framework question: How do you design interactions in a distributed system to prevent failures?
- Risk if not established
- Medium
- Framework verified
- 13 Nov 2026
AWS Well-Architected Framework — REL04-BP04 Make mutating operations idempotent
Executive summary
Why this practice matters
Design operations that change state so that repeating the same request has the same effect as making it once. Clients and services can then retry safely after timeouts and network failures without creating duplicate orders, payments or records.
Business impact
- Prevents duplicate transactions when requests are retried.
- Makes automatic retries safe, which improves resilience to transient failures.
- Reduces data inconsistencies that are costly to find and correct.
- Simplifies recovery after partial failures.
Assign
Accountable and responsible roles
Responsibilities are held separately from roles, so accountability type and typical roles are stated explicitly.
| Responsibility | Accountability type | Typical roles |
|---|---|---|
Define idempotency standards Set the API design standard for idempotency keys, storage and retention. Typical roles: Architect, Software Engineer, Architect, Software Engineer | responsible | ArchitectSoftware EngineerArchitect, Software Engineer |
Implement and test idempotent operations Build idempotent handling and tests that simulate retries and failures. Typical roles: Software Engineer, Quality Assurance / Test, Software Engineer, Quality Assurance / Test | responsible | Software EngineerQuality Assurance / TestSoftware Engineer, Quality Assurance / Test |
Monitor retries and duplicates Track retry rates and any duplicate processing in production. Typical roles: DevOps Engineer, SRE / Reliability Engineer, DevOps Engineer, SRE / Reliability Engineer | consulted | DevOps EngineerSRE / Reliability EngineerDevOps Engineer, SRE / Reliability Engineer |
Assessment
Assessment and evidence state
States describe how far the practice has moved from intent to something continuously validated.
- 0
Not Assessed
No documented evaluation of the practice has been performed.
Indicators
- No one has examined whether retried requests can cause duplicates.
- 1
Not Implemented
The practice is absent or applied only ad hoc.
Indicators
- Retrying a mutating request can create duplicates.
- No idempotency keys are used.
- 2
Partially Implemented
The practice is applied to some workloads or components, with known gaps.
Indicators
- Some high-impact operations are idempotent, but others are not.
- Retry behaviour is not documented or tested consistently.
- 3
Implemented
The practice is applied consistently across defined scope, with evidence.
Indicators
- All in-scope mutating operations are idempotent and documented in the API contract.
- Tests prove that retries and concurrent duplicates cause no further change.
- 4
Continuously Validated
The practice is regularly tested and improved from measured results.
Indicators
- Duplicate processing and retry rates are monitored.
- Incidents and monitoring lead to verified improvements.
Assessment dimensions
Coverage of mutating operations
Practice-specificAbsent · Partial · Operational and verified
Key handling and storage
Practice-specificAbsent · Partial · Operational and verified
Contract documentation
Practice-specificAbsent · Partial · Operational and verified
Retry testing
Practice-specificAbsent · Partial · Operational and verified
Caution
Do not award maturity because some APIs accept an idempotency key. Check that repeated and concurrent requests are actually deduplicated for the operations that matter most, and that this is tested.
Standard
What you should be able to demonstrate
Statements a reviewer should be able to confirm from evidence, not from intent.
- Every operation that changes state accepts an idempotency key or has a natural unique identifier.
- A repeated request with the same key returns the original result and causes no further change.
- Idempotency keys and their retention period are documented in the API contract.
- Tests simulate timeouts and retries to confirm no duplicates are created.
- Retries and duplicate requests are monitored.
Trade-offs to hold in view
- Recording processed keys needs storage and a retention policy.
- Checking keys adds a small amount of latency to each request.
- Clients must generate and reuse keys correctly.
Assess
Questions to ask
Each question exposes the difference between an intention and an operating practice.
- discovery
Which of our operations that change state would create a duplicate if a client retried after a timeout?
Finds the operations where retries are unsafe.
Usually asked by: Software Engineer, Architect
- challenge
What happens if two identical requests with the same key arrive at the same moment?
Tests concurrency handling, not just sequential retries.
Usually asked by: Software Engineer, Quality Assurance / Test
- evidence
Can we show a test that retries a payment or order request and proves only one is created?
Requires demonstrated behaviour.
Usually asked by: Quality Assurance / Test, Software Engineer
- executive
What would duplicate transactions cost us in refunds, support effort and customer trust?
Makes the business case for idempotency.
Usually asked by: Service Owner, Technology Executive
Evidence
Required and expected evidence
Reusable evidence definitions held once in the evidence library and referenced by every practice that relies on them. Each links to what good evidence looks like and to worked examples.
API / Service Contract
A controlled, versioned contract defining the externally observable behaviour of an API or independently evolving service interface, including operations, inputs, outputs, errors, compatibility expectations, lifecycle and ownership.
Shows which operations are idempotent, how keys are supplied and how long they are honoured.
Minimum expected content
- Contract identity, service/API name, owner and current version/status
- Intended consumers, scope and interface purpose
- Operations, endpoints, events or callable behaviours in scope
- Request/input schemas, constraints and required/optional fields
- Response/output schemas and semantic meaning
- Expected behaviour, state changes and material side effects
- Error model, error codes/conditions and retry expectations where relevant
- Authentication/authorisation and trust expectations where they form part of the interface
- Compatibility and versioning policy
- Deprecation, migration and support-window expectations
- Material reliability, timeout, idempotency or rate/usage expectations where consumers depend on them
- Machine-readable contract/specification where appropriate
- Verification or contract-test approach
- Change history and communication expectations for consumers
Anti-patterns
- Documentation generated from implementation but never reviewed as a producer-consumer contract
- Only endpoint names are documented while schemas, semantics and errors remain implicit
- Breaking changes are released under the same contract/version with no migration path
- The contract embeds unnecessary implementation internals that prevent independent evolution
- Versioning exists in the URL or metadata but no compatibility policy defines what versions mean
- Consumers rely on behaviours not represented in the contract
- Contract tests validate examples only and miss meaningful compatibility or schema changes
- The published contract is stale compared with the deployed interface
- No named owner or change path exists when producers and consumers disagree about expected behaviour
Review: Review whenever the interface, schemas, behaviour, compatibility policy or lifecycle materially changes, and keep the current contract version aligned with the deployed/supported interface.
Dependency / Coupling View
A current view of runtime, data, deployment and external dependencies that makes service coupling and failure propagation visible.
Identifies callers that retry against each service, and so depend on idempotent behaviour.
Minimum expected content
- Major services/components in scope
- Inbound and outbound dependencies
- Interaction type such as synchronous, asynchronous, shared data or batch
- Critical request/data-flow dependencies
- External/third-party dependencies where material
- Shared databases or schemas
- Coordinated deployment/change dependencies
- Known circular, high-fan-out or high-latency dependencies
- Runtime/trace evidence source where available
- Known failure-propagation or blast-radius concerns
- Owner and last reviewed date
Anti-patterns
- Only direct HTTP calls are captured while shared databases and deployment coupling are ignored
- The map is manually drawn once and never validated against runtime behaviour
- High fan-out or circular dependencies are visible but never assessed
- Every dependency is treated as equally critical
- Trace visualisations are presented without interpretation of reliability or change impact
- The map omits third-party or platform dependencies that can fail critical flows
Review: Keep aligned with material architecture changes and refresh from runtime/deployment evidence where practical.
Diagnosis
Common evidence gaps
Retry creates duplicates
A timeout followed by a retry creates a second order or payment.
Keys without storage
Clients send keys, but the service does not record which have been processed.
Undocumented behaviour
Clients do not know which operations are safe to retry.
Happy-path tests only
Tests never repeat a request or simulate a timeout.
Implementation
Implementation guidance
Identify mutating operations
List the operations that create, change or delete state, starting with payments, orders and other high-impact actions.
Add idempotency keys
Require a client-supplied key, or derive one from a natural identifier, and record which keys have been processed.
Return the original result
When a key is seen again, return the stored outcome rather than repeating the action.
Document the contract
Describe keys, retention and retry expectations in the API documentation so clients retry safely.
Test failure and retry
Simulate network failures and repeated requests to verify that no duplicates result.
Measure
Measurements
- Percentage of mutating operations with idempotency protection
- Duplicate transactions detected per period
- Retry rate per operation
- Test coverage of retry and timeout scenarios
Related
Outcomes and practices
Business outcomes
Practices