Thinking About API Status Codes For Destroying Entities Using DELETE

March 12, 2018

I am pulling together some API design guidance for some projects I’m consulting on, so I’m spending time reviewing the API design guides the leading API providers who have published them publicly. Learning from what they are doing across their own companies, organizations, institutions, and government agencies when it comes to sensible API governance.

Today, I am learning from the British food delivery company, Deliveroo, and documenting their guidance for which HTTP status codes should be returned for any API methods that use DELETE:

If it exists, it should return status:

  • 204 No Content if the entity was successfully destroyed,
  • 404 Not Found if the entity does not exist
  • 410 Gone if the entity is known to have existed but no longer does.

Additionally 4xx response codes may be used:

  • 412 Precondition Failed
  • 415 Unsupported if using versioning and the server doesn’t support the specified version.

I have to admit, I haven’t been properly publishing status codes any DELETE methods I provide. I’ve just been returning a 200 if successful, and 404 if it didn’t exist. I hadn’t put any further thought into the proper way of handling it. I just haven’t had the time, or the knowledge within reach to be able to handle properly.

I know that the RESTafarians enjoy debating these finer details of API design, and using HTTP, but for the rest of us, we just need some guidance from y’all. Which is why I spend time learning from existing API leaders who publish their API design guidance, and sharing as individual stories here on the blog, as well as including in my official project consulting guidance.

Read more...

Previous Article
Some Common API Data Types To Put To Use
Some Common API Data Types To Put To Use

I’m continuing my exploration of the API design guidance published by leading API providers. This time, I ...

Next Article
A Machine Readable Baseline For API Providers In My API Stack Work
A Machine Readable Baseline For API Providers In My API Stack Work

I’m rebooting my API Stack work as part of my partnership with Streamdata.io. I’m spending a significant p...