The Hypertext Transfer Protocol (HTTP) is a stateless application level protocol for distributed, collaborative, hypertext information systems. Every request to the server is completely new and not related to the previous one. Status codes are used to represent the status response of the client request (HTTP request) to the server. These status codes are part of of the HTTP/1.1 standard (RFC 7231). The first digit of the status code specifies one of five standard classes of responses. The most common HTTP status Code that you normally encounter in day to day life are as follows:
Status 200 OK:
The standard success code and default option.
Status 201 Object created:
Useful for the
Status 204 No Content:
When an action was executed successfully, but there is no content to return.
Status 206 Partial content:
Useful when you have to return a paginated list of resources.
Status 301 Moved Permanently:
Useful when you have to redirect to the given URI.
Status 307 Moved Temporarily:
Useful when requested resource resides temporarily under a different URI.
Status 400 Bad request:
The standard option for requests that fail to pass validation.
Status 401 Unauthorized:
The user needs to be authenticated.
Status 403 Forbidden:
The user is authenticated, but does not have the permissions to perform an action.
Status 404 Not found:
This will be returned automatically when the resource is not found.
Status 500 Internal server error:
Ideally you’re not going to be explicitly returning this, but if something unexpected breaks, this is what your user is going to receive.
Status 503 Service unavailable:
Pretty self explanatory, but also another code that is not going to be returned explicitly by the application.