Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

REST Response Code for DELETE Operation, 200 or 204 ?

Should we use 200 OK or 204 No Content as per the response for Delete Operation ?

It is often arguable whether we should use 200 or 204 as response code.

When to use 204

204 Definition
The server has successfully fulfilled the request and that there is no additional content to send in the response payload body.

If you are doing a removal of a data in a non reversible way, the system permanently loses the data, a permanent Delete.

Example : Delete a transaction entry of a particular transaction, identifying it as a duplicate or some other reason.

In such a case, 204 No Content can be used.

When to use 200

200 Definition
200 OK
The request has succeeded.

The payload sent in a 200 response depends on the request method. For the methods defined by this specification, the intended meaning of the payload can be summarized as:

If you are making a soft delete by marking the data, such as setting a flag.

Example : Delete a User who already has relations to Transactions. In this case deleting this user will cause several issues as it has several relations such as transaction and etc. Here the User needs to be marked as deleted by a flag or by setting STATUS to INACTIVE/ DELETED . 

Here it is very important to  handle this in the application to skip INACTIVE users on related activities.


This post first appeared on Devdummy, please read the originial post: here

Share the post

REST Response Code for DELETE Operation, 200 or 204 ?


Subscribe to Devdummy

Get updates delivered right to your inbox!

Thank you for your subscription