Scrivio Interview library
ConceptFoundations5 min read · updated 12 November 2026

Which HTTP methods are idempotent by definition, and why does idempotency matter for a client that retries after a timeout?

GET, HEAD, OPTIONS and TRACE (the safe methods) plus PUT and DELETE are idempotent by definition in HTTP; POST and PATCH are not in general. Idempotent means that sending the same request several times has the same effect on server state as sending it once, although the responses may differ, such as 404 on a second DELETE. It matters for retries because after a timeout the client cannot know whether the server processed the request, and only idempotent operations, or POSTs the server deduplicates, are safe to resend.

Why this question is asked

Networks fail in the most inconvenient place: after the server has done the work but before the client receives the answer. Every HTTP client library, gateway and service mesh has a retry setting, and whether that setting is safe depends entirely on idempotency. Interviewers ask this concept question because it separates candidates who memorised a table from those who understand why duplicate payments happen. In this answer, we will define safe and idempotent, see which methods are which, look at what a timeout really tells the client, see how a retried POST goes wrong, and answer whether a counter-incrementing PUT is idempotent.

1Safe and Idempotent, in Plain Words

HTTP, specified today in RFC 9110, describes two properties of methods. A safe method is one the client uses only to read: GET, HEAD, OPTIONS and TRACE. The client is not asking for any change on the server, although the server may still log the request or update a counter for its own purposes.

An idempotent method is one where sending the same request twice has the same intended effect on the server as sending it once. All safe methods are idempotent, because they change nothing. PUT and DELETE are idempotent too: PUT means replace the resource with this representation, so doing it again leaves the same state, and DELETE means remove it, so removing it again leaves it removed. POST means process this, which usually creates something new each time, and PATCH applies a set of changes whose effect may depend on the current state, so neither is idempotent in general.

HTTP methods by definition
MethodSafeIdempotentTypical use
GETyesyesread a resource
HEADyesyesread headers only
OPTIONSyesyesask what is allowed
TRACEyesyesdiagnostics, usually disabled
PUTnoyesreplace a resource with this state
DELETEnoyesremove a resource
POSTnonocreate or process
PATCHnonot in generalapply partial changes

2Same Effect, Not Same Response

A common misunderstanding is that idempotent means the response is identical every time. It means the state on the server is the same. The responses can differ, and that is fine.

Java
PUT /users/42/email {"email": "ana@example.com"} -> 200 OK
PUT /users/42/email {"email": "ana@example.com"} -> 200 OK (state unchanged by the repeat)
DELETE /orders/17 -> 204 No Content
DELETE /orders/17 -> 404 Not Found (still deleted: same effect)
POST /orders {"item": "lamp"} -> 201 Created, /orders/901
POST /orders {"item": "lamp"} -> 201 Created, /orders/902 (a second order)

The second DELETE returns 404 because the order is already gone, but the server's state after two DELETEs is the same as after one. The second POST, by contrast, really changed the state again: there are now two orders.

3What a Timeout Tells the Client

Suppose a client sends a request and waits 5 seconds without an answer. Three very different things may have happened: the request never reached the server, the server is still working on it, or the server finished and the response was lost on the way back. From the client's side, these cases look identical. The client simply does not know whether the operation happened.

So the only safe way to recover is to send the request again in a way that is harmless if it already happened. For an idempotent method that is automatic: repeating a PUT or DELETE cannot do more than the first one did. This is why HTTP clients and proxies may retry idempotent requests on their own, while they must not retry POST without knowing more.

Step throughA lost response followed by a retry
ClientOrder service
POST /orders (lamp)
creates order 901
201 Created ... lost in the network
timeout after 5 s: did it work?
POST /orders (lamp) again
creates order 902
201 Created /orders/902

7 messages in order. Play them, or step through them one at a time.

The customer now has two lamps on order and one payment too many.

4Making a Retried POST Safe

Many important operations are naturally POSTs: placing an order, starting a payment, sending a shipment. To make them safe to retry, the server must deduplicate. The common technique is an idempotency key: the client generates a unique value per intended operation, sends it in a header such as Idempotency-Key, and reuses the same value on every retry. The server stores the key with the result of the first request and, when it sees the key again, returns the stored result instead of doing the work twice.

An alternative is to let the client choose the identifier and use PUT, for example PUT /orders/{clientGeneratedId}. Then a repeat simply replaces the same order with the same content. Either way, the principle is the same: the server needs something in the request that says this is the same operation as before.

5Follow-up questions

Is a PUT that increments a counter idempotent?

No. If PUT /counters/7 means add one, two requests add two, so the effect depends on how many times it is sent, which breaks the definition. It also misuses PUT, whose meaning in HTTP is to replace the target's state with the representation sent. A client or proxy that retries it, trusting that PUT is idempotent, would double the increment. The correct designs are PUT with the full new value (PUT /counters/7 with value 42), ideally guarded by If-Match with an ETag so a concurrent change is detected, or POST /counters/7/increments with an idempotency key.

Can a GET have side effects?

The server may log it, cache it or count it, and that is allowed, because the client did not request a change. What must never happen is a GET that performs a business action such as deleting a record, because crawlers, prefetchers and retries will trigger it freely.

Is PATCH ever idempotent?

It can be, depending on the patch format. A JSON Merge Patch that sets fields to specific values is idempotent in practice, while a JSON Patch operation that adds an element to an array is not. HTTP does not promise it, so clients cannot assume it.

6Conclusion

In this answer, we saw that GET, HEAD, OPTIONS and TRACE are safe and idempotent, PUT and DELETE are idempotent, and POST and PATCH are not in general. Idempotency is about the effect on server state, not identical responses. Because a timeout leaves the client unable to tell whether the request was processed, only idempotent operations are safe to retry, and POSTs become safe only when the server deduplicates them, for example with an idempotency key.

What to say in the interviewAbout 80 seconds aloud

Open with

By the HTTP specification, the safe methods GET, HEAD, OPTIONS and TRACE are idempotent, and so are PUT and DELETE. POST and PATCH are not idempotent in general.

Then, if they want more

Idempotent means that sending the same request several times has the same effect on the server's state as sending it once. It does not mean the response is the same: a second DELETE of the same order usually returns 404, but the order is still just deleted. This matters for retries because a timeout is ambiguous.

The request might not have arrived, might still be running, or might have succeeded with the response lost on the way back, and the client cannot tell which. So the client can only safely resend operations that are harmless to repeat. A repeated PUT or DELETE is harmless.

A repeated POST that creates an order or a payment can create a duplicate, unless the server deduplicates it, typically with an Idempotency-Key header that the client generates once and reuses on every retry, so the server returns the original result.

And a PUT that increments a counter is not idempotent at all; it should send the new value or be a POST with a key.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Which HTTP methods are idempotent by definition, and why does idempotency matter for a...": https://scrivio-interview-library.netlify.app/spring-boot/rest-api-design/aacce62495/