HTTP Codes
HTTP status codes are standardized response codes sent by web servers. I grouped them into five categories.
Range | Category |
---|---|
1xx | Informational |
2xx š¢ | Success |
3xx š | Redirection |
4xx š“ | Client Errors |
5xx š“ | Server Errors |
and the most used ones...
š¢ 200 OK Request succeeded. Standard response for `GET`, `POST`, or `PUT`.
š¢ 201 Created Resource successfully created. Common with `POST`.
š¢ 202 Accepted Request accepted for processing, but not completed yet.
š¢ 204 No Content Request succeeded, no response body. Often for `DELETE`.
š 301 Moved Permanently Resource has permanently moved. Use new URL.
š 302 Found Temporary redirect. Browser should use the URL provided.
š 304 Not Modified Cached version is still valid. Saves bandwidth.
š 307 Temporary Redirect Same as 302 but preserves HTTP method.
š“ 400 Bad Request Server cannot process malformed request.
š“ 401 Unauthorized Client must authenticate (e.g. via token).
š“ 403 Forbidden Client is authenticated but not authorized.
š“ 404 Not Found Resource does not exist.
š“ 405 Method Not Allowed HTTP method is not supported by the resource.
š“ 409 Conflict Request conflicts with current server state (e.g. duplicate record).
š“ 422 Unprocessable Entity Valid data structure, but semantically invalid (common in form validation).
š“ 500 Internal Server Error Catch-all for unexpected server errors.
š“ 501 Not Implemented Server does not support the requested functionality.
š“ 502 Bad Gateway Server received an invalid response from upstream server.
š“ 503 Service Unavailable Server is down or overloaded.
š“ 504 Gateway Timeout Upstream server did not respond in time.
HTTP Codes Dictionary
/**
* Dictionary of common HTTP status codes mapped to their numeric value.
*/
export const HttpsCode = {
/**
* Official Documentation @ https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.1
*
* š¢ The request has succeeded.
*/
OK: 200,
/**
* Official Documentation @ https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.2
*
* š¢ The request has succeeded and a new resource has been created as a result.
* Often used in response to POST or PUT.
*/
CREATED: 201,
/**
* Official Documentation @ https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.5
*
* š¢ The server successfully processed the request and is not returning any content.
* Often used in DELETE operations.
*/
NO_CONTENT: 204,
/**
* Official Documentation @ https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.2
*
* š This response code means that the URI of the requested resource has been changed permanently.
*/
MOVED_PERMANENTLY: 301,
/**
* Official Documentation @ https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.3
*
* š This response code means that the URI of requested resource has been changed temporarily.
*/
FOUND: 302,
/**
* Official Documentation @ https://datatracker.ietf.org/doc/html/rfc7232#section-4.1
*
* š Indicates that the resource has not been modified since the version specified by the request headers.
* Saves bandwidth by allowing cached content.
*/
NOT_MODIFIED: 304,
/**
* Official Documentation @ https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.1
*
* š“ The server could not understand the request due to invalid syntax.
*/
BAD_REQUEST: 400,
/**
* 401 Unauthorized
*
* Official Documentation @ https://datatracker.ietf.org/doc/html/rfc7235#section-3.1
*
* š“ Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated".
* That is, the client must authenticate itself to get the requested response.
*/
UNAUTHORIZED: 401,
/**
* 403 Forbidden
*
* Official Documentation @ https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.3
*
* š“ The client does not have access rights to the content; i.e., it is unauthorized, so the server is refusing to give the requested resource.
*/
FORBIDDEN: 403,
/**
* Official Documentation @ https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.4
*
* š“ The server can not find the requested resource.
*/
NOT_FOUND: 404,
/**
* Official Documentation @ https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.5
*
* š“ The request method is known by the server but has been disabled and cannot be used for the resource.
*/
METHOD_NOT_ALLOWED: 405,
/**
* Official Documentation @ https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.8
*
* š“ This response is sent when a request conflicts with the current state of the server.
*/
CONFLICT: 409,
/**
* Official Documentation @ https://datatracker.ietf.org/doc/html/rfc4918#section-11.2
*
* š“ The request was well-formed but was unable to be followed due to semantic errors.
* Often used for validation errors.
*/
UNPROCESSABLE_ENTITY: 422,
/**
* Official Documentation @ https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.1
*
* š“ The server encountered an unexpected condition that prevented it from fulfilling the request.
*/
INTERNAL_SERVER_ERROR: 500,
/**
* Official Documentation @ https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.3
*
* š“ The server was acting as a gateway or proxy and received an invalid response from the upstream server.
*/
BAD_GATEWAY: 502,
/**
* Official Documentation @ https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.4
*
* š“ The server is not ready to handle the request. Common causes: server down or overloaded.
*
* Note that together with this response, a user-friendly page explaining the problem should be sent. This responses should be used for temporary conditions and the Retry-After: HTTP header should, if possible, contain the estimated time before the recovery of the service. The webmaster must also take care about the caching-related headers that are sent along with this response, as these temporary condition responses should usually not be cached.
*/
SERVICE_UNAVAILABLE: 503,
/**
* Official Documentation @ https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.5
*
* š“ The server, while acting as a gateway, did not receive a response in time from the upstream server.
*/
GATEWAY_TIMEOUT: 504
}