# What are idempotent requests? HTTP methods and Idempotency-Key explained

> What an idempotent request is, which HTTP methods are idempotent, why POST is not, and how an Idempotency-Key makes retries safe.

- Published 2026-11-11, updated 2026-11-11
- URL: https://softreuse.com/guides/what-are-idempotent-requests

**An idempotent request is one you can send more than once and get the same end state as sending it once.** Networks time out, load balancers retry and users double-click, so any request that moves money or creates records has to survive being delivered twice.

## Idempotent HTTP methods

[RFC 9110](https://www.rfc-editor.org/rfc/rfc9110#name-idempotent-methods) defines the idempotent methods: **PUT, DELETE and the safe methods (GET, HEAD, OPTIONS, TRACE)**. The server state after one request equals the state after ten identical ones.

| Method | Safe | Idempotent |
| --- | --- | --- |
| GET, HEAD, OPTIONS, TRACE | yes | yes |
| PUT | no | yes |
| DELETE | no | yes |
| POST | no | **no** |
| PATCH | no | **no** |

Idempotent describes the effect on the server, not the response. A second DELETE may return 404 instead of 204 and the method is still idempotent, because the resource is gone either way.

## Why POST is the problem

POST means "process this", and processing twice usually means two orders, two emails or two charges. A client that times out cannot tell whether the server never received the request or received it and lost the response. Retrying is the only way to recover, and it is exactly the case where duplicates appear.

## The fix: an Idempotency-Key

The client generates a unique key per logical operation and sends it as a header on every attempt of that operation. The server then:

1. Atomically claims the key before running the handler.
2. Runs the handler once and stores the response against the key.
3. Replays the stored response for later requests with the same key.

The edge cases decide whether this works in production:

- **Same key, still running:** answer 409 with Retry-After rather than running the handler a second time.
- **Same key, different method, path or body:** that is a client bug, so answer 422 instead of replaying an unrelated response.
- **Handler crashed:** the claim needs a lease that expires so a retry can take over.
- **Handler failed with a retryable error:** release the key so the retry runs.

The [IETF Idempotency-Key header draft](https://datatracker.ietf.org/doc/draft-ietf-httpapi-idempotency-key-header/) describes the header, and [Stripe's API](https://docs.stripe.com/api/idempotent_requests) popularised the pattern. The step-by-step implementation is in [How to implement Idempotency-Key in a Node.js API with PostgreSQL](https://softreuse.com/guides/idempotency-key-nodejs-postgres).

The [Idempotent Requests](https://softreuse.com/products/idempotent-requests) module implements this pattern for Node.js and PostgreSQL.

## Checklist

- Use PUT or DELETE where the operation is naturally idempotent.
- For POST and PATCH that have side effects, require an Idempotency-Key.
- Claim the key atomically, store the response, replay it on retries.
- Fingerprint the request so a reused key with a different body is rejected.
- Expire claims so a crashed request does not block the key forever.

## Sources

- [RFC 9110: Idempotent methods](https://www.rfc-editor.org/rfc/rfc9110#name-idempotent-methods)
- [IETF draft: The Idempotency-Key HTTP header field](https://datatracker.ietf.org/doc/draft-ietf-httpapi-idempotency-key-header/)
- [Stripe API: Idempotent requests](https://docs.stripe.com/api/idempotent_requests)

## Frequently asked questions

### What is an idempotent request?

A request that has the same effect on the server whether it is sent once or many times. Repeating it does not create a second order, a second charge or a second record.

### Which HTTP methods are idempotent?

Per RFC 9110, GET, HEAD, OPTIONS, TRACE, PUT and DELETE are idempotent. POST and PATCH are not idempotent by definition, which is why retrying them can duplicate side effects.

### Is idempotent the same as safe?

No. Safe methods (GET, HEAD, OPTIONS, TRACE) do not change server state at all. Idempotent methods may change state, but repeating them changes nothing further. DELETE is idempotent but not safe.

### How do I make a POST endpoint idempotent?

Have the client send a unique Idempotency-Key header per logical operation. The server runs the handler once for that key, stores the response and replays it on retries. Concurrent duplicates and a reused key with a different body need defined answers (409 and 422 are the common choices).
