← Blog

Claude API HTTP Status Codes Explained

2026-11-13 · 5 min read · SubToAPI Team

When you call the Claude API, the HTTP status code on the response tells you exactly what happened before you even look at the response body. A 200 means your request succeeded, a 4xx means something about your request was wrong, and a 5xx means the problem is on Anthropic's side. Knowing what each code means — and what to do about it — is the difference between an integration that silently fails and one that recovers gracefully.

This article walks through every status code you'll realistically encounter when calling the Claude API (or a proxy like SubToAPI that sits in front of it), what causes each one, and the correct handling strategy for each.

The Status Codes You'll Actually See

200 — Success

The request was processed and the response body contains your message, tool call, or stream. For streaming requests, a 200 means the connection was accepted — individual events in the stream can still carry error information, so don't assume success just because the initial status is 200.

400 — Bad Request

The request body is malformed or violates a constraint the API enforces before it even tries to run the model. Common causes:

curl https://api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "content-type: application/json" \
  -d '{"model": "claude-sonnet-4-5", "messages": []}'

This fails with a 400 because messages can't be empty. Fix the payload — retrying without changes will fail identically every time.

401 — Authentication Error

Your API key is missing, malformed, or invalid. Check that you're sending it in the correct header and that the key hasn't been revoked or rotated. If you're using SubToAPI, your application key (sub_live_...) goes in Authorization: Bearer $SUBTOAPI_KEY — mixing this up with a raw Anthropic key format is a common source of 401s during migration.

403 — Permission Denied

The key is valid but doesn't have permission for the requested action — for example, calling a model your account or tier doesn't have access to. This is distinct from 401: the credential itself is accepted, but the action is forbidden.

404 — Not Found

The endpoint path is wrong, or you're referencing a resource (like a file or batch ID) that doesn't exist. Double-check the URL against the docs — a stray trailing slash or an outdated path from an old integration is the usual culprit.

413 — Request Too Large

Your request body exceeds the maximum allowed size, usually because of a large messages array, a big base64-encoded image, or an oversized tool schema. Trim the payload or split the work into smaller requests.

422 — Unprocessable Entity

The request is well-formed JSON but semantically invalid for the model — for instance, an image format the model can't process, or a tool definition with an invalid JSON Schema. Validate structured inputs (especially tool definitions) before sending them.

429 — Rate Limited

You've exceeded your requests-per-minute, tokens-per-minute, or concurrent-request limit. This is the most common code production systems need to handle gracefully, because it happens under normal operation, not just when something is broken.

The correct response is exponential backoff with jitter, respecting the retry-after header if present:

async function callWithBackoff(fn, maxRetries = 5) {
  for (let attempt = 0; attempt < maxRetries; attempt++) {
    const res = await fn();
    if (res.status !== 429) return res;

    const retryAfter = res.headers.get("retry-after");
    const delay = retryAfter
      ? Number(retryAfter) * 1000
      : Math.min(1000 * 2 ** attempt, 30000) + Math.random() * 500;

    await new Promise((r) => setTimeout(r, delay));
  }
  throw new Error("Max retries exceeded");
}

Never retry immediately on a 429 in a tight loop — that just extends the throttling window and burns your rate limit budget further.

500 — Internal Server Error

Something went wrong on the API provider's infrastructure. This is not your fault and not usually retryable with any guarantee of success, but a single retry after a short delay is reasonable.

529 — Overloaded

The API is temporarily at capacity. This behaves like a 429 for handling purposes: back off and retry, ideally with a slightly longer initial delay since overload conditions tend to last longer than per-key rate limits.

Building a Status Code Handler

A production integration should branch on status code family, not just check for 200:

function classify(status) {
  if (status === 200) return "ok";
  if (status === 429 || status === 529) return "retry";
  if (status >= 500) return "retry-once";
  if (status >= 400) return "fatal";
  return "unknown";
}

Treat 400, 401, 403, 404, 413, and 422 as fatal for that request — retrying without changing anything will keep failing. Treat 429 and 529 as retryable with backoff. Treat 500 as retryable once, then surface the failure.

Why This Matters More With Proxies and Wrappers

If you're calling Claude through a layer like SubToAPI — which turns your Claude access into a standard HTTPS API with sub_live_... keys — the same status code conventions apply, since the goal is to behave like a normal REST API your existing HTTP client code already knows how to handle. That means your retry logic, backoff handling, and error branching work the same way whether you're calling the model directly or through the wrapper, which is useful if you're migrating an integration or adding team seats without rewriting your error-handling code. See the quickstart and messages docs for the exact response shapes.

Questions

Does a 200 status guarantee the model completed successfully? For non-streaming requests, yes — the model finished and the response body contains the result. For streaming requests, the initial 200 only confirms the connection was accepted; check the stream events themselves for errors, covered in the streaming docs.

Should I retry every 4xx error? No. 4xx codes mean your request was invalid in some way, so retrying unchanged will produce the same error. Fix the request first. The only exception some teams make is retrying 408-style timeouts, which Claude's API doesn't typically return.

What's the difference between 429 and 529? 429 means you personally have exceeded your rate limit. 529 means the API as a whole is overloaded, independent of your usage. Both should be handled with exponential backoff, but a 529 often warrants a longer initial wait since it reflects broader system load rather than your specific quota.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →