HTTP Methods and Natural Idempotency
You'll learn: Which HTTP methods are idempotent by design and which require extra work to make safe for retries.
Natural Idempotency in HTTP
Some HTTP methods are naturally idempotent—you can repeat them without changing the outcome beyond the first successful request. Others aren't, and need engineering effort to become safe.
Naturally Idempotent Methods
- GET: Reading data never changes it. Calling GET 100 times produces the same result as calling it once.
- PUT: Replaces a resource entirely.
PUT /users/123 {name: "Alice"}sets the user to exactly that state—do it twice, still the same state. - DELETE: Removes a resource. Delete it once, it's gone. Delete it again, it's still gone (the end state is identical).
Think of PUT like setting a thermostat to 72°F. Whether you press the button once or ten times, it's still 72°F.
Non-Idempotent Methods
- POST: Creates or appends.
POST /ordersmight create a new order each time—run it twice, get two orders. This is the double-charge problem. - PATCH: Partially updates.
PATCH /users/123 {increment_visits: 1}applied twice increments by 2, not 1.
Why This Matters
When a client retries due to network timeout, naturally idempotent methods (GET, PUT, DELETE) are safe to retry immediately. Non-idempotent methods (POST, PATCH) require idempotency keys and server-side deduplication to prevent duplicate effects.
Most payment APIs, for example, make POST requests artificially idempotent by requiring an idempotency key—precisely because POST isn't naturally safe to retry.
Key Takeaway: GET, PUT, and DELETE are naturally idempotent and safe to retry. POST and PATCH require special handling (like idempotency keys) to avoid duplicate side effects in distributed systems.