HTTP Status Codes Cheat Sheet for Developers and Testers
Every common HTTP status code from 1xx to 5xx in one place, with plain-English meanings, API examples and what testers should verify for each.
- The first digit tells you the class: 1xx info, 2xx success, 3xx redirect, 4xx client error, 5xx server error.
- Use the most specific code: 201 for created, 204 for no content, 422 for validation errors.
- 401 means “not authenticated”; 403 means “authenticated but not allowed”.
- Test both the status code and the response body, because a wrong code with a good body is still a bug.
Every web request ends with a three-digit number that says whether it worked. This HTTP status codes cheat sheet collects the codes you will meet most often when building or testing web apps and APIs.
Developers use status codes to tell clients what happened. Testers use them to check that the system behaves correctly in both good and bad situations. A clear grasp of HTTP status codes saves hours of debugging, especially when you test APIs.
The definitions follow the HTTP standard in RFC 9110, and the MDN status code reference is a handy companion. If APIs are new to you, start with our guide on what is an API.
The five classes of HTTP status codes
| Class | Meaning | Example |
|---|---|---|
| 1xx | Informational, request received | 100 Continue |
| 2xx | Success | 200 OK |
| 3xx | Redirection, more action needed | 301 Moved Permanently |
| 4xx | Client error, the request is wrong | 404 Not Found |
| 5xx | Server error, the server failed | 500 Internal Server Error |
HTTP status codes cheat sheet: 2xx success
| Code | Name | When to use it |
|---|---|---|
| 200 | OK | Request succeeded; response has a body (GET, PUT). |
| 201 | Created | A new resource was created (POST). Usually includes a Location header. |
| 202 | Accepted | Request accepted for later processing, such as a background job. |
| 204 | No Content | Success with no body, common for DELETE. |
| 206 | Partial Content | A range of the resource was returned, such as video streaming. |
HTTP status codes cheat sheet: 3xx redirection codes
| Code | Name | When to use it |
|---|---|---|
| 301 | Moved Permanently | The URL has changed for good; search engines update links. |
| 302 | Found | Temporary redirect. |
| 304 | Not Modified | Cached copy is still valid. |
| 307 | Temporary Redirect | Temporary redirect that keeps the HTTP method. |
| 308 | Permanent Redirect | Permanent redirect that keeps the HTTP method. |
HTTP status codes cheat sheet: 4xx client error codes
| Code | Name | Typical cause |
|---|---|---|
| 400 | Bad Request | Malformed JSON or missing required data. |
| 401 | Unauthorized | No valid credentials or an expired token. |
| 403 | Forbidden | Logged in but not allowed to do this. |
| 404 | Not Found | The resource or URL does not exist. |
| 405 | Method Not Allowed | Wrong HTTP method for this endpoint. |
| 409 | Conflict | State conflict, such as a duplicate record. |
| 410 | Gone | Resource was removed on purpose. |
| 415 | Unsupported Media Type | Wrong Content-Type header. |
| 422 | Unprocessable Content | Valid format but failed validation rules. |
| 429 | Too Many Requests | Rate limit exceeded; check the Retry-After header. |
401 vs 403 vs 404
These three cause the most confusion. A 401 means the server does not know who you are. A 403 means it knows you but you lack permission. A 404 means the thing does not exist, although some APIs return 404 instead of 403 to avoid revealing that a private resource exists.
HTTP status codes cheat sheet: 5xx server error codes
| Code | Name | Typical cause |
|---|---|---|
| 500 | Internal Server Error | Unhandled exception on the server. |
| 501 | Not Implemented | The server does not support the feature. |
| 502 | Bad Gateway | A proxy got an invalid reply from an upstream server. |
| 503 | Service Unavailable | Overloaded or down for maintenance. |
| 504 | Gateway Timeout | An upstream server took too long to respond. |
Quick tip: A 5xx response should never expose stack traces or database errors to users. Test that error bodies are safe as well as correct.
How to test HTTP status codes
For each endpoint, write at least one test for the happy path and for each expected error. Here is a short Python example with the requests library:
import requests
BASE = "https://api.example.com"
def test_create_user_returns_201():
r = requests.post(f"{BASE}/users", json={"name": "Asha", "email": "asha@example.com"})
assert r.status_code == 201
assert "id" in r.json()
def test_missing_token_returns_401():
r = requests.get(f"{BASE}/me")
assert r.status_code == 401
def test_unknown_user_returns_404():
r = requests.get(f"{BASE}/users/999999", headers={"Authorization": "Bearer TOKEN"})
assert r.status_code == 404
Use this checklist when you review an API:
- Successful create returns 201, not 200.
- Delete returns 204 or 200 consistently.
- Validation failures return 400 or 422 with helpful messages.
- Missing or expired tokens return 401; missing permissions return 403.
- Unknown IDs return 404, not 500.
- Rate limiting returns 429 with a Retry-After header.
- Server failures return 5xx without leaking internal details.
Our API testing with Postman guide shows how to automate these checks in a collection, and our REST API best practices article explains how to pick the right code when designing endpoints.
Final thoughts
Keep this HTTP status codes cheat sheet bookmarked. Learn the five classes first, then the ten or so codes you meet daily: 200, 201, 204, 301, 400, 401, 403, 404, 429 and 500. Use the most accurate code in your API and verify every expected error in your tests.
Frequently asked questions
What do the HTTP status code classes mean?
1xx is informational, 2xx is success, 3xx is redirection, 4xx is a client error and 5xx is a server error.
What is the difference between 401 and 403?
401 means the request lacks valid authentication. 403 means the user is authenticated but not permitted to perform the action.
Should a POST return 200 or 201?
Return 201 Created when a new resource is created. Use 200 only when the POST performs an action without creating something.
When should an API return 422?
Use 422 when the request is well formed but fails business or validation rules. Some teams use 400 for this, so stay consistent.
What causes a 502 or 504 error?
Both involve a gateway or proxy. 502 means it received a bad reply from an upstream server, while 504 means the upstream server timed out.
Keep learning
Need help with testing, WordPress or SEO?
We help teams ship better software and grow their sites. Tell us what you are working on and we will suggest a clear next step.