Search code examples
httpidempotent

Does idempotency include response codes?


Do repeated requests to idempotent methods have to return the same response code?

A lot of other people are asking the same question and ending up with contradicting answers. The answer should reference an authoritative source on the matter.


Solution

  • I asked this question on the HTTP mailing list and was told that idempotency does not include return codes. Meaning, you are free to return HTTP 204 the first time a resource is deleted, and HTTP 404 at a later time, so long as the subsequent request does not change the server state.

    While it is true that subsequent requests may not change the server state, the response codes are not considered part of that state.