API Reference
camelRun v2 REST and WebSocket API reference
Complete reference for every camelRun v2 HTTP and WebSocket endpoint under /v2/*: tenants, providers, definitions, CamelFS repos, agents, runs, voice, channels, media, and webhooks.
Base URL: https://run.camelai.com (all API routes live under /v2/*).
All JSON responses use application/json. Errors use the standard envelope:
json
{ "error": { "code": "...", "message": "..." } }Health and discovery
| Method and path | Auth | Description |
|---|---|---|
GET /healthz | None | Worker health check ({ ok: true, service: "camelrun-worker-v2" }) |
GET /v2 | None | v2 root health check ({ ok: true, service: "camelrun-worker-v2" }) |
GET /v2/health | None | v2 health check ({ ok: true, service: "camelrun-worker-v2" }) |
GET /v2/.well-known/jwks.json | None | Public Ed25519 JWKS for verifying runtime MCP tool JWTs (Cache-Control: public, max-age=60) |
Tenants, tokens, providers, models, and billing
| Method and path | Auth | Description |
|---|---|---|
POST /v2/tenants | Admin (X-Admin-Key) | Provision a tenant ({ name, initialCreditsUsd?, tier?, monthlyCapUsd?, concurrencyLimit?, rateLimitRpm? }) -> 201 { tenantId, name, apiKey, balanceUsd } |
GET /v2/me | Tenant | Tenant profile, balance, tier, and busyAgents: { active, limit } |
POST /v2/tokens | Tenant | Create API key ({ name?, scopes? }) -> 201 { id, name, token, prefix, scopes, createdAt } |
GET /v2/tokens | Tenant | List API keys ({ tokens }) |
DELETE /v2/tokens/:id | Tenant | Revoke API key ({ deleted: true }) |
PUT /v2/providers/:provider | Tenant | Seal provider credentials ({ apiKey?, baseUrl?, modelAliases?, headers?, apiStyle? }) |
GET /v2/providers | Tenant | List configured providers (metadata only, no secrets) |
DELETE /v2/providers/:provider | Tenant | Remove a provider credential |
PUT /v2/key-scopes/:scope/providers/:provider | Tenant | Seal provider credentials inside a named key scope (1..100 chars) |
GET /v2/key-scopes/:scope/providers | Tenant | List providers in a key scope ({ scope, providers }) |
DELETE /v2/key-scopes/:scope/providers/:provider | Tenant | Delete one provider from a key scope |
DELETE /v2/key-scopes/:scope | Tenant | Delete an entire key scope |
GET /v2/models | Tenant | List catalog and alias models (?provider=&available=true&keyScope=) |
GET /v2/usage | Tenant | Daily usage rows (?days=30, clamped 1..365) -> { days: [...] } |
GET /v2/billing | Tenant | { balanceUsd, monthlyCapUsd, busyAgents, usage } |
POST /v2/billing/credits | Admin (X-Admin-Key) | Idempotently grant credits ({ tenantId?, amountUsd, refId, note? }) |
Definitions
| Method and path | Auth | Description |
|---|---|---|
PUT /v2/definitions/:slug | Tenant | Create or update a reusable agent definition |
GET /v2/definitions | Tenant | List all definitions ({ definitions }) |
GET /v2/definitions/:slug | Tenant | Get a single definition (404 if missing) |
DELETE /v2/definitions/:slug | Tenant | Delete a definition ({ deleted: true }) |
CamelFS repositories (/v2/repos)
| Method and path | Auth | Description |
|---|---|---|
POST /v2/repos | Tenant | Create repo ({ name? }) -> 201 { repoId, name, lineage, defaultRef, commit, ... } |
GET /v2/repos | Tenant | List tenant repos ({ repos }) |
GET /v2/repos/:repoId | Tenant | Get repo metadata and refs |
DELETE /v2/repos/:repoId | Tenant | Stop active VMs and delete repo |
GET /v2/repos/:repoId/files | Tenant | Read one file (?path=<required>&at=&offset=&limit=) |
GET /v2/repos/:repoId/read-all | Tenant | Read all files under optional ?path= at ?at= (max 1,000 files / 16 MiB) -> { commit, files } |
POST /v2/repos/:repoId/write | Tenant | Atomic write ({ ref?, expectedCommit?, holder?, author?, message?, puts?, deletes?, moves? }) -> { commit, tree, changed, totalBytes } |
GET /v2/repos/:repoId/ls | Tenant | List entries (?at=&path=&recursive=1|0&glob=) -> { commit, entries } |
POST /v2/repos/:repoId/grep | Tenant | Regex search ({ pattern, at?, pathPrefix?, maxMatches? }) -> { commit, matches } |
GET /v2/repos/:repoId/history | Tenant | Commit log (?ref=&limit=20) -> { commits } |
POST /v2/repos/:repoId/fork | Tenant | Fork repo ({ name?, sourceRef?, atCommit? }) -> 201 new repo |
POST /v2/repos/:repoId/restore | Tenant | Restore branch ({ targetCommit, ref?, message? }) -> { commit, tree } |
Durable keyed agents (/v2/agents)
:idOrKey accepts either the agent's key or its ID (agt_...).
| Method and path | Auth | Description |
|---|---|---|
PUT /v2/agents/:key | Tenant | Upsert agent config (201 created, 200 updated). Optional prompt starts an initial run in the same request. Returns { id, key, agentToken, repoId, branch, model, created, run? }. |
GET /v2/agents | Tenant | List tenant agents ({ agents }) |
GET /v2/agents/:idOrKey | Tenant or Agent | Full AgentConfig plus status, activeRunId, messageCount, lastRun |
PATCH /v2/agents/:idOrKey/model | Tenant | Compare-and-swap idle model update ({ model, expectedModel, keyScope? }) |
PATCH /v2/agents/:idOrKey/spend-limit | Tenant | Compare-and-swap idle spend limit update ({ spendLimitUsd, expectedSpendLimitUsd }) |
PUT /v2/agents/:idOrKey/repo | Tenant | Ensure a repository is provisioned for the agent |
DELETE /v2/agents/:idOrKey | Tenant | Destroy agent Durable Object and index entry ({ deleted: true }) |
POST /v2/agents/:idOrKey/runs | Tenant or Agent | Start a run ({ prompt, actor?, keyScope?, files?, idempotencyKey?, whileRunning?, wait?, outputSchema?, maxSteps?, spendLimitUsd? }). Note: actor requires Tenant auth; spendLimitUsd requires whileRunning: "queue". |
GET /v2/agents/:idOrKey/runs | Tenant or Agent | { cursor, activeRunId, runs } |
GET /v2/agents/:idOrKey/runs/:runId | Tenant or Agent | Get a RunRecord (add ?by=idempotency-key to look up by idempotencyKey) |
POST /v2/agents/:idOrKey/abort | Tenant or Agent | Abort active run and optionally keep queued runs ({ keepQueued?: boolean }) -> { aborted: true, cancelledRunIds } |
GET /v2/agents/:idOrKey/events | Tenant or Agent (or ?token=) | SSE stream when Accept: text/event-stream (?after=0&runId=&follow=1, supports Last-Event-ID), or JSON page (?after=0|latest&runId=) |
GET /v2/agents/:idOrKey/ws | Tenant or Agent (or ?token=) | Hibernatable WebSocket for live events and bidirectional local tool calls (register_tools, tool_call, tool_result, ping/pong) |
GET /v2/agents/:idOrKey/history | Tenant or Agent | Conversation history (?after=0&limit=50 or ?before=latest|<seq>&limit=50) -> { messages, compaction, nextAfter, nextBefore? } |
GET /v2/agents/:idOrKey/history/import | Tenant | Read v1 history import proof (Cache-Control: no-store) |
PUT /v2/agents/:idOrKey/history/import | Tenant | Import v1 conversation history into a fresh agent |
PUT /v2/agents/:idOrKey/history/import/chunk | Tenant | Append a chunked v1 history import (max 1 MiB per chunk) |
POST /v2/agents/:idOrKey/compact | Tenant or Agent | Compact history ({ summary?, keepLast? }) -> { summary, upToSeq, compactedCount } |
POST /v2/agents/:idOrKey/reset-context | Tenant or Agent | Reset active context ({ summary?, keepLast? }) -> { ok: true, upToSeq, summary } |
POST /v2/agents/:idOrKey/fork | Tenant | Fork agent and CamelFS repo ({ key?, atSeq? }) |
GET /v2/agents/:idOrKey/inputs | Tenant or Agent | List runs with pending inputs ({ runs }) |
POST /v2/agents/:idOrKey/inputs/:inputId | Tenant or Agent | Respond to a pending input ({ approved?, answer?, wait?, actor? }). Signed MCP inputs and actor-bound runs require Tenant auth. |
POST /v2/agents/:idOrKey/schedules | Tenant | Create schedule ({ prompt, intervalSeconds?, cronExpr? | cron? }) -> 201 |
GET /v2/agents/:idOrKey/schedules | Tenant or Agent | List schedules ({ schedules }) |
DELETE /v2/agents/:idOrKey/schedules/:scheduleId | Tenant | Delete schedule ({ deleted: true }) |
POST /v2/agents/:idOrKey/workflows | Tenant or Agent | Execute replay workflow ({ code, idempotencyKey?, wait? }) -> 200 (completed) or 422 (failed) |
POST /v2/agents/:idOrKey/dream | Tenant or Agent | Run memory consolidation to /workspace/MEMORY.md |
PUT /v2/agents/:key request body
json
{
"model": "azure/gpt-6.2-sol",
"keyScope": null,
"instructions": "Be concise.",
"definition": "optional-slug",
"tools": [
{
"name": "lookupOrder",
"description": "Look up an order",
"parameters": { "type": "object", "properties": { "orderId": { "type": "string" } }, "required": ["orderId"] },
"url": "https://app.example.com/tools/lookup-order",
"headers": { "X-Secret": "..." },
"requiresApproval": false
}
],
"mcpServers": [
{
"name": "app",
"url": "https://app.example.com/mcp",
"auth": { "type": "runtime" },
"audience": "https://app.example.com/mcp",
"allowTools": ["read_project"]
}
],
"toolIdentity": { "subject": "user_42", "context": { "orgId": "org_1" } },
"builtins": ["files", "images", "bash", "codemode", "delegate", "workflows", "web_search", "web_fetch", "human"],
"queue": { "mode": "each", "windowMs": 0 },
"repoId": "repo_...",
"branch": "refs/heads/main",
"spendLimitUsd": 10,
"idleTtlSeconds": 86400,
"dreaming": { "enabled": false, "idleSeconds": 3600 }
}Stateless runs and decisions
| Method and path | Auth | Description |
|---|---|---|
POST /v2/runs | Tenant | One-shot stateless run ({ input, model?, instructions?, outputSchema?, tools?, maxSteps? }) |
POST /v2/decisions | Tenant | Calibrated classification ({ input, choices, instructions?, model? }) -> { choice, confidence, scores, costUsd } |
Voice calls and sessions
| Method and path | Auth | Description |
|---|---|---|
POST /v2/voice/calls | Tenant or Agent | Start a managed OpenAI or ElevenLabs voice call -> 201 with connect |
GET /v2/voice/calls | Tenant | List calls (?state=live|ended&limit=50) -> { calls, next } |
GET /v2/voice/calls/:id | Tenant or Agent | Get call details |
PATCH /v2/voice/calls/:id | Tenant or Agent | Update speakers or metadata |
POST /v2/voice/calls/:id/transcript | Tenant or Agent | Record a transcript utterance (202) |
POST /v2/voice/calls/:id/end | Tenant or Agent | End a call ({ reason? }) |
DELETE /v2/voice/calls/:id | Tenant or Agent | End a call |
POST /v2/voice/providers/elevenlabs/post-call | ElevenLabs HMAC | ElevenLabs post-call callback |
POST /v2/voice/providers/elevenlabs/tools/:tool | Tool secret | ElevenLabs tool bridge (ask_agent or stay_silent) |
POST /v2/voice/sessions | Tenant or Agent | Create an agent realtime voice session ({ agentIdOrKey, provider?, voice?, instructions? }) |
GET /v2/voice/sessions/:id | Tenant or Agent | Get voice session info |
POST /v2/voice/sessions/:id/tool | Tenant or Agent | Execute an agent tool from a voice session ({ name, args?, callId? }) |
GET /v2/voice/sessions/:id/ws | Tenant or Agent (or ?token=) | WebSocket bridge for voice session tool execution |
Channels, media, and webhooks
| Method and path | Auth | Description |
|---|---|---|
POST /v2/channels | Tenant | Create a slack, email, or http channel (201) |
GET /v2/channels | Tenant | List channels ({ channels }) |
DELETE /v2/channels/:id | Tenant | Delete channel ({ deleted: true }) |
POST /v2/channels/:id/inbound | Tenant or Channel HMAC | Deliver inbound message to thread-keyed agent |
POST /v2/transcriptions | Tenant | Speech-to-text (multipart file or JSON audioBase64) |
POST /v2/speech | Tenant | Text-to-speech ({ input, voice?, model?, format? }) -> audio bytes + X-Media-Id |
GET /v2/voices/search | Tenant | Search voices (?provider=elevenlabs|openai|grok|gemini&q=&category=&limit=10) |
POST /v2/images | Tenant | Generate image ({ prompt, model?, size? }) -> { id, url, contentType, sizeBytes, costUsd } |
POST /v2/images/render | Tenant | Render SVG to PNG ({ svg, files?, format?: "png" }) -> { contentType, width, height, data } |
GET /v2/images/:id | Optional Tenant | Fetch stored image bytes |
POST /v2/moderations/images | Tenant | Moderate raw image/jpeg or image/png (up to 5 MiB) |
POST /v2/webhooks | Tenant | Register webhook endpoint ({ url, events?, secret? }) -> 201 |
GET /v2/webhooks | Tenant | List webhooks ({ webhooks }) |
DELETE /v2/webhooks/:id | Tenant | Delete webhook ({ deleted: true }) |