Why is DELETE considered idempotent even if the second call returns a 404 Not Found?
Last updated
Idempotency is about the resulting server state, not the response code. After the first DELETE the resource is gone and repeat calls change nothing further.
The first call returns
200or204and later calls return404, which is fine since identical responses are not required.So a client can safely retry a
DELETEafter a network timeout without corrupting anything.
- https://datatracker.ietf.org/doc/html/rfc7231
- https://dev.to/dwale/is-delete-really-an-idempotent-http-request-3d06
- https://stackoverflow.com/questions/66249638/how-to-handle-put-endpoint-with-immutable-resource
- https://stackoverflow.com/questions/4088350/is-rest-delete-really-idempotent
- https://dev.to/priyanshu_kumawat/idempotency-in-a-rest-api-design-and-why-do-we-need-it-3l0
- https://restfulapi.net/idempotent-rest-apis/
- https://mavericknyk.medium.com/idempotent-rest-apis-eb186c386117
- https://www.restapitutorial.com/introduction/idempotence