# Snapshots & clones

A **snapshot** is a saved copy of a sandbox's disk – installed packages and files, not memory. Start new sandboxes from it whenever you like, or **clone** a sandbox into up to 10 copies with one call: prepare an environment once, then run several agents or test variants from it.

## Save a snapshot and start from it

**Python**

```
from wbxsandbox import Sandbox, Snapshot

sb = Sandbox.create(template="base", timeout=600)
sb.run("pip install pandas && mkdir -p /home/user/data")
snap = sb.snapshot(name="after-setup")       # Snapshot(id="snap_...", size_bytes=...)

sb2 = Sandbox.create(from_snapshot=snap.id, timeout=600, env={"RUN": "2"})
print(sb2.run("python3 -c 'import pandas'").ok)  # True – the package is on the disk

for s in Snapshot.list():
    print(s.id, s.name, s.source_sandbox, s.size_bytes)
snap.delete()
```

**TypeScript**

```
import { WBX } from "wbxsandbox";

const wbx = new WBX();
const sb = await wbx.sandboxes.create({ template: "base", timeoutSeconds: 600 });
await sb.commands.run("pip install pandas");
const snap = await sb.snapshot({ name: "after-setup" });

const sb2 = await wbx.sandboxes.create({ fromSnapshot: snap.id, timeoutSeconds: 600, env: { RUN: "2" } });
for (const s of await wbx.snapshots.list()) console.log(s.id, s.name, s.sizeBytes);
await snap.delete();
```

**curl**

```
curl -s -X POST https://sandbox.wbx.cz/v1/sandboxes/SB_ID/snapshots -H "Authorization: Bearer $WBXSANDBOX_API_KEY" \
  -H "Content-Type: application/json" -d '{"name": "after-setup"}'

curl -s -X POST https://sandbox.wbx.cz/v1/sandboxes -H "Authorization: Bearer $WBXSANDBOX_API_KEY" -H "Content-Type: application/json" \
  -d '{"from_snapshot": "SNAP_ID", "timeout_s": 600, "env": {"RUN": "2"}}'

curl -s https://sandbox.wbx.cz/v1/snapshots -H "Authorization: Bearer $WBXSANDBOX_API_KEY"
curl -s -X DELETE https://sandbox.wbx.cz/v1/snapshots/SNAP_ID -H "Authorization: Bearer $WBXSANDBOX_API_KEY"
```

- A snapshot works for a **running**, **paused** or **asleep** sandbox. A running one is paused only for a moment while its disk is copied and then keeps running; a sleeping one is not woken.
- A sandbox from a snapshot (`from_snapshot`) gets the snapshot's template (leave `template` out) and boots fresh. Everything else – lifetime, `env`, network, name, `on_timeout` – comes from your request, as for any new sandbox; vCPU and memory from the request or the snapshot.
- It starts on the server that stores the snapshot. When that server is full or does not answer, you get `503` – usually with code `snapshot_node_unavailable`; the `503` can also come without a code. Retry a little later.
- A snapshot stays until you delete it – also after the source sandbox ends – and its size is billed as storage.

## Clone a sandbox

A clone takes a snapshot of the sandbox and starts `count` (1–10) new sandboxes from it on the same server. Copies keep the source sandbox's lifetime and network settings, its compute class, `on_timeout`, `idle_timeout_s` and `keep_days` unless you set them – see [what copies keep](#inherit).

**Python**

```
copies = sb.clone(count=3)              # same lifetime, compute class and network as sb
longer = sb.clone(timeout=3600)         # one copy with its own lifetime
for c in copies:
    c.run("python3 worker.py")
if copies.errors:                       # copies that could not be created
    print(copies.errors)
```

**TypeScript**

```
const { sandboxes, errors } = await sb.clone({ count: 3 });  // same lifetime, compute class and network as sb
const longer = await sb.clone({ timeoutSeconds: 3600 });     // one copy with its own lifetime
await Promise.all(sandboxes.map((c) => c.commands.run("python3 worker.py")));
if (errors.length) console.log(errors);
```

**curl**

```
curl -s -X POST https://sandbox.wbx.cz/v1/sandboxes/SB_ID/clone -H "Authorization: Bearer $WBXSANDBOX_API_KEY" \
  -H "Content-Type: application/json" -d '{"count": 3}'
```

- The answer is `{"snapshot_id", "snapshot_kept", "sandboxes": [ … ], "errors": [ … ]}` with status `201`. When only some copies could be created (status `207`) – usually because your plan allows fewer concurrent sandboxes – the created ones are in `sandboxes` and one `{"index", "name", "status", "code", "error"}` per failed copy in `errors`. When no copy could be created, the status and code are those of the first error; only then do the SDKs raise an error.
- `name` names the copies (`<name>-1` … `<name>-N` for several). The snapshot used for the clone is deleted afterwards unless you send `"keep_snapshot": true` (`snapshot_name` names it; `keepSnapshot` / `snapshotName` in TypeScript).
- Every copy counts towards your concurrent-sandbox, vCPU and memory limits. Destroy copies you no longer need.

## From your AI assistant

Ask: “save a snapshot of this sandbox” or “make 3 copies of it and try a different fix in each”. The tools are `create_snapshot`, `list_snapshots` and `clone_sandbox`; `create_sandbox` takes `from_snapshot`. `clone_sandbox` can only change the lifetime of the copies (`timeout_s`) – network, IP version and compute class are always taken from the source. The copies do not become the current sandbox; the assistant passes a copy's `sandbox_id` to work in it. Snapshots cannot be deleted over MCP – use the portal, the API or an SDK. Parameters: [MCP tools](https://sandbox.wbx.cz/docs/mcp/tools.md#snapshots). Walkthrough: [Prepare once, run many agents](https://sandbox.wbx.cz/docs/guides/snapshot-clone.md).

