Snapshots
Snapshots need templates with envd v0.5.0 or newer. Check with e2b template list or in the dashboard, and rebuild older templates.
Create a snapshot#
import { Sandbox } from 'e2b'
const sandbox = await Sandbox.create()
const snapshot = await sandbox.createSnapshot()
console.log('Snapshot ID:', snapshot.snapshotId)
// Or by sandbox ID, without a sandbox object
const other = await Sandbox.createSnapshot(sandboxId)from e2b import Sandbox
sandbox = Sandbox.create()
snapshot = sandbox.create_snapshot()
print('Snapshot ID:', snapshot.snapshot_id)
# Or by sandbox ID, without a sandbox object
other = Sandbox.create_snapshot(sandbox_id)Snapshots can also be created, listed and deleted from the E2B CLI.
The sandbox is briefly paused and resumed while the snapshot is taken, which drops every active connection — WebSockets, PTYs, command streams. Reconnect afterwards.
Start new sandboxes from it#
Pass the snapshot ID where you would pass a template.
const newSandbox = await Sandbox.create(snapshot.snapshotId)new_sandbox = Sandbox.create(snapshot.snapshot_id)List and delete#
const paginator = Sandbox.listSnapshots({ sandboxId: 'your-sandbox-id' }) // filter optional
const snapshots = []
while (paginator.hasNext) {
snapshots.push(...(await paginator.nextItems()))
}
// true if deleted, false if not found
const deleted = await Sandbox.deleteSnapshot(snapshot.snapshotId)paginator = Sandbox.list_snapshots(sandbox_id="your-sandbox-id") # filter optional
snapshots = []
while paginator.has_next:
snapshots.extend(paginator.next_items())
Sandbox.delete_snapshot(snapshot.snapshot_id)Snapshot or template?#
Templates boot faster for reproducible environments — their memory is compact and prefetched. Reach for a snapshot when what you need is runtime state: an agent halfway through a task, a warmed-up process, a point to roll back to.