91

I assume the response code 200 always allows for a response-body, but I can't find any explicit mention of response-bodies for DELETE-requests.

2 Answers 2

163

It is explicitly mentioned here in the RFC

The short answer is:

You should include a response body with an entity describing the deleted item/resource if you return 200.

202 is something like an asynchronous request/response return status.

204 says explicitly that you do not include a response body

4
  • 2
    Upvote for referencing the HTTP spec. Also be aware that they are updating the HTTP spec and clarifying many issues here tools.ietf.org/wg/httpbis Jul 5, 2011 at 13:59
  • 11
    +1 But the spec says you can return 200 ok if the response body contains an entity "describing status" and not the entity deleted.
    – naikus
    Nov 19, 2012 at 11:34
  • 1
    It actually says "includes an entity describing the status" - so returning the deleted entity with a "deleted" flag seems totally valid. May 9, 2014 at 23:45
  • Must 202 (Accepted) response must be body included? Feb 19, 2016 at 9:49
16

Yes, you should usually respond with a 200 response code as per the W3C spec:

9.7 DELETE

The DELETE method requests that the origin server delete the resource identified by the Request-URI. This method MAY be overridden by human intervention (or other means) on the origin server. The client cannot be guaranteed that the operation has been carried out, even if the status code returned from the origin server indicates that the action has been completed successfully. However, the server SHOULD NOT indicate success unless, at the time the response is given, it intends to delete the resource or move it to an inaccessible location.

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.

If the request passes through a cache and the Request-URI identifies one or more currently cached entities, those entries SHOULD be treated as stale. Responses to this method are not cacheable.

1
  • 5
    You've mis-read the language. The codes are listed in ascending order and the order does not imply a preferred response. Each of a 200, 202, or a 204 response are equally acceptable as described in this text. The SHOULD only means that the codes are implemented with the usual conventions (e.g, 200 includes a body and 204 does not). Oct 15, 2015 at 7:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.