camelAI Documentation

API Reference

camelRun v2 error codes and HTTP status reference

Standard camelRun v2 error envelope, 410 V1_OPERATION_RETIRED, HTTP status codes, domain error codes, and CamelRunError handling.

View as Markdown

Every non-2xx HTTP response from camelRun v2 returns JSON in the same envelope:

json
{
  "error": {
    "code": "invalid_spend_limit",
    "message": "A run with a spend limit must use whileRunning: queue"
  }
}

Branch on error.code and HTTP status, not on the human-readable error.message.

Retired v1 API (410 V1_OPERATION_RETIRED)

The legacy v1 API (/v1/* and /clients/*) was retired on 2026-11-21. Any request to a /v1/* or /clients/* path on run.camelai.com returns HTTP 410 Gone with:

json
{
  "error": "This operation is unavailable on the legacy API. Use CamelRun v2.",
  "code": "V1_OPERATION_RETIRED"
}

To migrate:

  1. Switch all endpoints from /v1/* to /v2/* (and per-agent MCP from /v1/agents/:id/mcp to /v2/agents/:idOrKey/mcp).
  2. Replace v1 API tokens with v2 tenant API keys (cr_live_...) created at run.camelai.com/console.
  3. Follow the full checklist in Migrating from v1 to v2.

Handling errors in @camelai/run

The SDK throws CamelRunError on HTTP failures and (unless throwOnError: false is passed) when agent.run() finishes with status: "failed":

ts
import { CamelRunError } from "@camelai/run";

try {
  const run = await agent.run("Generate the report.", { spendLimitUsd: 0.5 });
  console.log(run.text);
} catch (err) {
  if (err instanceof CamelRunError) {
    console.error("Code:", err.code, "HTTP status:", err.status);
    if (err.run) console.error("Failed run ID:", err.run.id);
  }
  throw err;
}

Common HTTP statuses and error codes

400 Bad Request

CodeCause
invalid_requestMissing or malformed body/query field (for example empty prompt, invalid apiStyle, invalid after cursor, missing path on repo read)
invalid_jsonRequest body is not valid JSON
invalid_spend_limitNegative/non-finite spendLimitUsd, or spendLimitUsd sent with whileRunning: "steer"
invalid_actoractor is empty or exceeds 200 characters
invalid_attachmentsInvalid files entry, attachment missing at its pinned commit, or attachments sent on a steer or without a repo
invalid_approvalMissing boolean approved on an approval input, or non-object answer for an MCP form elicitation
invalid_tool_identitytoolIdentity missing a non-empty subject or passing a non-object context
invalid_tool_auth / invalid_tool_urlUnsupported MCP auth type or non-HTTPS URL on a signed MCP server
invalid_svg / invalid_svg_filesEmpty/malformed SVG, unsupported format, or invalid files map on POST /v2/images/render
missing_provider_key / missing_provider_urlProvider credentials or base URL not configured for the requested model
model_provider_required / unknown_modelBare model ID with no provider prefix, or model not registered for your tenant
model_price_unknownModel has no known platform price; add your own provider key (BYOK) or choose a priced model from GET /v2/models?available=true
model_context_unknownCustom model alias has no declared contextWindow on its provider record (PUT /v2/providers/:provider)
reasoning_requiredExplicit "thinkingLevel": "off" was sent to a model that requires reasoning
invalid_signatureInvalid ElevenLabs webhook signature
realtime_model / realtime_voiceUnknown or invalid realtime voice model or voice ID

401 Unauthorized and 403 Forbidden

StatusCodeCause
401unauthorizedMissing, malformed, revoked, or invalid Bearer token or X-Admin-Key
401missing_signature / invalid_signatureMissing or invalid channel inbound HMAC signature
403forbiddenScoped agent token attempted a tenant-only route, another agent, config/delete mutation, actor run, or signed MCP input response
403input_actor_mismatchInput response actor does not match the actor who started the paused run

402 Payment Required

CodeCause
spend_limit_exceededRun or agent reached its spendLimitUsd cap, or tenant credit balance / monthly cap was exhausted
insufficient_creditsAccount has no remaining balance or BYOK runtime credit (infraCreditUsd) to start a run

404 Not Found and 410 Gone

StatusCodeCause
404not_foundUnknown route, token, definition, channel, or webhook
404agent_not_found / agent_not_initializedUnknown agent ID/key
404repo_not_foundUnknown camelFS repository ID
404run_not_foundUnknown run ID or idempotency key
404input_not_foundUnknown pending input ID
404image_not_found / media_not_foundUnknown image or media ID
404voice_call_not_found / voice_session_not_foundUnknown voice call or session ID
410V1_OPERATION_RETIREDRequest targeted a retired v1 endpoint (/v1/* or /clients/*). Switch to /v2/*; see Migrating from v1 to v2
410input_expiredPending input passed its expiresAt deadline
410vm_lostUnderlying workspace container was lost mid-exec without an execution receipt (a new container boots from the last committed workspace)

409 Conflict

CodeCause
conflictResource key already exists (for example fork with an existing key)
agent_busyPATCH /model or PATCH /spend-limit called while runs are queued, running, or input_required
model_changed / spend_limit_changedCompare-and-swap mismatch on expectedModel or expectedSpendLimitUsd
agent_deletingAgent deletion is already in progress
input_already_resolvedInput was already answered, denied, or expired
ref_leased / cas_conflictcamelFS write conflicted with another holder's active lease or expectedCommit
duplicate_requestDuplicate idempotency claim

413 Payload Too Large, 422 Unprocessable Entity, 429, and 5xx

StatusCodeCause
413attachment_count / attachment_sizeMore than 20 files or image exceeds request/resize limits
413repo_too_many_files / repo_too_largeGET /v2/repos/:repoId/read-all exceeds 1,000 files or 16 MiB
413render_too_largeSVG render request exceeds byte or image budgets
413payload_too_large / history_chunk_too_largeRequest body or history chunk exceeds limit
422output_schema_invalidFinal response failed JSON parsing or outputSchema validation
422attachment_invalidAttachment bytes do not match declared image MIME type
422workflow_failedWorkflow script threw an error or exceeded sandbox limits
429rate_limitedTenant token-bucket rate limit (rateLimitRpm) or concurrency limit exceeded
499cancelledRun was aborted via POST /v2/agents/:idOrKey/abort
502 / 503model_error, model_cost_unresolved, svg_render_failed, svg_renderer_unavailable, moderation_upstream_error, tool_identity_unavailable, missing_provider_keyUpstream provider error, unresolved variable-price settlement, or unconfigured Worker binding/secret