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.
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:
- Switch all endpoints from
/v1/*to/v2/*(and per-agent MCP from/v1/agents/:id/mcpto/v2/agents/:idOrKey/mcp). - Replace v1 API tokens with v2 tenant API keys (
cr_live_...) created at run.camelai.com/console. - 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
| Code | Cause |
|---|---|
invalid_request | Missing or malformed body/query field (for example empty prompt, invalid apiStyle, invalid after cursor, missing path on repo read) |
invalid_json | Request body is not valid JSON |
invalid_spend_limit | Negative/non-finite spendLimitUsd, or spendLimitUsd sent with whileRunning: "steer" |
invalid_actor | actor is empty or exceeds 200 characters |
invalid_attachments | Invalid files entry, attachment missing at its pinned commit, or attachments sent on a steer or without a repo |
invalid_approval | Missing boolean approved on an approval input, or non-object answer for an MCP form elicitation |
invalid_tool_identity | toolIdentity missing a non-empty subject or passing a non-object context |
invalid_tool_auth / invalid_tool_url | Unsupported MCP auth type or non-HTTPS URL on a signed MCP server |
invalid_svg / invalid_svg_files | Empty/malformed SVG, unsupported format, or invalid files map on POST /v2/images/render |
missing_provider_key / missing_provider_url | Provider credentials or base URL not configured for the requested model |
model_provider_required / unknown_model | Bare model ID with no provider prefix, or model not registered for your tenant |
model_price_unknown | Model has no known platform price; add your own provider key (BYOK) or choose a priced model from GET /v2/models?available=true |
model_context_unknown | Custom model alias has no declared contextWindow on its provider record (PUT /v2/providers/:provider) |
reasoning_required | Explicit "thinkingLevel": "off" was sent to a model that requires reasoning |
invalid_signature | Invalid ElevenLabs webhook signature |
realtime_model / realtime_voice | Unknown or invalid realtime voice model or voice ID |
401 Unauthorized and 403 Forbidden
| Status | Code | Cause |
|---|---|---|
401 | unauthorized | Missing, malformed, revoked, or invalid Bearer token or X-Admin-Key |
401 | missing_signature / invalid_signature | Missing or invalid channel inbound HMAC signature |
403 | forbidden | Scoped agent token attempted a tenant-only route, another agent, config/delete mutation, actor run, or signed MCP input response |
403 | input_actor_mismatch | Input response actor does not match the actor who started the paused run |
402 Payment Required
| Code | Cause |
|---|---|
spend_limit_exceeded | Run or agent reached its spendLimitUsd cap, or tenant credit balance / monthly cap was exhausted |
insufficient_credits | Account has no remaining balance or BYOK runtime credit (infraCreditUsd) to start a run |
404 Not Found and 410 Gone
| Status | Code | Cause |
|---|---|---|
404 | not_found | Unknown route, token, definition, channel, or webhook |
404 | agent_not_found / agent_not_initialized | Unknown agent ID/key |
404 | repo_not_found | Unknown camelFS repository ID |
404 | run_not_found | Unknown run ID or idempotency key |
404 | input_not_found | Unknown pending input ID |
404 | image_not_found / media_not_found | Unknown image or media ID |
404 | voice_call_not_found / voice_session_not_found | Unknown voice call or session ID |
410 | V1_OPERATION_RETIRED | Request targeted a retired v1 endpoint (/v1/* or /clients/*). Switch to /v2/*; see Migrating from v1 to v2 |
410 | input_expired | Pending input passed its expiresAt deadline |
410 | vm_lost | Underlying workspace container was lost mid-exec without an execution receipt (a new container boots from the last committed workspace) |
409 Conflict
| Code | Cause |
|---|---|
conflict | Resource key already exists (for example fork with an existing key) |
agent_busy | PATCH /model or PATCH /spend-limit called while runs are queued, running, or input_required |
model_changed / spend_limit_changed | Compare-and-swap mismatch on expectedModel or expectedSpendLimitUsd |
agent_deleting | Agent deletion is already in progress |
input_already_resolved | Input was already answered, denied, or expired |
ref_leased / cas_conflict | camelFS write conflicted with another holder's active lease or expectedCommit |
duplicate_request | Duplicate idempotency claim |
413 Payload Too Large, 422 Unprocessable Entity, 429, and 5xx
| Status | Code | Cause |
|---|---|---|
413 | attachment_count / attachment_size | More than 20 files or image exceeds request/resize limits |
413 | repo_too_many_files / repo_too_large | GET /v2/repos/:repoId/read-all exceeds 1,000 files or 16 MiB |
413 | render_too_large | SVG render request exceeds byte or image budgets |
413 | payload_too_large / history_chunk_too_large | Request body or history chunk exceeds limit |
422 | output_schema_invalid | Final response failed JSON parsing or outputSchema validation |
422 | attachment_invalid | Attachment bytes do not match declared image MIME type |
422 | workflow_failed | Workflow script threw an error or exceeded sandbox limits |
429 | rate_limited | Tenant token-bucket rate limit (rateLimitRpm) or concurrency limit exceeded |
499 | cancelled | Run was aborted via POST /v2/agents/:idOrKey/abort |
502 / 503 | model_error, model_cost_unresolved, svg_render_failed, svg_renderer_unavailable, moderation_upstream_error, tool_identity_unavailable, missing_provider_key | Upstream provider error, unresolved variable-price settlement, or unconfigured Worker binding/secret |