> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bonya.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Snapshot a sandbox

> Capture a running sandbox's disk state

A snapshot captures a sandbox's disk state at a point in time. It's identified by its own `snapshot_id`, tied back to the `source_sandbox_id` it was taken from — but its identity outlives that source: you can delete the sandbox that produced a snapshot and keep the snapshot. See [Snapshots](https://docs.bonya.ai/concepts/snapshots.md) for the full concept.

> [!NOTE]
>
> To start a new sandbox from a snapshot, pass its id to create (`snapshot` in the SDKs and API, `snapshot` on the MCP `sandbox_create` tool). To clone a running sandbox directly, use fork.

## Create a snapshot

The source sandbox must be **running** — suspended, failed, or already-deleted sandboxes are rejected rather than snapshotted.

```shell CLI theme={null}
bonya snapshot create web
```

```python Python theme={null}
snapshot = sandbox.snapshot(idempotency_key="snapshot-job-123")
print(snapshot.id, snapshot.source_sandbox_id)
```

```ts TypeScript theme={null}
const snapshot = await sandbox.snapshot({ idempotencyKey: "snapshot-job-123" });
console.log(snapshot.id, snapshot.sourceSandboxId);
```

```go Go theme={null}
snapshot, err := sandbox.Snapshot(ctx, bonya.SnapshotOptions{
	IdempotencyKey: "snapshot-job-123",
})
fmt.Println(snapshot.ID, snapshot.SourceSandboxID)
```

The SDKs accept (or auto-generate) an idempotency key for create, so a retried call returns the same snapshot identity rather than minting a second one. If the source sandbox isn't running, the SDKs raise/throw a specific error rather than a generic failure — a suspended source raises `SandboxSuspendedError`, a failed one `SandboxFailedError`, a deleted one `SandboxNotFoundError`/`SandboxDeletedError`.

## Delete a snapshot

Delete is idempotent — calling it again on an already-deleted snapshot is a local no-op, not an error.

```shell CLI theme={null}
bonya snapshot delete web <snapshot-id>
```

```python Python theme={null}
snapshot.delete()
snapshot.delete()  # no-op
```

```ts TypeScript theme={null}
await snapshot.delete();
await snapshot.delete(); // no-op
```

```go Go theme={null}
snapshot.Delete(ctx)
snapshot.Delete(ctx) // no-op
```

Because a snapshot's identity outlives its source sandbox, you can delete a snapshot's source sandbox first and its snapshot later — the two are independent decisions.

## Related

> [card] [Snapshots](https://docs.bonya.ai/concepts/snapshots.md)

> [card] [Sandboxes](https://docs.bonya.ai/concepts/sandboxes.md)

> [card] [Snapshot CLI reference](https://docs.bonya.ai/cli-reference/snapshot.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.