claude api 400 bad request error
Resolve the Claude API 400 Bad Request error by validating headers, model identifiers, JSON payload structure, and correct alternating roles.
Updated 8/19/2026Powered by Tickd.ai
A 400 Bad Request error from the Claude API indicates that the server cannot process your request because it is malformed. This is typically caused by client-side validation errors, unsupported API parameters, or incorrect syntax. Follow these steps to debug and correct your request payload.
Validate your JSON request payload
The most common culprit behind a 400 error is invalid JSON. Ensure that your request payload does not contain trailing commas, unescaped control characters, or unclosed quotation marks. If you are building payloads dynamically, use standard JSON serialisation libraries rather than manual string formatting to guarantee valid payloads.
Check for the anthropic-version header
All direct requests to the Anthropic API require a specific API version header. Ensure that you have included anthropic-version: 2023-06-01 (or the latest supported version) in your request headers. If you are using the official SDKs, this header is appended automatically; however, if you are calling the REST endpoints directly via curl or custom HTTP clients, missing this header will trigger a 400 error.
Correct the messages array structure
The Messages API enforces a strict alternating structure for multi-turn conversations. Your payload must begin with a message from the user role and alternate strictly between user and assistant. Sending consecutive messages with the same role, starting with an assistant message, or sending empty string values within content blocks will immediately result in a 400 validation error.
Confirm correct model identifiers
Specifying an invalid or deprecated model string in your payload will cause the server to reject the request. Ensure you are using exact identifiers such as claude-3-5-sonnet-20241022 or claude-3-opus-20240229. Do not use shorthand names, and verify that the specified model is active and available to your API account tier.
Rule out gateway or platform outages
On rare occasions, a 400 Bad Request error can be returned by edge load balancers when Anthropic's gateway servers are undergoing severe stress or configuration updates. If your code was working perfectly and suddenly began failing with 400 errors without any changes on your side, consult our guide on the Anthropic API 529 Overloaded Error to check for current platform-wide outages.