Search code examples
httphttp-status-code-404crudhttp-status-codeshttp-delete

What response status codes should I return from an HTTP DELETE endpoint?


What response status codes should I return from an HTTP DELETE endpoint in cases:

  • when the resource is present (I believe, it's 200)
  • when the resource is absent (should it be 200 or 404, or smth?)

In other words, should I treat an attempt to delete absent resource as an error, or should I respond with OK instead?


Solution

  • Ok, there’s always an answer in the RFCs:

    A successful response SHOULD be 200 (OK) if the response includes an entity describing the status, 202 (Accepted) if the action has not yet been enacted, or 204 (No Content) if the action has been enacted but the response does not include an entity.