Understanding the Web's Language
When your browser talks to a web server, the server responds with a 3-digit HTTP status code. Understanding these codes is crucial for debugging APIs and building resilient web applications.
The Five Classes
- 1xx (Informational): The request was received, continuing process.
- 2xx (Successful): The request was successfully received, understood, and accepted. (e.g.,
200 OK,201 Created). - 3xx (Redirection): Further action needs to be taken in order to complete the request. (e.g.,
301 Moved Permanently,304 Not Modified). - 4xx (Client Error): The request contains bad syntax or cannot be fulfilled. This means you messed up. (e.g.,
400 Bad Request,401 Unauthorized,404 Not Found). - 5xx (Server Error): The server failed to fulfill an apparently valid request. This means the server messed up. (e.g.,
500 Internal Server Error,502 Bad Gateway).
Designing a REST API? Make sure you return the semantically correct status codes so client applications know exactly how to handle the response. Check our HTTP Status Codes Reference for a complete list.