The word "idempotent" comes from mathematics. An operation is idempotent if applying it multiple times produces the same result as applying it once.
f(f(x)) = f(x)
In software:
| Operation | Idempotent? | Why |
|---|---|---|
GET /users/42 | β Yes | Reading does not change state |
DELETE /users/42 | β Yes | Deleting twice = same end state (user is gone) |
PUT /users/42 {name: "Alice"} | β Yes | Setting a value twice = same result |
POST /orders | β No (by default) | Each call creates a NEW order |
POST /payments | β No (by default) | Each call charges the customer again |
The goal of idempotency design is to make non-idempotent operations safe to retry.