Save and restore
Create a sandbox, write a file, and save a durable checkpoint:wait_durable=True waits until the snapshot
has finished saving and can be used if the original sandbox becomes unavailable.
Restore that snapshot into a new sandbox:
403. Forks inherit the parent’s datasets in the same way.
Grow the writable disk
A sandbox that is running out of disk does not need to start over. Snapshot it, then restore the snapshot at a larger size:- Sizes come from a fixed set: 16 GiB (the default) or 32 GiB — 64 GiB on
upgraded plans.
Any other value returns
400. - Disks grow, never shrink. Restoring a snapshot at a size smaller than it
was captured with returns
400. - Fork accepts no size. Fork copies inherit the parent’s disk exactly; to
get larger children, snapshot the parent, restore it at the larger size, and
fork the restored sandbox. Passing
writable_size_bytesto a fork returns400explaining exactly that.
writable_size_bytes on a restore keeps the snapshot’s own size, so
existing code is unaffected.
Check an existing snapshot
You can create a snapshot without waiting for durability, then check it later:box.snapshots.list().
To save a checkpoint and let the original sandbox rest immediately, use
snapshot(leave_asleep=True, wait_durable=True). Its next command or file access
wakes it automatically; there is nothing to call first.
Fork for parallel work
Create an independent copy of the current sandbox:First result. To create several copies from the same
point, request them together:
fork() returns one sandbox. Passing n returns a list, including when n=1.
You can create up to 16 copies per call, within your organization’s sandbox limit.
Fork between commands whenever possible. Copies inherit running processes and
connection state, so reconnect external services separately in each copy before
using them. Avoid copying a process that is partway through an external write.
See what changed
Compare any two snapshots to see what changed between them, from files and SQLite rows to processes and memory:Merge work back
Merge brings the file changes from one snapshot into a running sandbox. A typical use is to fork, work in the copy, and merge the result back:pre_merge_snapshot_id.