Skip to main content

Pause, resume and snapshots

Pausing keeps a sandbox's memory and files. Snapshots save /workspace so new sandboxes can start from it.

S
Written by Sanjay Senthilkumar

Pausing keeps a sandbox's memory and files, and resuming brings it back where it stopped. Pause and resume work on every plan. A paused sandbox does not use vCPU-hours.

Pause while your agent waits. A running box counts toward your hours for the whole time it runs, busy or idle, so a box left running while the agent waits for a model or a person keeps using hours. Only paused and stopped boxes are free of vCPU-hours.

Pause and resume

await sandscale.sandboxes.pause(box.id, { region: box.region });
await sandscale.sandboxes.resume(box.id, { region: box.region });

Pausing works for microVM sandboxes. Trying to run a command in a paused sandbox gives a 409 (a ConflictError in the SDK): resume it first.

Save a snapshot

const snap = await sandscale.sandboxes.snapshot(box.id, { region: box.region, label: 'after-npm-ci' });

A snapshot is an archive of the sandbox's /workspace, checked end to end. Nothing mounted into the workspace is included, so runtime secrets are never in a snapshot. Snapshots use storage, and work within your organization's snapshot policy (on or off, how many, how large and how long they are kept).

Start from a snapshot

const next = await sandscale.sandboxes.create({ snapshotId: snap.id });

If the archive fails its check, the start fails rather than giving you a broken workspace.

Stopping is final

Stopping a sandbox ends it and deletes its disk. Take a snapshot first if you want to keep its files.

Did this answer your question?