HTTP Status Codes Explained (200, 404, 500โฆ)
Every API response comes with a status code. Here's what the common ones mean and how to react to them.
Every HTTP response starts with a three-digit status code that tells you, at a glance, what happened. Read it before you touch the response body — it decides whether you parse the body, retry, fix your request, or show the user an error.
The five classes
| 1xx | Informational — rare in application code (100 Continue, 101 Switching Protocols). |
| 2xx | Success. Your request worked. |
| 3xx | Redirection. The resource is elsewhere, or hasn’t changed. |
| 4xx | Client error. You sent something wrong — don’t blindly retry. |
| 5xx | Server error. Their side broke — retrying (with backoff) is reasonable. |
The codes you’ll actually meet
Success
| 200 OK | Standard success for GET and most others. Body has what you asked for. |
| 201 Created | A POST created a resource. Often returns the new object and a Location header. |
| 202 Accepted | Request queued but not finished — common for async jobs. Poll for the result. |
| 204 No Content | Success, deliberately empty body. Typical for DELETE and some PUTs. Don’t call .json() on it. |
Redirection
| 301 / 308 Moved Permanently | The URL changed for good. Update your stored URL. |
| 302 / 307 Found / Temporary Redirect | Follow it this time, but keep using the original URL. |
| 304 Not Modified | Your cached copy is still current (you sent If-None-Match / If-Modified-Since). Use the cache. |
Client errors — fix the request
| 400 Bad Request | Malformed syntax, missing required field, invalid JSON. Read the error body. |
| 401 Unauthorized | No credentials, or they’re invalid/expired. Authenticate, then retry once. |
| 403 Forbidden | Authenticated, but not allowed to do this. Retrying won’t help — it’s a permissions or plan issue. |
| 404 Not Found | No resource at this URL. Check the id and the path (and trailing slashes). |
| 405 Method Not Allowed | Right URL, wrong verb — e.g. GET on a POST-only endpoint. |
| 409 Conflict | The request clashes with current state — duplicate, version mismatch, already exists. |
| 422 Unprocessable Entity | Syntax is fine but the data fails validation (e.g. email not an email). |
| 429 Too Many Requests | Rate limited. Read Retry-After and back off — see rate limiting. |
Server errors — retry carefully
| 500 Internal Server Error | Unhandled error on their side. Retry once or twice with backoff. |
| 502 Bad Gateway | A proxy got a bad response from an upstream server. Usually transient. |
| 503 Service Unavailable | Overloaded or in maintenance. Honour Retry-After if present. |
| 504 Gateway Timeout | An upstream server took too long. Retry with backoff; consider a longer client timeout. |
A retry rule of thumb
def should_retry(status):
if status in (429, 500, 502, 503, 504):
return True # transient - back off and retry
return False # 4xx (except 429): fix the request, don't retry
# always cap retries (e.g. 3) and use exponential backoff with jitterTwo more habits: log the response body on any 4xx (that’s where the API tells you what was wrong), and never treat “got a response” as “it worked” — a 200 with an error object in the body is still an error.
FAQ
What does HTTP status code 200 mean?
200 OK means the request succeeded and the response body contains what you asked for. It’s the normal result for a successful GET.
What is the difference between 401 and 403?
401 Unauthorized means you’re not authenticated — no valid credentials. 403 Forbidden means you are authenticated but aren’t allowed to do this. Retrying a 403 with the same credentials will never work.
Should I retry a 4xx error?
Generally no — 4xx means your request was wrong, so fix it. The exception is 429 (rate limited): wait for the Retry-After period, then retry.
What does 429 Too Many Requests mean?
You’ve exceeded the API’s rate limit. Slow down, read the Retry-After header for how long to wait, and add backoff so it doesn’t happen again.
Is a 304 an error?
No. 304 Not Modified is a success case for conditional requests — it means your cached copy is still valid, so use it instead of downloading the resource again.
Keep going
Try it on a real API
๐ Explore free public APIs
Hundreds of free APIs, searchable by category, with auth & CORS at a glance.
Browse the directory โ