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

# Snapshot an instance

> Save an instance as a template, then start any number of new instances that already hold its files.

```bash curl wrap theme={null}
curl -X POST \
  https://api.agent37.com/v1/instances/ab12cd34ef/snapshot \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "my-setup",
    "description": "Repos cloned, dependencies installed"
  }'
```

```python Python wrap theme={null}
import requests

response = requests.post(
    "https://api.agent37.com/v1/instances/ab12cd34ef/snapshot",
    headers={
        "Authorization": "Bearer sk_live_...",
        "Content-Type": "application/json"
    },
    json={
        "name": "my-setup",
        "description": "Repos cloned, dependencies installed"
    },
)
response.raise_for_status()
print(response.json())
```

```javascript Node wrap theme={null}
const response = await fetch(
  "https://api.agent37.com/v1/instances/ab12cd34ef/snapshot",
  {
    method: "POST",
    headers: {
      "Authorization": "Bearer sk_live_...",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "name": "my-setup",
      "description": "Repos cloned, dependencies installed"
    }),
  },
);
if (!response.ok) {
  throw new Error(await response.text());
}
console.log(await response.json());
```

```json 201 wrap theme={null}
{
  "name": "my-setup",
  "scope": "workspace",
  "status": "saving",
  "revision": 1,
  "image_digest": "sha256:9b2e...c41f",
  "agents": [],
  "description": "Repos cloned, dependencies installed",
  "default_port": null,
  "entrypoint": null,
  "public": false,
  "created": 1764662400,
  "updated": 1764662400
}
```

Authenticate with `Authorization: Bearer sk_live_...` on `https://api.agent37.com`.

Set an instance up once: clone the repositories, install the packages, sign in to the tools. Snapshot it, and every instance you create from the snapshot starts with all of that already in place.

## Path parameters

**id** `string` *required*

The instance id, returned when you create an instance.

## Body parameters

**name** `string` *required*

The name of the template the snapshot is saved as: 2 to 63 characters, lowercase letters, numbers, and hyphens, starting with a letter. A name you have already used publishes the next revision of that template.

**description** `string`

A note for your own reference.

## Response and behavior

The response is a [template object](https://www.agent37.com/docs/agents-api/templates.md#the-template-object). A snapshot is a template: it is listed with your other templates, and you start instances from it by name.

`POST /v1/instances/{id}/snapshot` saves everything on the instance's disk, wherever it was written: the data disk and every package and file changed outside it. The call returns in seconds whatever the disk holds, and the instance keeps running throughout. Like a [fork](https://www.agent37.com/docs/agents-api/instances/fork.md), it copies files and not memory, so running processes are not carried over.

The source must be `running`, `stopped`, or `sleeping`.

### Start instances from it

```bash curl wrap theme={null}
curl -X POST https://api.agent37.com/v1/instances \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{ "template": "my-setup" }'
```

Each new instance holds the snapshot's files on a disk of its own, so nothing one instance writes reaches another, or the instance the snapshot was taken from. What the body leaves out is taken from that instance:

| Field | Default | You can change it |
| - | - | - |
| `type` | the saved instance's | No. A sandbox's snapshot starts sandboxes, a VM's starts VMs |
| `region` | the saved instance's | No |
| `resources.cpu`, `resources.memory` | the saved instance's | Yes, to any [shape](https://www.agent37.com/docs/agents-api/instance-sizing.md) |
| `resources.disk` | the saved instance's | Only to a larger disk |

A request that names a different `type` or `region`, or a smaller `disk`, returns `400`.

### `saving` and `ready`

A new snapshot reads `"status": "saving"`. You can create instances from it straight away. `GET /v1/templates/{name}` reads `ready` a little later, sooner for a small disk and after a few minutes for a large one.

While it is still `saving`, a create can return `409 try_again` when there is no room for another instance beside the original. Retry in a moment, or wait for `ready`.

### Revisions

Snapshot under the same name again and the template moves to the next revision. New instances start from the newest one, and an earlier one stays available by its [pin](https://www.agent37.com/docs/agents-api/templates.md#pin-a-template-version): `"template": "my-setup@1"`.

### Size and price

A snapshot can be as large as the instance's disk. The 15 GB limit on template images does not apply to it.

Storage is \$0.09 per GB per month on what the instance's disk held when the snapshot was taken, from the moment it is taken until you delete the template. Taking one requires a balance in your [wallet](https://www.agent37.com/docs/agents-api/billing.md).

### Delete it

[Delete the template](https://www.agent37.com/docs/agents-api/templates.md#delete-a-template) and every revision's snapshot goes with it, which ends the storage charge. Instances already started from it keep running: their disks are their own.

## Snapshot or fork

| | Snapshot | [Fork](https://www.agent37.com/docs/agents-api/instances/fork.md) |
| - | - | - |
| You get | A template | A second instance |
| Use it to | Start many instances from one setup, now and later | Copy one instance once |
| The source afterwards | Can be deleted | Can be deleted once the fork is `running` |
| Keeps the source's `env`, name, and metadata | No, set them on create | Yes |

## What cannot be snapshotted

* An instance of an Agent37 agent template, such as `agent37-hermes` or `agent37-claude-code`, or of `agent37-n8n`. [Fork](https://www.agent37.com/docs/agents-api/instances/fork.md) it instead. Instances of `agent37-base`, `agent37-ubuntu`, and your own templates can be snapshotted.
* An instance parked in cold storage. [Start](https://www.agent37.com/docs/agents-api/instances/start.md) it first.

A template that holds a snapshot stays private: it cannot be [shared with other workspaces](https://www.agent37.com/docs/agents-api/templates.md#share-a-template-with-other-workspaces). An existing instance cannot be [updated](https://www.agent37.com/docs/agents-api/instances/update.md) onto one, since a snapshot is a whole disk and an update keeps the instance's own.

## Errors

| Status | Code | When |
| - | - | - |
| `400` | `invalid_request` | The name is not a valid template name, the instance is not `running`, `stopped`, or `sleeping`, or its template cannot be snapshotted |
| `402` | `insufficient_balance` | The wallet is empty |
| `409` | `try_again` | The instance is starting, stopping, restoring, or being updated. Retry in a few seconds |
| `409` | `invalid_request` | The instance is parked in cold storage, or was deleted while it was being saved |


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