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

# Create Snapshot

> Create a snapshot of the current sandbox state for later restoration.

Takes a point-in-time snapshot of the sandbox VM. Snapshots capture the full
memory and filesystem state, allowing you to restore a sandbox to a known-good
checkpoint. Returns a `Snapshot` object with the new snapshot ID.

Use snapshots to checkpoint long-running agent workflows, save expensive setup
steps, or create reusable starting points.

## Path Parameters

<ParamField path="sandbox_id" type="string" required>
  The sandbox identifier. Format: `sbx-<8 chars>`.
</ParamField>

## Response

<ResponseField name="snapshot_id" type="string">
  Unique snapshot identifier. Format: `snap-<8 chars>`.
</ResponseField>

<ResponseField name="sandbox_id" type="string">
  The sandbox this snapshot was taken from.
</ResponseField>

<ResponseField name="created_at" type="string">
  UTC timestamp when the snapshot was created.
</ResponseField>

## Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.declaw.ai/sandboxes/sbx-a1b2c3d4/snapshot \
    -H "X-API-Key: YOUR_API_KEY"
  ```

  ```python Python theme={null}
  from declaw import Sandbox

  sbx = Sandbox.connect("sbx-a1b2c3d4", api_key="YOUR_API_KEY", domain="api.declaw.ai")
  snapshot = sbx.snapshot()
  print(snapshot.snapshot_id)  # snap-a1b2c3d4
  ```

  ```typescript TypeScript theme={null}
  import { Sandbox } from "@declaw/sdk";

  const sbx = await Sandbox.connect("sbx-a1b2c3d4", {
    apiKey: "YOUR_API_KEY",
    domain: "api.declaw.ai",
  });
  const snapshot = await sbx.snapshot();
  console.log(snapshot.snapshotId); // snap-a1b2c3d4
  ```
</CodeGroup>

```json Response theme={null}
{
  "snapshot_id": "snap-a1b2c3d4",
  "sandbox_id": "sbx-a1b2c3d4",
  "created_at": "2024-01-15T10:30:00Z",
  "source": "manual"
}
```

## Error Responses

| Status | Cause                                        |
| ------ | -------------------------------------------- |
| `401`  | Missing or invalid API key                   |
| `404`  | Sandbox not found                            |
| `502`  | Orchestrator unreachable or returned non-200 |
| `503`  | Sandbox node unreachable                     |
