HTTP Status Codes

HTTP Status Codes best practises

In REST, HTTP status codes are used to tell the client whether its request has been accepted. Likewise, the status code contains information so that the client knows what is happening with the content of the request.

For example, the server can process a request synchronously and respond with 200 (Ok), but it can also perform sequential actions asynchronously and the client only receives information that the request was accepted (201, Created).

It is therefore very important to implement REST APIs in such a way that the status codes are used correctly.

Status Code ranges

The first digit of the Status Code defines the class of response.

Status Code Category Description
1xx Informational The request received. Process is still ongoing.
2xx Success The request was received and accepted successfully.
3xx Redirection An additional action must be taken in order to complete the request.
4xx Client Error The request contains a (validation) error, bad syntax or cannot be fulfilled.
5xx Server Error The server failed.