A 429 from Claude’s API can mean three different things — a per-minute rate limit, an organization spend cap, or a Claude Code workspace limit — and only one of those actually resolves itself if you just wait and retry. Anthropic’s own API error documentation lays out exactly which status codes the official SDK retries automatically and which ones mean the request is simply wrong. The table and notes below work through that documentation status by status, including two gotchas that trip up retry logic built from guesswork instead of the docs.
The full table, straight from Anthropic’s documentation
| Status | Error type | Meaning | Retry? |
|---|---|---|---|
| 400 | invalid_request_error | Malformed request, or an org/workspace spend limit hit | No — fix the request |
| 401 | authentication_error | API key malformed, revoked, or expired | No — fix credentials |
| 402 | billing_error | Billing or payment issue | No — check payment details |
| 403 | permission_error | API key lacks permission for the resource | No — check access |
| 404 | not_found_error | Resource not found | No — check the path/ID |
| 409 | conflict_error | Request conflicts with current resource state | Resolve conflict, then retry |
| 413 | request_too_large | Request exceeds the size limit | No — reduce request size |
| 429 | rate_limit_error | Rate limit, spend cap, or workspace limit hit | Sometimes — see below |
| 500 | api_error | Unexpected internal error | Yes — exponential backoff |
| 504 | timeout_error | Request timed out while processing | Use streaming or Batches instead |
| 529 | overloaded_error | API temporarily overloaded across all users | Yes — exponential backoff |
The documentation doesn’t label every code “retryable” or “not retryable” directly — that distinction comes from how Anthropic’s own SDK behaves. The official client retries connection errors, rate limits, and 5xx errors with exponential backoff, which is the practical definition of “transient” here: if the SDK itself doesn’t bother retrying a code automatically, treat it as permanent until the request is fixed.
The 429 gotcha: one status code, three different causes
A 429 is the one code on this table that needs more than a glance at the status number. It fires for a per-minute or per-token rate limit, for hitting a monthly spend cap you configured, and — specifically for the Claude Code workspace — for its own separate spend limit. Only the first case is reliably transient. Anthropic’s documentation is explicit that a spend-cap 429 “has no retry-after header and keeps failing until access resumes,” which means a retry loop that doesn’t check for the header will keep burning requests against a wall that isn’t moving. Reading the retry-after header before deciding how long to wait, rather than hard-coding a backoff schedule, is what separates error handling that was built from the docs from error handling that was built from assumption.
The 529 overloaded_error: what “treated as transient” actually means
A 529 means the API is under heavy load across all users, not that anything about your specific request was wrong. It falls under the SDK’s general 5xx retry handling, so the default client retries it with exponential backoff the same way it retries a 500. The practical difference from a 500 is informational more than behavioral: a 529 tells you the problem is capacity, not a bug on either side, so there’s nothing to fix in the request itself — the only lever is how patient your retry schedule is.
The common mistake: matching on error message text instead of status codes
Anthropic’s documentation states this directly: catch the specific SDK exception classes first, and don’t match on error message strings. It’s a common shortcut to write if "rate limit" in str(error) because it feels quicker than importing the right exception class, and it breaks the moment Anthropic rewords a message or adds a new error type that happens to contain similar text. The Python SDK gives distinct exception classes — RateLimitError for 429, InternalServerError for 5xx, APIStatusError as the catch-all for everything else — specifically so error handling can branch on type rather than parsing prose. The Go SDK collapses these into a single *anthropic.Error type, so the equivalent discipline there is branching on StatusCode instead of the error string.
Mid-stream errors don’t follow the same rules
Everything above assumes the error arrives as the response to your request. A streaming response is different: the connection can return a 200 and start sending content, then encounter a problem partway through. Standard status-code handling never sees that failure, because the HTTP status was already 200 before anything went wrong. Anthropic’s streaming documentation covers this separately under error events, and any retry logic built only around HTTP status codes needs a second path specifically for a stream that starts successfully and then fails mid-response. In practice that means listening for an explicit error event in the stream handler, separate from whatever wraps the initial request, rather than assuming a 200 status guarantees a clean finish.
Request size limits that trigger a 413
A 413 is one of the simpler codes to fix, but only if you know the actual ceiling for the endpoint you’re calling — Anthropic sets a different limit for each one, and assuming the Messages API limit applies everywhere is how a Files API upload fails for a reason that looks unrelated.
| Endpoint | Max request size |
|---|---|
| Messages API | 128 MB |
| Token Counting API | 128 MB |
| Message Batches API | 256 MB |
| Files API | 500 MB |
A 413 on the Messages API almost always means the conversation history or an inlined document got too large for a single call, which is a sign to move large reference material to the Files API rather than pasting it into the prompt on every request.
Why a 504 often means “use a different endpoint,” not “retry harder”
A timeout_error on a long-running request is a sign the request itself needs a different shape, not a longer wait. Anthropic’s documentation recommends streaming or the Message Batches API specifically for requests that run over roughly ten minutes, since an idle synchronous connection can simply drop before the response is ready — no error in your code, just a connection that didn’t survive the wait. Enabling TCP keep-alive helps on some networks, but it’s a mitigation for the symptom; switching a long job to streaming or batch processing addresses the actual cause.
A minimal retry handler, annotated
import anthropic
client = anthropic.Anthropic(max_retries=4) # default is 2
try:
message = client.messages.create(
model="claude-sonnet-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello, Claude"}],
)
except anthropic.RateLimitError as e: # 429
print("Rate limited or spend cap reached:", e)
except anthropic.InternalServerError as e: # 5xx
print("Server error; include request ID in support tickets:", e)
except anthropic.APIStatusError as e: # other HTTP errors
print(e.status_code, e)
max_retries=4 exists because the SDK default of two retries is tuned for typical transient blips, not for a sustained overload event — raising it costs nothing on the happy path and buys more resilience on a bad day. The three except blocks are ordered from most specific to least specific on purpose: RateLimitError and InternalServerError are subclasses that Python would still match under the general APIStatusError, so they have to come first or they’d never be reached. Every error object carries the same request_id that appears in the response header, which is the one piece of information Anthropic’s support team actually needs to look up what happened on their end — printing it on every caught exception costs one line and saves a back-and-forth later.
Where this fits with your own retry workflow
If your retries are orchestrated outside your own code, the same status-code distinctions still apply. An n8n workflow for Claude API retries with exponential backoff builds the backoff logic in a visual workflow rather than a try/except block, and should branch on the same codes as above. Zapier’s 30-second timeout limit on Claude API calls is a related but separate problem — a platform-imposed timeout rather than anything in Anthropic’s own error table — and needs its own workaround regardless of how well the error handling above is built. Either way, how usage tiers affect rate limits is worth checking before assuming a 429 is a bug rather than a limit you’ve simply reached.
Five checks before you ship this to production
- Catch SDK exception classes (
RateLimitError,InternalServerError,APIStatusError), not substrings of the error message. - Read the
retry-afterheader on a 429 before waiting a fixed amount of time — and treat a missing header as a sign the limit won’t lift on its own schedule. - Give 500 and 529 errors real exponential backoff instead of a flat retry delay, since both are explicitly the SDK’s “retry with backoff” category.
- Route anything over roughly ten minutes through streaming or the Batches API instead of a long-held synchronous call.
- Log
request_idon every caught exception, before you need it for a support ticket rather than after.
None of this requires memorizing eleven status codes. It requires knowing which handful are worth retrying, reading the header that tells you how long to wait instead of guessing, and catching exception types instead of parsing error text — three habits that come straight out of Anthropic’s own documentation rather than trial and error against a production outage.



