DEV Community

Manish R Warang
Manish R Warang

Posted on • Originally published at blog.g33kzone.com on

HTTP Status Codes :: 200 vs 202 vs 204

With the world embracing microservices architecture, we as developers are now heavily involved in designing / consuming API's. One of the most important aspect of such webservices design is to have the right HTTP status codes mapped. This enables the consumer (of the webservice) to get more insight around the response received.

One of the dilemma I had encountered was to figure out the right 2xx Success HTTP status code for Update (HTTP PUT) / Delete (HTTP DELETE) scenarios. Had narrowed down on 200 / 202 / 204 Http Status codes.

Lets go through the official definition for these status codes first to help us understand better.

HTTP 200 OK

The request has been fulfilled and resulted in a new resource being created.

HTTP 202 Accepted

The request has been accepted for processing, but the processing has not been completed.

HTTP 204 No Content

The server has fulfilled the request but does not need to return an entity-body, and might want to return updated meta-information.

Based on the above definitions, 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 response body.

Top comments (0)