# HTTP response code when DELETE request is not permitted

**URL:** <https://www.ruby-forum.com/t/http-response-code-when-delete-request-is-not-permitted/132180>\
**Category:** Rails\
**Created:** [March 17, 2008, 6:09pm UTC](https://www.ruby-forum.com/t/http-response-code-when-delete-request-is-not-permitted/132180 "2008-03-17T18:09:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Olly\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/eb8c5e/32.png) [@Olly\_L](https://www.ruby-forum.com/u/Olly_L)\
**Post date:** [March 17, 2008, 6:09pm UTC](https://www.ruby-forum.com/t/http-response-code-when-delete-request-is-not-permitted/132180/1 "2008-03-17T18:09:41Z")

</div>

Hi there,

If a DELETE request on a resource fails because constraints prevent  
the resource from being deleted, what should the correct HTTP response  
code be?

There appears to be a lot of contention about this on the web, but I’m  
unable to find a ‘definitive guide’ for the sort of REST API I’m  
developing. Perhaps someone could point me in the right direction?

I’m currently of the opinion that 403 Forbidden is the best option,  
although 405 Method Not Allowed sounds equally appropriate, or perhaps  
even 409 Conflict.

Advice appreciated.

Thanks  
Olly

---

<div class="post-metadata">

**Author:** ![Olly\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/eb8c5e/32.png) [@Olly\_L](https://www.ruby-forum.com/u/Olly_L)\
**Post date:** [March 17, 2008, 8:18pm UTC](https://www.ruby-forum.com/t/http-response-code-when-delete-request-is-not-permitted/132180/2 "2008-03-17T20:18:03Z")

</div>

On Mon, Mar 17, 2008 at 10:08 AM, Olly L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m currently of the opinion that 403 Forbidden is the best option,  
> although 405 Method Not Allowed sounds equally appropriate, or perhaps  
> even 409 Conflict.

I believe 403 is an authentication header, as in ‘your login failed’.  
405 means the DELETE method itself isn’t allowed. ActiveResource uses  
409 for locking conflicts, and 422 for validation errors.

According to rfc 2616, it sounds like 409 would be your best bet:

The request could not be completed due to a conflict with the current  
state of the resource. This code is only allowed in situations where  
it is expected that the user might be able to resolve the conflict and  
resubmit the request.

[http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html)

That sounds better than 422, unprocessable entity:

The request was well-formed but was unable to be followed due to  
semantic errors.

> **[List of HTTP status codes](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Client_Error)**
>
> This is a list of Hypertext Transfer Protocol (HTTP) response status codes. Status codes are issued by a server in response to a client's request made to the server. It includes codes from IETF Request for Comments (RFCs), other specifications, and some additional codes used in some common applications of the HTTP. The first digit of the status code specifies one of five standard classes of responses. The optional message phrases shown are typical, but any human-readable alternative may be prov...

There are many ways to interpret that though. I think the key is to  
document it well and stick to it.

–  
Rick O.  
[http://lighthouseapp.com](http://lighthouseapp.com)  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)

---

<div class="post-metadata">

**Author:** ![Olly\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/eb8c5e/32.png) [@Olly\_L](https://www.ruby-forum.com/u/Olly_L)\
**Post date:** [March 18, 2008, 1:41pm UTC](https://www.ruby-forum.com/t/http-response-code-when-delete-request-is-not-permitted/132180/3 "2008-03-18T13:41:07Z")

</div>

I agree – 409 it is.

Thanks Rick.
