One API for every sandbox provider

  • Daytona
  • Northflank
  • Cloudflare
  • CodeSandbox
  • Docker
  • Podman
  • Firecracker

Create sandboxes, run commands, move files and open ports on E2B, Modal, Daytona, Vercel or your own laptop. Switching providers is a one-line change.

curl -fsSL https://carton.sh/install | sh

Open source · self-hosted · Cloud waitlist

import { Carton } from "carton";

const carton = new Carton();

const sandbox = await carton.sandboxes.create({
  provider: "e2b",  // the only line that changes
  template: "python-3.12",
});

const exec = await sandbox.exec(["python", "agent.py"]);
for await (const line of exec.logs()) console.log(line);

await sandbox.delete();

Example code. The SDK, CLI and HTTP API share one set of verbs.

Sandbox APIs agree on almost nothing

We read 70 API specs from 33 sandbox providers. They share the shape of a REST API and very little else. Every adapter you write by hand is a new dialect to learn, test and keep up with.

to sayproviders usecarton uses
the resourcesandboxes · devboxes · vms · box · browserssandboxes
a lifetimeseconds · minutes · milliseconds · "1h"max_lifetime_seconds
tear downDELETE · POST /shutdown · terminate · killDELETE → 204
an errora different body for every provider{ "error": { code, message, retryable } }
authBearer · X-API-Key · X-Access-Token · two-header pairsAuthorization: Bearer
a safe retryIdempotency-Key, declared by 2 of 33Idempotency-Key on every POST

Counted from each provider's published API spec. carton absorbs the differences in adapters, so your code only ever sees the right-hand column.

The whole API fits on one screen

Sandboxes, executions, files, ports and snapshots. Plain REST, cursor pagination, the same error object everywhere.

GET    /v1/sandboxes                     list
POST   /v1/sandboxes                     create, on any provider
GET    /v1/sandboxes/{id}                read, by id or name
POST   /v1/sandboxes/{id}/{verb}         pause · resume · fork
DELETE /v1/sandboxes/{id}                destroy

POST   /v1/sandboxes/{id}/executions     run a command
GET    …/executions/{exec}/logs          stream output
POST   …/executions/{exec}/stdin         write input

PUT    /v1/sandboxes/{id}/files/{path}   write a file
POST   /v1/sandboxes/{id}/ports          expose a port
POST   /v1/sandboxes/{id}/snapshots      snapshot
GET    /v1/sandboxes
POST   /v1/sandboxes
GET    /v1/sandboxes/{id}
POST   /v1/sandboxes/{id}/{verb}
DELETE /v1/sandboxes/{id}

POST   …/{id}/executions
GET    …/executions/{exec}/logs
POST   …/executions/{exec}/stdin

PUT    …/{id}/files/{path}
POST   …/{id}/ports
POST   …/{id}/snapshots

The TypeScript SDK and the CLI use the same nouns and verbs, so what you learn once works everywhere. An MCP server for agents will follow the same shape. Planned

Built for agents that retry

Agents call APIs in loops, lose connections and try again. carton is designed for that from the first request.

Retries never double-bill
Every POST takes an Idempotency-Key. An agent that retries a create gets the same sandbox back, not a second one on your invoice.
Streams you can resume
Logs and events stream over SSE with a sequence number. Drop the connection, reconnect, and pick up at the last line you saw.
Exec is a handle
Start a command, stream its output, write to stdin, send a signal, resize the terminal or kill it, all through one execution id.
Capabilities, not surprises
Each provider declares what it supports: pause, fork, snapshots, pty. Ask for something it lacks and you get a typed error, never a silent fallback.
Units in the name
max_lifetime_seconds, idle_timeout_seconds, exec_timeout_ms. No bare timeout, no guessing whether 60 means seconds or minutes.
One error, everywhere
The SDK, the CLI with --json and the HTTP API return the same error object, and the CLI has documented exit codes, so agents stop parsing stderr.

Your laptop is a provider too

Develop against --provider local, ship against a hosted one. Same code, same API.

Run carton agent on a laptop, a server or a GPU box and it joins the same pool as your hosted providers. It reports its real isolation boundary, so your policy can keep untrusted code off weak sandboxes.

$ carton agent join https://carton.internal
registered  my-mac      apple-container  vm  arm64
registered  gpu-box-01  firecracker      vm  amd64
$ carton agent join https://carton.internal
registered  my-mac      vm  arm64
registered  gpu-box-01  vm  amd64

One inventory, and agents never see your keys

carton holds the key for every provider account. Agents and CI jobs get carton tokens you can scope, limit and revoke.

One list covers every account. Deadlines work the same way on every provider, forgotten sandboxes get cleaned up, and spend is tracked per token.

$ carton ls
ID        PROVIDER  TOKEN         AGE  EXPIRES  STATE
sbx_7k2m  modal     agent-review  12m  in 48m   running
sbx_q91d  e2b       agent-review  3h   in 2m    running
sbx_r55p  local     ci            1d   expired  orphan, cleaning up

$ carton spend --by token --since 7d
TOKEN         MODAL   E2B     LOCAL   TOTAL (EST.)
agent-review  $41.20  $18.75  $0.00   $59.95
ci            $6.10   $0.00   $0.00   $6.10
$ carton ls
ID        PROVIDER  EXPIRES  STATE
sbx_7k2m  modal     in 48m   running
sbx_q91d  e2b       in 2m    running
sbx_r55p  local     expired  orphan

$ carton spend --by token --since 7d
TOKEN         TOTAL (EST.)
agent-review  $59.95
ci            $6.10

Example output. Spend is estimated from what carton ran, and reconciled with the provider's own billing where it offers one.

Providers

carton reaches each provider through an adapter. These are the first ones we're building.

Hosted

  • E2B
  • Modal
  • Daytona
  • Vercel Sandbox
  • Runloop
  • Northflank
  • Morph
  • Blaxel
  • Cloudflare
  • CodeSandbox

Your machines

  • Docker
  • Podman
  • Apple container
  • Firecracker
  • nono
  • bubblewrap

Something else? Write an adapter: nine operations, in any language. carton's adapter kit handles polling, retries and error mapping.

Open source. Cloud is coming.

Self-hosted

Free and open source. One binary for the server, the CLI and the agent. Your keys stay on your infrastructure.

Install carton

carton Cloud Coming soon

The same API, hosted. Bring your own provider keys. Join the waitlist and we'll email you when it opens.

Questions

Is carton a sandbox provider?

No. carton sits on top of the providers you already use, and on your own machines. It gives them one API, keeps track of what is running, and holds the keys.

Do providers have to support carton?

No. carton talks to each provider through its own API, using an adapter. Adding a provider means writing an adapter: nine operations, in any language.

What happens when a provider can’t do something?

You find out before it matters. Every provider declares its capabilities, and calling one it doesn’t have returns a typed error. carton never fakes a feature behind your back.

Can a running sandbox move to another provider?

No. You choose the provider when you create a sandbox. You can copy files between sandboxes, but running processes and memory stay where they are.

Where do my provider keys live?

In carton, encrypted. Agents and CI jobs get carton tokens, which you can scope, limit and revoke without touching the provider account.

Is it safe to run untrusted code on my laptop?

carton reports the real isolation boundary of every provider: vm, gvisor, container or namespaces. Your policy decides which code may run where, for example "untrusted code needs a vm".

Write it once. Run it on any provider.

curl -fsSL https://carton.sh/install | sh

Rather not host it? Join the Cloud waitlist