6

I'm implementing DELETE support on a ReST API (build on ServiceStack) and wondering what response code to return following a successful DELETE.

HTTP defines 410 as:

The requested resource is no longer available at the server and no forwarding address is known. This condition is expected to be considered permanent. Clients with link editing capabilities SHOULD delete references to the Request-URI after user approval. If the server does not know, or has no facility to determine, whether or not the condition is permanent, the status code 404 (Not Found) SHOULD be used instead. This response is cacheable unless indicated otherwise.

Now, if a resource has just been DELETEd, I probably do want many of those recommendations to apply... but accepted practice seems to be returning a 200 OK following a successful DELETE - especially since the 4XX range is supposed to denote error conditions.

Any compelling arguments one way or another beyond the guidelines in the HTTP spec?

Dylan Beattie
  • 53,688
  • 35
  • 128
  • 197
  • Since your DELETE request is all about the delete action, you should respond with a 200 because that action was completed successfully. If someone later requests that resource via a GET, his action is all about getting the resource and should then be answered with some 4xx, maybe 410 or just 404 for simplicity. – ToBe Jan 09 '14 at 16:21

1 Answers1

10

RFC 2616 Section 9.7 specifically states the following regarding the response for DELETE:

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.

Dylan Beattie
  • 53,688
  • 35
  • 128
  • 197
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770