Every HTTP response starts with a three-digit status code. The first digit tells you the class of result, and a handful of codes cover almost everything you will see while building or debugging an API.
The five classes
1xx codes are informational, for example 101 when a connection switches to WebSocket. 2xx means success. 3xx means the client must look elsewhere, usually a redirect. 4xx means the request was wrong in some way, and 5xx means the server failed on a valid request.
Clients and monitoring tools often react to the class alone, so picking the right class matters more than picking the perfect code.
Success codes worth knowing
200 OK is the default. 201 Created is for a POST that made a new resource, ideally with a Location header. 204 No Content means success with no body, common for DELETE. 202 Accepted means the work was queued and has not finished.
Pairs people confuse
401 means the request is not authenticated, so supplying credentials can fix it. 403 means the server knows who you are and still says no. For redirects, 301 and 308 are permanent and pass search ranking to the new URL, while 302 and 307 are temporary. 307 and 308 also keep the request method, which 301 and 302 do not guarantee.
Among server errors, 500 is a generic failure, 502 means a gateway got a bad answer from upstream, 503 means the service is overloaded or down for maintenance, and 504 means upstream took too long.
Choosing a code for your own API
Use 400 for malformed requests and 422 for well-formed requests that fail validation. Use 404 when the resource does not exist, 409 for conflicts with current state and 429 when you rate limit, with a Retry-After header if you can. Return real 5xx codes for real server faults so alerts and retries behave correctly.