---
title: 'Migrating from camelRun v1 to v2'
sidebarTitle: 'Migrating from v1 to v2'
description: 'Summary of breaking changes from camelRun v1 to v2: /v2 endpoints, CamelFS git-backed repos replacing volumes, SDK changes, spendLimitUsd, and history import.'
---
[View as Markdown](https://camelai.com/docs/camelrun/v1-to-v2.md)

camelRun v2 is a clean-sheet replacement for v1 built on Cloudflare Workers, SQLite Durable Objects, and the Go `camelfsd` service. This guide maps every major change so you can update your integration cleanly.

## Summary of changes

| Area                                                             | camelRun v1                                                                                   | camelRun v2                                                                                                                                                                                       |
| ---------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **API prefix**                                                   | `/v1/*`                                                                                       | `/v2/*`                                                                                                                                                                                           |
| **Tenant API keys**                                              | `art_...`                                                                                     | `cr_live_<tenantId>.<id>_<secret>`                                                                                                                                                                |
| **Agent tokens**                                                 | `client_...` / agent token                                                                    | `agt_tok_<tenantId>.<agentId>.<secret>` (agent IDs are `agt_...`)                                                                                                                                 |
| **Agent upsert**                                                 | `POST /v1/agents` with `Idempotency-Key` header                                               | `PUT /v2/agents/:key` (optional `prompt` starts a first run in the same call)                                                                                                                     |
| **Sending prompts**                                              | `POST /v1/agents/:id/prompt` (`202` + poll `/requests/:req`)                                  | `POST /v2/agents/:idOrKey/runs` (`wait: true` by default, or `wait: false` + poll `/runs/:runId` or SSE `/events`)                                                                                |
| **Streaming**                                                    | `GET /v1/agents/:id/events` + browser tokens                                                  | `GET /v2/agents/:idOrKey/events?after=...&follow=1` (`Accept: text/event-stream`) or `GET /v2/agents/:idOrKey/ws`                                                                                 |
| **Files and storage**                                            | Mutable volumes (`/v1/volumes`), snapshots, and multi-path `mounts` (`/v1/agents/:id/mounts`) | **CamelFS** Git-backed repositories (`/v2/repos`). Each agent binds one `(repoId, branch)` mounted at `/workspace` with atomic commits                                                            |
| **Attachments**                                                  | Upload to `/v1/agents/:id/uploads/...` or inline base64                                       | Write to the agent's repo (`POST /v2/repos/:repoId/write`), then pass `files: [{ path, commit, contentType }]` on `POST /v2/agents/:idOrKey/runs`                                                 |
| **Compute / bash**                                               | External computer providers (`/v1/computers`)                                                 | Built-in Firecracker session VMs (`builtins: ["bash"]`) over `/workspace` with atomic Git commits                                                                                                 |
| **End-user billing**                                             | Built-in end-user wallets (`/v1/end-users/*`)                                                 | Removed from runtime. Track user credits in your app, pass per-run `spendLimitUsd` (with `whileRunning: "queue"`) and `actor`, and reconcile via `run.usage.costUsd` or `usage.recorded` webhooks |
| **TypeScript SDK**                                               | `new Agents()`, `tool()`, `schema.*`                                                          | `new CamelRun({ baseUrl, apiKey })`, `defineTool()`, `client.agents.upsert()`, `client.repos.*`                                                                                                   |
| **Definitions**                                                  | `def_...` revisions with `apply: "all"`                                                       | Slug-keyed `PUT /v2/definitions/:slug`                                                                                                                                                            |
| **Built-in suites**                                              | `ask_user`, `js_exec`, `schedule`, `generate_image`                                           | `files`, `images` (`render_image`), `bash`, `codemode`, `delegate`, `workflows`, `web_search`, `web_fetch`, `human` (`ask_human`)                                                                 |
| **Workspaces / CLI / per-agent MCP server / account zip export** | `/v1/workspaces`, `@camelai/camelrun`, `/v1/agents/:id/mcp`, `/v1/account/export`             | Removed in v2. Use `/v2/usage`, `/v2/billing`, `/v2/repos/:repoId/read-all`, and `/v2/agents/:idOrKey/history` directly                                                                           |

## 1. Update SDK initialization and tools

Replace `Agents` / `tool` with `CamelRun` / `defineTool` from `@camelai/run` v2:

```ts
// v2
import { CamelRun, defineTool } from "@camelai/run";

const client = new CamelRun({
  baseUrl: "https://run.camelai.com",
  apiKey: process.env.CAMELRUN_API_KEY!, // cr_live_...
});

const lookupOrder = defineTool({
  name: "lookupOrder",
  description: "Look up an order by ID",
  parameters: {
    type: "object",
    properties: { orderId: { type: "string" } },
    required: ["orderId"],
  },
  execute: async ({ orderId }: { orderId: string }) => orders.get(orderId),
});

const agent = await client.agents.upsert("support-user-123", {
  model: "azure/gpt-6.2-sol",
  instructions: "Help users with their orders.",
  tools: [lookupOrder],
  builtins: ["files", "human"],
});

const run = await agent.run("Where is order 42?", {
  whileRunning: "queue",
  spendLimitUsd: 0.25,
  actor: "user-123",
});
```

## 2. Replace volumes and mounts with CamelFS repos

Instead of creating `/v1/volumes` and passing `mounts: [...]`, create a `/v2/repos` repository and bind `repoId` and `branch` on the agent:

* `POST /v1/volumes` -> `POST /v2/repos`
* `volume.write` / `PUT /v1/volumes/:id/files/...` -> `POST /v2/repos/:repoId/write` (`puts`, `deletes`, `moves`)
* `volume.readAll` -> `GET /v2/repos/:repoId/read-all`
* `volume.snapshot()` -> every write and bash command already produces an immutable commit SHA; use `repo_checkpoint` for named refs
* `volume.restore(snapshot)` -> `POST /v2/repos/:repoId/restore` with `{ targetCommit }`
* `volume.fork()` -> `POST /v2/repos/:repoId/fork`

For attachments on runs, write the file to the agent's repository first, then reference `{ path, commit, contentType }` in `files`:

```ts
const written = await client.repos.write(agent.repoId!, {
  message: "upload invoice",
  puts: [{ path: "uploads/invoice.png", base64: invoiceBase64 }],
});

const run = await agent.run("Read this invoice.", {
  files: [{ path: "uploads/invoice.png", commit: written.commit, contentType: "image/png" }],
});
```

## 3. Update runs, steering, and spend limits

* `POST /v2/agents/:idOrKey/runs` accepts `prompt` (replacing `text`), `idempotencyKey` (replacing `requestId`), `whileRunning: "queue" | "steer"`, `wait`, `outputSchema`, `maxSteps`, `files`, `actor`, and `spendLimitUsd`.
* **Important**: Per-run `spendLimitUsd` requires `whileRunning: "queue"`. Requests combining `spendLimitUsd` and `whileRunning: "steer"` fail with `400 invalid_spend_limit`.
* If you previously used `/v1/end-users/*`, move customer balance checks to your application backend, pass `spendLimitUsd` on each run, and deduct actual spend from `run.usage.costUsd` or `usage.recorded` webhooks.

## 4. Update signed MCP servers and human inputs

* Point your JWT verifier's JWKS URL to `https://run.camelai.com/v2/.well-known/jwks.json` and update expected `iss` to `https://run.camelai.com/v2`.
* Set `toolIdentity: { subject, context }` on `PUT /v2/agents/:key` (replacing top-level `subject` / `context`) and pass `actor` per run on `POST /v2/agents/:idOrKey/runs`.
* Answer pending inputs via `POST /v2/agents/:idOrKey/inputs/:inputId` with `{ approved, answer, wait, actor }`. Signed MCP inputs and actor-bound runs require a tenant API key (`cr_live_...`).

## 5. Import existing v1 conversation history

If you are migrating existing agents from v1, camelRun v2 provides dedicated history import endpoints (`PUT /v2/agents/:idOrKey/history/import` and `PUT /v2/agents/:idOrKey/history/import/chunk` for chunks up to 1 MiB, plus `GET /v2/agents/:idOrKey/history/import` to read the import proof) and `agent.importV1History(...)` in `@camelai/run`:

1. Provision the destination v2 repository and commit any historical workspace files or attachments first.
2. Create the destination v2 agent (`PUT /v2/agents/:key`) before running any turns on it.
3. Import history with `agent.importV1History({ source, messages, attachments, previous?, appendAfter? })` and save the returned `{ receipt, count }`.
4. The destination agent refuses history imports once it has run activity.