## In the portal

*Snapshot* and *Clone* (with the number of copies) on a running or asleep sandbox on the *Sandboxes* page. The *Snapshots* page lists your snapshots with their size, source and date, starts a sandbox from one (*Create sandbox*) and deletes them; *Start a sandbox* → *Start from* picks a snapshot too.

## Reference: what a snapshot contains

| Contains | Does not contain |
| --- | --- |
| The whole disk of the sandbox at that moment: installed packages, your files, caches – and everything else written to the disk, for example `.env` files, tokens saved by tools or shell history. | Memory and running programs (a sandbox from a snapshot boots fresh) – including files in `/tmp`, `/run` and `/dev/shm`, which live in memory; the `env` you passed when creating the source, its lifetime, compute class and network settings, name and public URLs. |

A snapshot belongs to your team only and is never shared with other accounts. If the disk holds secrets, remove them before the snapshot, or delete the snapshot when you no longer need it.

```
{
  "id": "snap_n1_3f9c0a6b1d2e4f58",
  "name": "after-setup",
  "source_sandbox": "sb_n1_…",
  "template": "base",
  "vcpu": 1, "mem_mb": 1024, "disk_mb": 4096,
  "size_bytes": 734003200,
  "created_at": "2026-11-21T10:00:00Z"
}
```

`size_bytes` is the space the snapshot takes and what is billed; `disk_mb` is the disk size of a sandbox started from it.

### What copies keep from the source

Copies keep the source sandbox's lifetime and network settings, its compute class, `on_timeout`, `idle_timeout_s` and `keep_days` unless you set them in the request. Options you pass win – except network access, which can only get narrower. A sandbox started with `from_snapshot` (not a clone) takes nothing from the source sandbox.

| Setting | Left out | Set in the request |
| --- | --- | --- |
| `timeout_s` | the source's lifetime (the value it was created with, or the last one set); a source with the default lifetime gives copies the default too | your value |
| `on_timeout`, `idle_timeout_s` | the source's | your value |
| `keep_days` | the source's, at most what your plan allows now | your value |
| `compute_class` | the source's class – unless your account can no longer use it; then your default class | your value |
| network (`mode`, `allow`, `block`, `ip`) | the source's: no internet stays no internet, an allowlist stays the same, blocked destinations stay blocked, the IP version is kept | only narrows the source's access: the stricter mode wins, blocked destinations add up, two allowlists keep only what both allow; `ip` chooses the IP version |
| `env`, `metadata` | not taken over – pass what the copies need | your value |
| vCPU, memory, template | from the source | `vcpu` / `mem_mb` as for a sandbox from a snapshot; `template` is refused |

A zero or empty value counts as left out: `"timeout_s": 0`, `"keep_days": 0`, `"idle_timeout_s": 0` and `"compute_class": ""` keep the source's setting – pass the value you want instead (for example `"timeout_s": 300`). A request lists at most 200 allowed and 200 blocked destinations; when team policy, source and request add up to more than 1000, the clone is refused (`400 network_too_large`). When the network of the source cannot be read right now, the clone is refused with `503 clone_network_unknown` rather than giving copies wider access.

### Identity of copies

Every sandbox from a snapshot – and every clone – gets a new ID, its own network (and an IPv6 address only if you request it) and a new identity: `/etc/machine-id` is generated again and the SSH host keys of the source (`/etc/ssh/ssh_host_*`) are removed, so two copies never look like the same machine. To make sure services start with the new identity, the sandbox restarts once during its first start – starting from a snapshot therefore takes a few seconds longer than from a template. Files you created yourself (for example IDs your app wrote to disk) are copied as they are.

### Limits and billing

- **Availability:** snapshots and clones are available on every plan – API, SDKs, MCP and portal. They can be turned off for an account; then the API answers `403 feature_disabled` (`GET /v1/features` shows `snapshots` and `clones`).
- **Number of snapshots:** set by your plan (see [Limits](https://sandbox.wbx.cz/docs/limits.md#plans)); above it `429 snapshot_limit`. A snapshot made only for a clone does not stay.
- **Storage:** billed like asleep sandboxes – the size of each snapshot counts on its own (blocks it shares with the source or other snapshots are not subtracted) and is added to the storage of asleep sandboxes; the GB included in your plan apply first, the rest is billed per GB and month ([Pricing](https://sandbox.wbx.cz/pricing)).
- **Deletion:** only when you delete it – or when your account is deleted, or your credit has run out and the grace period passed without a top-up; we email you 2 days before.
- **Errors:** `409 sandbox_archived` (wake the sandbox first), `429 snapshot_limit`, `503 snapshot_pause_failed`, `503 clone_network_unknown` and others – all in [Errors](https://sandbox.wbx.cz/docs/errors.md#snapshots).

## Next steps

- [Prepare once, run many agents](https://sandbox.wbx.cz/docs/guides/snapshot-clone.md): A complete example with cleanup.
- [Sleep and wake](https://sandbox.wbx.cz/docs/sandboxes/sleep.md): Keep one sandbox's files between sessions.
- [Versions](https://sandbox.wbx.cz/docs/versions.md#minimum): SDK versions with snapshots and clones.

Source: https://sandbox.wbx.cz/docs/sandboxes/snapshots
