Skip to main content
Snapshots let you create a persistent point-in-time capture of a running sandbox, including both its filesystem and memory state. You can then use a snapshot to spawn new sandboxes that start from the exact same state. The original sandbox continues running after the snapshot is created, and a single snapshot can be used to create many new sandboxes.

Snapshots vs. Pause/Resume

Pause/ResumeSnapshots
Effect on original sandboxPauses (stops) the sandboxSandbox keeps running
Relationship1:1 — resume restores the same sandbox1:many — snapshot can spawn many new sandboxes
Use caseSuspend and resume a single sandboxCreate a reusable checkpoint
For pause/resume functionality, see Persistence.

Snapshot flow

The sandbox is briefly paused during the snapshot process but automatically returns to running state. The sandbox ID stays the same after the snapshot completes.
During the snapshot, the sandbox is temporarily paused and resumed. This causes all active connections (e.g. WebSocket, PTY, command streams) to be dropped. Make sure your client handles reconnection properly.

Create a snapshot

You can create a snapshot from a running sandbox instance.
import { Sandbox } from '@e2b/code-interpreter'

const sandbox = await Sandbox.create()

// Create a snapshot from a running sandbox
const snapshot = await sandbox.createSnapshot()
console.log('Snapshot ID:', snapshot.snapshotId)
You can also create a snapshot by sandbox ID using the static method.
import { Sandbox } from '@e2b/code-interpreter'

// Create a snapshot by sandbox ID
const snapshot = await Sandbox.createSnapshot(sandboxId)
console.log('Snapshot ID:', snapshot.snapshotId)

Create a sandbox from a snapshot

The snapshot ID can be used directly with Sandbox.create() to spawn a new sandbox from the snapshot. The new sandbox starts with the exact filesystem and memory state captured in the snapshot.
import { Sandbox } from '@e2b/code-interpreter'

const snapshot = await sandbox.createSnapshot()

// Create a new sandbox from the snapshot
const newSandbox = await Sandbox.create(snapshot.snapshotId)

List snapshots

You can list all snapshots. The method returns a paginator for iterating through results.
import { Sandbox } from '@e2b/code-interpreter'

const paginator = Sandbox.listSnapshots()

const snapshots = []
while (paginator.hasNext) {
  const items = await paginator.nextItems()
  snapshots.push(...items)
}

Filter by sandbox

You can filter snapshots created from a specific sandbox.
import { Sandbox } from '@e2b/code-interpreter'

const paginator = Sandbox.listSnapshots({ sandboxId: 'your-sandbox-id' })
const snapshots = await paginator.nextItems()

Delete a snapshot

import { Sandbox } from '@e2b/code-interpreter'

// Returns true if deleted, false if the snapshot was not found
const deleted = await Sandbox.deleteSnapshot(snapshot.snapshotId)