CodePark/ questions / Methods, safety & idempotency
START PRACTICINGPRACTICE
Backend question · HTTP & API design › Methods, safety & idempotency

A client sends DELETE /orders/7 twice. The first call returns 204, the second returns 404. Is DELETE still idempotent here?

Yes, because the order is gone after one call or two, so the effect on server state is the same

Yes, DELETE is still idempotent. Idempotency is about the intended effect on server state, not about the response. After one DELETE or two, the order no longer exists. So the effect is the same, even though the status codes differ.

"No, because the two responses are different" is wrong, because idempotency does not require the same response. "Only if the server returns 204 for the second call too" is wrong for the same reason. "No, DELETE is only idempotent when sent with an
If-Match header" is wrong, because DELETE is idempotent by definition, with or without that header.