HTTP Status Codes
Every HTTP status code from 100 to 511, with a plain explanation of what it means and when a server sends it. Search by number or words like "redirect" or "rate limit".
Questions
What do the first digits mean?
1xx is informational, 2xx means success, 3xx means redirection, 4xx means the client made a mistake and 5xx means the server failed.
Should I return 401 or 403?
Return 401 when the user is not logged in or the token is invalid, because logging in could fix it. Return 403 when the user is logged in but does not have permission.
Should I return 400 or 422?
Many APIs use 400 when the request cannot be parsed, such as broken JSON, and 422 when it parses fine but fails validation rules.
Which redirect should I use?
Use 301 or 308 for permanent moves and 302 or 307 for temporary ones. Choose 307 or 308 when the method and body must stay the same, such as for a POST.