What is Idempotency?
An operation is idempotent if performing it multiple times produces the same result as performing it once. In HTTP, GET, PUT, and DELETE are idempotent, while POST generally is not.
Idempotency matters for reliability: if a network error makes a client retry a request, an idempotent operation (or an idempotency key) ensures it is not applied twice — for example, charging a card only once.
Key points
- Repeating the operation yields the same result as doing it once.
- GET, PUT, and DELETE are idempotent; POST usually is not.
- Enables safe retries after network failures.
- APIs use idempotency keys to deduplicate POST requests.
Example
POST /charges Idempotency-Key: a1b2c3 ← safe to retry, charged once
Common uses
- Safely retrying failed requests
- Preventing duplicate payments or orders
- Reliable message and event processing
- Designing fault-tolerant APIs