Question:

What is an HTTP status code?

An HTTP status code is a three-digit number a server sends back with every response to tell you whether the request worked. It’s the server’s way of giving you a quick verdict before you even look at the content.

Status codes are grouped by their first digit. 2xx means success (200 is the most common, meaning everything worked). 3xx means a redirect (the resource has moved somewhere else). 4xx means the client did something wrong (404 is “not found”, 401 is “unauthorized”, 403 is “forbidden”). 5xx means the server did something wrong (500 is the generic server error you never want to see).

A few you’ll encounter constantly: 200 OK means success. 201 Created means a new resource was created (common after a POST). 301 Moved Permanently means the URL has changed for good. 400 Bad Request means your request was malformed. 401 Unauthorized means you need to log in. 403 Forbidden means you’re logged in but not allowed. 404 Not Found is self-explanatory. 429 Too Many Requests means you’ve been rate limited. 500 Internal Server Error means something broke on the server.

When you’re debugging an API or building one, status codes are one of the first things to check. A good API uses them precisely so clients know exactly what happened without having to parse the response body.

You might also like