Skip to content

Guides

Snapshots and parallel copies

Set a sandbox up once, snapshot it, and start as many copies of it as you need, in parallel, on the same provider.

Keep state or run in parallel

  • Steps that build on each other

    One sandbox, commands in sequence: install, then run, then read the result.

  • Stop now, continue later

    Create with require: ["pause"], then pause and resume.

  • N copies of one setup at once

    Set it up once, snapshot it, start N copies: variants, benchmarks, retries.

  • The same setup on several providers

    One sandbox per provider, each pinned, same setup script.

A snapshot never leaves its provider. To compare providers, run the same setup script on each one instead.

Snapshot a sandbox

Create the source with provider: { require: ["snapshot"] }, or "fork" when the copies must also keep memory and running processes. The source keeps running while it is snapshotted.

ProviderkindA copy keeps
E2BforkFiles, memory and running processes
FreestyleforkFiles, memory and running processes
NovitaforkFiles, memory and running processes
ModalsnapshotFiles only; processes restart
Upstash BoxsnapshotFiles only; processes restart
POST /v1/sandboxes/:id/snapshot
curl -s -X POST "$API/v1/sandboxes/$SANDBOX_ID/snapshot" -H "$AUTH"
201
{
  "id": "snap_4c1d9e7a20b3f85e6d17",
  "sandbox_id": "sbx_7f3a9c2e1d4b8a6f5e0c",
  "provider": "e2b",
  "kind": "fork",
  "region": "us",
  "size": { "name": "standard", "cpu": 2, "memory_gb": 4 },
  "status": "ready",
  "expires_at": "2026-12-01T10:00:00.000Z"
}

Start copies

Pass from_snapshot to a create, with count (1 to 20) for several copies at once. Copies run on the snapshot's provider, size and region, with no fallback; all of them start or none do, and the response is { data: [...] }. Leave out sandbox, size and template: the snapshot sets them.

POST /v1/sandboxes
curl -s -X POST "$API/v1/sandboxes" -H "$AUTH" -H "Content-Type: application/json" \
  -d '{"from_snapshot": "snap_4c1d9e7a20b3f85e6d17", "count": 3, "timeout": 900}'

Run N variants in parallel

Install once, snapshot, run a different variant in each of 3 copies at the same time, then clean everything up.

The CLI does the same with sp snapshot <id>, sp new --from <snap_id> --count 3 and sp snapshots rm <snap_id>; MCP clients get snapshot_sandbox, fork_sandbox and delete_snapshot.

Benchmark providers

Pin every run with provider: { only: ["e2b"], allow_fallbacks: false } and record provider, size and region from each create response next to its result. With fallbacks on, a run can land on another provider without failing. See only and ignore.

Expiry, cost and deletion

Snapshots expire after 7 days, sooner when the provider keeps them for less. GET /v1/snapshots lists yours; DELETE /v1/snapshots/:id deletes one on the provider. Storage is billed once, when the snapshot is deleted or expires, at the provider's list price where it charges for it. An expired snapshot answers snapshot_expired; take a new one.