About http status code lookup
HTTP status codes tell you what happened to a request. They are grouped by their first digit.
The groups
- 1xx: informational.
- 2xx: success, such as 200 OK and 201 Created.
- 3xx: redirection, such as 301 Moved Permanently and 302 Found.
- 4xx: client error, such as 400 Bad Request, 401 Unauthorized, 403 Forbidden and 404 Not Found.
- 5xx: server error, such as 500 Internal Server Error and 503 Service Unavailable.
401 versus 403
401 means you are not authenticated; 403 means you are known but not allowed.
A worked example
A payment API returns 429, which means Too Many Requests: slow down and retry after the time in the Retry-After header. A 503 means the server is temporarily unavailable, and 504 means a gateway timed out waiting for another server.
Picking the right code
- 201 Created after a successful POST that makes something new.
- 204 No Content for success with nothing to return.
- 400 for bad input, 401 for missing login and 403 for no permission.
- 404 when a resource does not exist, 409 for a conflict.
