> ## 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.

# Snapshots

> Capture a sandbox's disk state and restore or fork it

A **snapshot** captures a sandbox's disk state. It is identified by a `snapshot_id` and tied to the `source_sandbox_id` it was taken from. Its identity outlives the source: you can delete the sandbox that produced a snapshot and keep the snapshot.

Snapshots are part of the public REST API (`/v1/sandbox/{sandbox_id}/snapshots` and `/v1/snapshot/{snapshot_id}`), the SDKs, the CLI and the MCP server.

## Creating a snapshot

The source sandbox must be **running**. A paused, failed, or deleted sandbox is rejected rather than snapshotted.

```shell cURL theme={null}
curl -X POST https://api.bonya.ai/v1/sandbox/$SANDBOX_ID/snapshots \
  -H "Authorization: Bearer $BONYA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "baseline"}'
```

```python Python theme={null}
snapshot = sandbox.snapshot(name="baseline")
```

```ts TypeScript theme={null}
const snapshot = await sandbox.snapshot({ name: "baseline" });
```

```go Go theme={null}
snapshot, err := client.CreateSnapshot(ctx, sandbox.ID, bonya.SnapshotOptions{
	IdempotencyKey: "example-snapshot-1",
})
```

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

Create accepts an idempotency key, so a retried call returns the same snapshot rather than minting a second one. See [Idempotency](https://docs.bonya.ai/concepts/idempotency.md).

## Restoring and forking

Start a new sandbox from a snapshot by passing its id to create:

```python Python theme={null}
restored = client.create_sandbox(snapshot=snapshot.id)
```

```ts TypeScript theme={null}
const restored = await client.createSandbox({ snapshot: snapshot.id });
```

To clone a **running** sandbox without naming a snapshot, fork it: `POST /v1/sandbox/{sandbox_id}/fork` with `{"count": 2}`, or `sandbox.fork(2)` in the SDKs.

## Listing and deleting

`GET /v1/sandbox/{sandbox_id}/snapshots` lists a sandbox's snapshots, `GET /v1/snapshot/{snapshot_id}` fetches one, and `DELETE /v1/snapshot/{snapshot_id}` removes it.

```python Python theme={null}
snapshots = sandbox.list_snapshots()
snapshot.delete()
```

```ts TypeScript theme={null}
const snapshots = await sandbox.listSnapshots();
await snapshot.delete();
```

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

Delete is idempotent in the SDKs: calling it again on an already-deleted snapshot is a no-op.

## Related

> [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.