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

# Templates

> A template is the prepared VM a sandbox starts from; pick one by name or save your own start state as a snapshot.

## See what exists

```bash theme={"theme":"css-variables"}
curl -sS https://api.styne.ai/templates -H "Authorization: Bearer $STYNE_API_KEY"
```

Each entry has the `templateID`, its `aliases`, `cpuCount`, `memoryMB` and `diskSizeMB`. The CLI prints the same:
`styne template list` (`--json` for the API's answer). A template you cannot start, or that does not exist, answers
`404 not_found` on create.

| Template | Use | Size | Contents |
| - | - | - | - |
| `small` | sandboxes: code, tests, tools, servers | 2 vCPU, 4 GiB memory, 51 GiB disk | Linux, root user, Python 3, Node, git, curl |
| `default` (alias `base`) | the size a create gets when it names none | 4 vCPU, 8 GiB memory, 51 GiB disk | as `small` |
| `large` | builds, test suites, data work | 8 vCPU, 16 GiB memory, 111 GiB disk | as `small` |
| `xlarge` | heavy builds and jobs | 16 vCPU, 32 GiB memory, 251 GiB disk | as `small` |

The image has root, `/root` as the home directory, Python 3, Node, git and curl, and is also named `code`. The list may also
show a browser template. It is for [browsers](https://docs.styne.ai/browsers.md), and it does not start a sandbox. See
[limits](https://docs.styne.ai/limits.md#sandbox-sizes) for sizes; asking for more than the template has answers `400`.

## Which to pick

Start from `base`. It is the image every example in these docs uses and the one the E2B SDKs map to (`Sandbox.create("base")`);
a name that does not exist, such as `node` or `python`, answers `404`. Install what your task needs at run time, or once into
a snapshot.

## Make your own start state

Install the toolchain in a sandbox, check it, save it, and start every later sandbox from the name. The state includes the
installed packages, your repository checkout and anything running in memory.

```python theme={"theme":"css-variables"}
from e2b import Sandbox

with Sandbox.create(template="base", timeout=600) as sbx:
    sbx.commands.run("mkdir -p /root/toolbox && echo v1 > /root/toolbox/VERSION && sync")
    print(sbx.commands.run("cat /root/toolbox/VERSION").stdout.strip())
```

Then save it and start from it with the calls in [Snapshots](https://docs.styne.ai/snapshots.md):
`POST /sandboxes/{id}/snapshots` with a `name`, and `POST /sandboxes` with `{"snapshot": "<name>"}` instead of `templateID`.
A sandbox started from a snapshot has the size of the template the snapshot came from.

## Things to know

* A snapshot is placed on the node that holds it, so a create from a name waits for capacity on that node only.
* Names are yours: other accounts never see them, and a name is unique in your account.
* Rebuild a snapshot when your toolchain changes: save a new name (`toolbox-v2`), move your harness to it, delete the old
  one. Sandboxes already started are not affected by a delete.

## Resolve an alias

```bash theme={"theme":"css-variables"}
curl -sS https://api.styne.ai/templates/aliases/base -H "Authorization: Bearer $STYNE_API_KEY"
```

The answer is the `templateID` the alias stands for, for example `{"templateID": "...", "public": true}`; an unknown alias answers `404`. The list is also served at `GET /default-templates` and `GET /v2/templates`, the paths the E2B SDK reads, with the same answer as `GET /templates`.

## Operations

| Method | Path | What it does |
| - | - | - |
| `GET` | `/templates/aliases/{alias}` | Resolve a template alias to its template id |
| `DELETE` | `/templates/{id}` | Delete a saved snapshot by its template id, at the path the E2B SDK uses; answers 204 |
| `GET` | `/default-templates` | List the templates the key can start, at the path the E2B SDK reads |
| `GET` | `/v2/templates` | List the templates the key can start, at the E2B v2 path |


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