Docs

Errors

Every error the platform returns follows the same envelope and the same handful of HTTP status codes. This page is the canonical reference: the envelope shape, the status-to-code mapping, and a recovery matrix you can implement against.

For rate-limit specifics see Rate limits. For pagination-specific error cases see Pagination and errors.

Canonical error envelope

All errors use this exact shape:

json
{
  "error": {
    "code": "invalid_input",
    "message": "Field 'task' is required.",
    "details": {
      "field": "task",
      "expected": "string"
    }
  }
}

Three fields:

  • code: stable machine-readable identifier. Safe to branch on.
  • message: human-readable description. Safe to log. Do not pattern-match against it programmatically; copy may change.
  • details: optional JSON object with structured context. Shape depends on the code. Present when the server has something useful to attach (offending field, rate limit window, violated constraint).

The envelope is consistent across REST and MCP surfaces. MCP tool error responses wrap the same object as the result of the tool call so you can branch on code identically.

HTTP status code mapping

HTTP statusCommon codesWhen it fires
400invalid_input, invalid_argument, validation_errorThe request body, query string, or tool input failed validation. Fix the payload and retry.
401unauthenticated, invalid_token, expired_tokenNo credentials were presented, or the bearer token could not be parsed. Re-auth.
403forbidden, scope_denied, insufficient_roleThe caller is authenticated but lacks the required scope, role, or tenant membership. Grant the scope or upgrade the role.
404not_foundThe resource does not exist, or it exists but belongs to another tenant. See "Security-sensitive errors" below.
409conflict, duplicate, version_conflictThe write would violate a uniqueness constraint or clobber a newer version of the resource. Read, merge, retry.
429rate_limitedRate limit exceeded. Back off and retry; see Rate limits.
500internal, server_errorUnexpected server-side failure. Retry with backoff; file an issue if persistent.
503service_unavailable, dependency_unavailableAn upstream dependency (database, Anthropic API, worker queue) is temporarily down. Retry with backoff.

Status codes are the primary signal for your client-side dispatcher; code is the secondary signal for precise handling.

Per-tool error codes

Some tools define richer codes on top of the standard set. They still use the canonical envelope; only the code value is more specific.

agents.start

CodeStatusMeaning
profile_not_found400profile_id is not in the registered profile catalogue. Call agents.profiles_list to see valid ids.
invalid_input400Missing or malformed task or input_params. Details carry the field name.
enqueue_failed500The session row was created but the worker queue did not accept the job. Retry by calling agents.start again; the partially-created session can be inspected via agents.status.

agents.resume

CodeStatusMeaning
invalid_input400Resume payload did not match pending_input_schema. details.validation_error has the mismatch.
invalid_state409Session is not in awaiting_input. details.current_status shows where it actually is.
not_found404Session id unknown, or belongs to another tenant.

artifacts.update

CodeStatusMeaning
version_conflict409The expected_version supplied does not match the current version. Read the artifact, merge, retry with the new version number.
locked409Artifact is locked for editing by another caller. Retry after the lock expires.

context_substrate.*

CodeStatusMeaning
substrate_not_found404Substrate id unknown or pre-expiration.
query_too_broad400Query exceeded internal cost ceiling. Narrow the filter or reduce max_tokens.

Check each tool's reference page under API reference: tools for the authoritative list of codes it emits.

Security-sensitive errors

Two behaviors are worth calling out because they can look like bugs:

  1. 404 instead of 403 for cross-tenant access. If you request an artifact, session, or webhook that exists but belongs to another business, the platform returns 404 not_found rather than 403 forbidden. This prevents probing, so a caller cannot distinguish "does not exist" from "exists but not yours". If you are confident the id is yours and you get a 404, check that your API key is bound to the correct business, not that the resource was deleted.
  2. Masked secrets in error details. When a validation error touches a field that the platform classifies as sensitive (tokens, API keys, refresh credentials), details will show [MASKED] in place of the offending value along with a <field>_masked: true sentinel. The error message is still useful; the value is just never echoed back.

Recovery matrix

The client behavior that is right for each code class:

Code classRetry?Action
invalid_input, invalid_argument, validation_errorNoFix the payload. The details field names the offending field. Do not retry the same request.
unauthenticated, invalid_token, expired_tokenYes, after re-authRun the auth flow to obtain a fresh credential, then retry. See Authentication.
forbidden, scope_denied, insufficient_roleNoThe token is valid but lacks authority. Do not retry; surface to a human to grant the scope or role.
not_foundNo (usually)Validate the id. For cross-tenant 404s, verify the API key is bound to the correct business.
conflict, duplicate, version_conflictYes, after mergeRead the current state, reconcile, resubmit with the updated version number or dedupe key.
rate_limitedYes, with backoffHonor Retry-After or details.retry_after_seconds. Exponential backoff with jitter, capped at 60s. See Rate limits.
internal, server_errorYes, with backoffRetry up to 3 times with backoff. If the correlation id repeats, file an issue.
service_unavailable, dependency_unavailableYes, with backoffSame as internal. These indicate transient upstream problems.

Correlation id

Every response carries an X-Correlation-Id header. When you surface errors to a user or log them for ops, capture the correlation id. On our side it joins the request to the audit log and any upstream traces. Support requests that include the correlation id resolve significantly faster.

See also