API Directory โ€บ Guides โ€บ HTTP Status Codes Explained (200, 404, 500โ€ฆ)

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

1xxInformational — rare in application code (100 Continue, 101 Switching Protocols).
2xxSuccess. Your request worked.
3xxRedirection. The resource is elsewhere, or hasn’t changed.
4xxClient error. You sent something wrong — don’t blindly retry.
5xxServer error. Their side broke — retrying (with backoff) is reasonable.

The codes you’ll actually meet

Success

200 OKStandard success for GET and most others. Body has what you asked for.
201 CreatedA POST created a resource. Often returns the new object and a Location header.
202 AcceptedRequest queued but not finished — common for async jobs. Poll for the result.
204 No ContentSuccess, deliberately empty body. Typical for DELETE and some PUTs. Don’t call .json() on it.

Redirection

301 / 308 Moved PermanentlyThe URL changed for good. Update your stored URL.
302 / 307 Found / Temporary RedirectFollow it this time, but keep using the original URL.
304 Not ModifiedYour cached copy is still current (you sent If-None-Match / If-Modified-Since). Use the cache.

Client errors — fix the request

400 Bad RequestMalformed syntax, missing required field, invalid JSON. Read the error body.
401 UnauthorizedNo credentials, or they’re invalid/expired. Authenticate, then retry once.
403 ForbiddenAuthenticated, but not allowed to do this. Retrying won’t help — it’s a permissions or plan issue.
404 Not FoundNo resource at this URL. Check the id and the path (and trailing slashes).
405 Method Not AllowedRight URL, wrong verb — e.g. GET on a POST-only endpoint.
409 ConflictThe request clashes with current state — duplicate, version mismatch, already exists.
422 Unprocessable EntitySyntax is fine but the data fails validation (e.g. email not an email).
429 Too Many RequestsRate limited. Read Retry-After and back off — see rate limiting.

Server errors — retry carefully

500 Internal Server ErrorUnhandled error on their side. Retry once or twice with backoff.
502 Bad GatewayA proxy got a bad response from an upstream server. Usually transient.
503 Service UnavailableOverloaded or in maintenance. Honour Retry-After if present.
504 Gateway TimeoutAn 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 jitter

Two 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

Browse all 196 free APIs โ†’

๐Ÿ”Œ Explore free public APIs

Hundreds of free APIs, searchable by category, with auth & CORS at a glance.

Browse the directory โ†’