Skip to content
中文

Limits and errors

Use this page to investigate agent configuration and session API failures. See Embed limits and errors for tokens, origins, anonymous quotas, and components. Organization balance and quotas belong to Usage and billing.

Request and execution limits

ItemValueUnit and meaning
Agent name1–256characters
Instructions system100,000maximum characters
Agent / session metadata16 / 64 / 512pairs / key characters / value characters
Session title500maximum characters
Initial initial_events50maximum events
List limit (agents, versions, sessions, events, skills, skill versions, environments, customers)1–100; 20integer range, anything else is a 400; default items
Session budget"20.00"default USD 20
Session time_zoneUTCdefault; accepts IANA names
Custom tools32 / 16 KiBmaximum count / UTF-8 JSON bytes per input_schema

A budget uses type: "limit", max_list_cost.currency: "USD", and max_list_cost.amount in US dollars: send a positive integer or up to 2 decimals (for example "0.50"); responses carry exactly 2 decimals (for example "20.00"), and more decimals return 400. null removes the ceiling. The budget controls subsequent model requests; it is not a cost forecast. A session’s usage.list_cost.amount is its model cost, threads included, in US dollars with exactly 6 decimals (for example "0.000345"). usage.runtime_cost is the separately billed runtime in the same format and does not count against the budget. String limits use JavaScript string length, so not every character occupies one unit. Tool schema size is measured in UTF-8 bytes.

Handle errors by code

Every error on /agent/v1 and on the Managed Agents routes of /anthropic/v1 has one body, including authentication and rate-limit refusals:

{
"type": "error",
"error": {
"type": "not_found_error",
"message": "Session not found",
"code": "SESSION_NOT_FOUND",
"retryable": false
},
"request_id": "4bf92f3577b34da6a3ce929d0e0e4736"
}

error.type follows the Anthropic vocabulary (invalid_request_error, authentication_error, permission_error, not_found_error, rate_limit_error, api_error, overloaded_error; billing_error, request_too_large and not_implemented_error where they apply). Branch on error.code; error.retryable says whether the same request can succeed later. request_id equals the X-Request-Id and request-id response headers. A malformed id answers the same not-found code as a well-formed unknown one: HTTP 404 not_found_error (for example SESSION_NOT_FOUND or AGENT_NOT_FOUND), the same on both interfaces. This is deliberate and differs from Anthropic’s Compliance API, which answers 400 invalid_request_error for a malformed session ID; as a result, a caller cannot tell from the response whether the id exists. Note also that on /agent/v1 a session segment that does not start with sesn_ is read as a session name rather than a malformed id (it answers 400 when agent_id is missing; see Get Session). A path that is not an endpoint answers NOT_FOUND with Endpoint not found; an undeclared method on an endpoint, and a resource without a code of its own (a deployment, for example), answer NOT_FOUND as well.

INVALID_PARAMS

HTTP 400. A request field, format or option is invalid; the message names the field and the rule, for example limit must be an integer between 1 and 100, rating must be positive or negative, Unknown field: foo or Invalid JSON body. Correct the request; unchanged retries will not help.

INVALID_PAGE_TOKEN

HTTP 400. page is not a valid cursor for this list; restart from the first page. Restart at the first page, then pass next_page unchanged with the same filters.

MODEL_NOT_ALLOWED

HTTP 400. The model is not allowed by the pinned version. Select an allowed model or update the configuration and create a new session.

UNAUTHENTICATED

HTTP 401. Credentials are missing or invalid. The key layer names the case: AUTHENTICATION_ERROR (no credential), INVALID_API_KEY, API_KEY_DISABLED, API_KEY_EXPIRED, INVALID_API_TOKEN, API_TOKEN_EXPIRED or API_TOKEN_REVOKED. Check the Key for this environment and organization, then authenticate again.

SESSION_FORBIDDEN

HTTP 403. The caller cannot access this session (PERMISSION_DENIED for other refused actions). Check its user and organization. Do not retry automatically or probe other users by changing IDs.

Not found codes

HTTP 404. Each resource has its own code; use the id from creation or listing and the caller that owns it.

CodeMissing resource
AGENT_NOT_FOUNDAgent
AGENT_VERSION_NOT_FOUNDAgent version
SESSION_NOT_FOUNDSession
THREAD_NOT_FOUNDSession thread
SKILL_NOT_FOUNDSkill
SKILL_VERSION_NOT_FOUNDSkill version
ENVIRONMENT_NOT_FOUNDEnvironment
EMBED_TOKEN_NOT_FOUNDCustomer access token (an end-user token cannot issue grant codes)
CUSTOMER_NOT_FOUNDCustomer (end user)
NOT_FOUNDAny other resource, or a path that is not an endpoint

AGENT_VERSION_CONFLICT

HTTP 409. The version sent with an agent update is not the agent’s latest (older or not yet existing). error.current_version carries the latest; retrieve the agent and retry with that version.

AGENT_ARCHIVED

HTTP 409. The agent is archived, so it cannot be updated or start sessions. Unarchive it first.

SKILL_LAST_VERSION

HTTP 409. A skill keeps at least one version, so its last version cannot be deleted. Delete the whole skill instead; its versions go with it.

RESOURCE_IN_USE

HTTP 409. A skill or environment is still named by an agent’s active or latest version. Remove it from those agents first.

SESSION_CONFLICT

HTTP 409. The session state conflicts with the operation (a tool result already submitted, a message no longer queued). Read the session or pending tool before submitting again.

SESSION_ARCHIVED

HTTP 409. The session is archived and cannot accept messages. Retain its history for inspection and create a new session for another conversation.

INVALID_STATE

HTTP 409. Another resource’s state does not permit this operation, such as deleting a running session or editing a built-in environment. Change the state first, then check it again.

RATE_LIMITED

HTTP 429, retryable: true. Wait for Retry-After before the next request.

UPSTREAM_UNAVAILABLE

HTTP 502. An upstream is temporarily unavailable. Retry after backing off; check existing results first when creating resources or sending messages.

SANDBOX_UNAVAILABLE

HTTP 503. The execution environment is temporarily unavailable. Retry after backing off. Record the request identifier and contact support if failures persist.

When to retry

Resolve the cause first when error.retryable is false. For HTTP 429, read Retry-After and avoid tight retry loops. Temporary upstream or environment failures can be retried after backing off. A broken network connection does not prove the request was never executed. Check known sessions and events before repeating creation or message requests.

After an event stream starts, execution failures can arrive as events. A successful connection status does not establish task success. Inspect replies, pending tool confirmations, and session status; accepting a message is separate from completing its task.

Capture diagnostic information

Record the time, environment, agent and session IDs, HTTP status, error type and code, and request_id (the same value as the X-Request-Id and request-id headers). Keep Keys, grant codes, customer access tokens, and visitor credentials out of diagnostic records.

Inspect sessions and usage, then compare your request with the API reference. To narrow a reproduction, start from the minimal request in the quickstart.