Skip to content
Wardcase Docs

Snapshots

A snapshot saves a sandbox’s /work directory so you can start new sandboxes from it: install dependencies once, snapshot, and create every later sandbox from that state. /work is the sandbox’s writable volume and its home directory, so packages installed with pip install or npm install -g are included.

A snapshot holds the files in /work only. The rest of the filesystem comes from the image and is read-only, /tmp is in memory, and running processes are not saved. Neither are the environment variables you passed with env, so pass them again when you restore.

// Resolves once the snapshot is ready.
const snap = await sbx.snapshot({ name: "deps-installed" });
const copy = await vv.sandboxes.create({ snapshotId: snap.id, region: "eu-west" });
const snaps = await vv.snapshots.list({ sandboxId: sbx.id });

With the API, name it if you like (up to 80 characters):

Terminal window
curl https://api.wardcase.com/v1/sandboxes/sbx_4f9k2m8q1z7x3c5v/snapshots \
-H "Authorization: Bearer $VIVARIUM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"deps-installed"}'

The response is 202 with the snapshot in status pending. Poll GET /v1/snapshots/{id} until status is ready. A ready snapshot has size_bytes and sha256. If the upload fails three times in a row, status is failed and failure_reason says why.

Create a sandbox with snapshotId in TypeScript, snapshot_id in Python, or snapshot_id in the API body. The new sandbox starts from the snapshot’s filesystem and image instead of an image of your choice:

Terminal window
curl https://api.wardcase.com/v1/sandboxes \
-H "Authorization: Bearer $VIVARIUM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"snapshot_id":"snap_7h2k9d4w1m6p3x8r","egress_policy_id":"pol_..."}'

The new sandbox runs in the region the snapshot was taken in, so leave region out or pass that region; another region returns validation. A snapshot that is not ready returns conflict. Size, timeouts, egress policy, environment and metadata come from the request, as for any new sandbox. How snapshots work explains what is and is not saved.

Snapshots are kept in the object storage bucket configured for the service, which is not tied to the sandbox’s region. They stay until you delete them. GET /v1/snapshots lists them, with an optional sandbox_id filter, and DELETE /v1/snapshots/{id} deletes one. Snapshot storage is not billed during early access.

snapshot.requested, snapshot.created with size and SHA-256, snapshot.failed with the reason, snapshot.deleted, and sandbox.restored on the sandbox created from a snapshot.