Memory snapshots let you capture a running sandbox and start new sandboxes from that saved state.
When you take a snapshot, you are freezing the sandbox’s memory, processes, and filesystem at that point in time.
Starting a sandbox from a snapshot is instant and you can start a new sandbox from the same snapshot multiple times.
Create a Memory Snapshot
Create a snapshot from a running sandbox.
const snapshot = await sandbox.createMemorySnapshot({
snapshotName: "node-after-setup",
});
console.log("Snapshot name:", snapshot.snapshotName);
console.log("Snapshot ID:", snapshot.snapshotId);
console.log("Status:", snapshot.status);
Start a Sandbox From a Snapshot
Use the snapshot name to start a new sandbox:
const sandbox = await client.sandboxes.create({
snapshotName: "node-after-setup",
snapshotId: "snapshot-id", // if omitted uses the latest snapshot
});
console.log(sandbox.id);
List Images and Snapshots
List the available sandbox images and snapshots:
const { images } = await client.sandboxes.listImages();
const { snapshots } = await client.sandboxes.listSnapshots({
status: "created",
limit: 100,
});
console.log(images.map((image) => image.imageName));
console.log(snapshots.map((snapshot) => snapshot.snapshotName));
Snapshot Response
The snapshot create API returns metadata about both the snapshot and its backing image:
Unique snapshot identifier.
The team that owns the snapshot.
Snapshot creation status.
Backing image name for the snapshot. What the snapshot was created from.