HomeAPI ConceptsUnderstanding Response Status Codes :A complete guide

Understanding Response Status Codes :A complete guide

- Advertisement -spot_img

HTTP response status codes are used to communicate the result of a server’s attempt to process a request. These codes are categorized into five classes based on the first digit of the code. Here’s a breakdown of each category and the meaning of common status codes:

Understanding Response Status Codes :A complete guide

1xx: Informational Responses – Response Status Codes

These status codes indicate that the request has been received and the process is continuing. They are rarely seen in normal use, but they do have a purpose in certain protocols.

  • 100 Continue
    The server has received the request headers, and the client should proceed to send the request body.
  • 101 Switching Protocols
    The server is switching protocols as requested by the client (e.g., upgrading from HTTP/1.1 to WebSocket).
  • 102 Processing (WebDAV)
    The server is processing the request but has not yet completed it.

2xx: Successful Responses

These codes indicate that the request has been successfully received, understood, and processed by the server.

  • 200 OK
    The request was successful, and the server returned the requested data (for GET) or confirmed the request (for POST, PUT, DELETE, etc.).
  • 201 Created
    The request was successful and resulted in the creation of a new resource (typically used with POST requests).
  • 202 Accepted
    The request has been accepted for processing, but the processing has not been completed. This doesn’t guarantee that the request will be completed.
  • 204 No Content
    The request was successful, but there is no content to return. Often used for DELETE requests.
  • 205 Reset Content
    The server has fulfilled the request and the client should reset the document view.
  • 206 Partial Content
    The server is sending only part of the resource, typically used for partial downloads (e.g., with the Range header).

3xx: Redirection Response Status Codes

These codes indicate that further action is needed by the client to complete the request, often because the requested resource has moved.

  • 300 Multiple Choices
    The request has more than one possible response. The client can choose which resource to follow.
  • 301 Moved Permanently
    The resource has permanently moved to a new URL. The client should use the new URL in future requests.
  • 302 Found (Previously “Moved Temporarily”)
    The resource has been temporarily moved to a different URL. The client should continue to use the original URL for future requests.
  • 303 See Other
    The response to the request can be found under a different URL, using the GET method.
  • 304 Not Modified
    The resource has not been modified since the last request. The client can use the cached version of the resource.
  • 307 Temporary Redirect
    The resource is temporarily located at a different URL, but future requests should still use the original URL.
  • 308 Permanent Redirect
    The resource has been permanently moved to a new URL, and future requests should use this URL.

4xx: Client Error Response Status Codes

These status codes indicate that there was a problem with the request made by the client (the user or the client application).

  • 400 Bad Request
    The server cannot process the request because of malformed syntax or invalid data.
  • 401 Unauthorized
    The request lacks proper authentication credentials (e.g., missing or invalid API key, token, or login credentials).
  • 402 Payment Required
    This code is reserved for future use; however, it may be used for payment-related issues.
  • 403 Forbidden
    The server understood the request but refuses to authorize it. This is different from 401 (Unauthorized) because it indicates that authentication was successful, but the server denies access.
  • 404 Not Found
    The server cannot find the requested resource. The URL may be incorrect, or the resource does not exist.
  • 405 Method Not Allowed
    The HTTP method used is not allowed for the resource (e.g., trying to POST to a read-only resource).
  • 406 Not Acceptable
    The server cannot generate a response that is acceptable according to the Accept headers sent in the request.
  • 407 Proxy Authentication Required
    The client must authenticate with a proxy server before making the request.
  • 408 Request Timeout
    The server timed out waiting for the request from the client. This can happen when the client takes too long to send data.
  • 409 Conflict
    The request could not be completed due to a conflict with the current state of the resource (e.g., attempting to create a duplicate resource).
  • 410 Gone
    The resource is no longer available and has been permanently removed from the server.
  • 411 Length Required
    The request did not specify the Content-Length header, which is required by the server.
  • 412 Precondition Failed
    One of the conditions in the If-* headers (e.g., If-Match, If-None-Match) failed.
  • 413 Payload Too Large
    The request entity is larger than the server is willing or able to process (e.g., uploading a very large file).
  • 414 URI Too Long
    The URL requested by the client is too long for the server to process.
  • 415 Unsupported Media Type
    The server cannot process the request because the content type is not supported.
  • 416 Range Not Satisfiable
    The server cannot fulfill the range request (e.g., requested byte range is beyond the file size).
  • 417 Expectation Failed
    The server cannot meet the expectations specified in the Expect header.
  • 418 I’m a teapot
    This is a joke status code defined in the Hyper Text Coffee Pot Control Protocol (RFC 2324). It’s not used in real-world applications.
  • 422 Unprocessable Entity (WebDAV)
    The server understands the content type of the request entity, but it is unable to process the contained instructions (e.g., semantic errors).
  • 429 Too Many Requests
    The user has sent too many requests in a given amount of time (“rate limiting”).

5xx: Server Error Responses

These status codes indicate that the server failed to fulfill a valid request.

  • 500 Internal Server Error
    A generic error message when the server encounters an unexpected condition that prevents it from fulfilling the request.
  • 501 Not Implemented
    The server does not support the functionality required to fulfill the request (e.g., the server does not support the HTTP method).
  • 502 Bad Gateway
    The server received an invalid response from an upstream server while processing the request (typically in a proxy or gateway setup).
  • 503 Service Unavailable
    The server is temporarily unable to handle the request (e.g., due to being overloaded or down for maintenance).
  • 504 Gateway Timeout
    The server did not receive a timely response from an upstream server or some other auxiliary server.
  • 505 HTTP Version Not Supported
    The server does not support the HTTP protocol version that was used in the request.
  • 507 Insufficient Storage (WebDAV)
    The server is unable to store the representation needed to complete the request.
  • 510 Not Extended
    The server requires further extensions to fulfill the request.

Summary of Key Status Codes

Status CodeDescription
200 OKRequest succeeded, data returned.
301 Moved PermanentlyResource has moved permanently.
302 FoundResource temporarily moved.
400 Bad RequestMalformed request.
401 UnauthorizedAuthentication required.
403 ForbiddenAccess denied.
404 Not FoundResource not found.
500 Internal Server ErrorServer error, something went wrong.
502 Bad GatewayInvalid response from upstream server.
503 Service UnavailableServer temporarily down or overloaded.

These status codes give a lot of insight into what is going on with an HTTP request and response, helping developers debug and manage server-client communication efficiently. You can test your APIs by using Postman, HTTPie, Hoppscotch

Other Keywords

Stay Connected
16,985FansLike
2,458FollowersFollow
61,453SubscribersSubscribe
Must Read
Related News

3 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here