# Templates

A template is a sandbox's files saved under a name: the workspace, `/tmp` and the home directory, with whatever you put there. New sandboxes can start from it instead of from an empty workspace.

Set a sandbox up once, the way your agent needs it, then save it:

```ts
const sb = await fb.create();
await sb.run("pip install --user httpx rich");
await sb.run("git clone https://github.com/you/your-repo /workspace/repo");
await sb.saveTemplate("py-tools");

const next = await fb.create({ template: "py-tools" }); // starts with all of it
```

In the CLI: `/template save py-tools` in a session, then `flashbox --template py-tools`. Over MCP: `template_save`, then `sandbox_create` with `template`. Over HTTP: `POST /v1/checkpoints/:id/template {"name": "py-tools"}`, then `POST /v1/sandboxes {"template": "py-tools"}`.

## What a template holds

Everything you can write in a sandbox:

- Packages installed for the user: `pip install --user`, npm with a prefix in your home, tools in `~/bin`.
- Repositories, data files and build caches in `/workspace`.

The system itself is read-only, so system packages (`apk add`) are not part of templates; the base image has the common tools (see [sandboxes](/docs/sandboxes/)), and tell us what is missing.

## Limits and storage

- Up to 20 templates per account; names are lowercase letters, digits and dashes.
- A template is stored compressed; a sandbox started from one is ready in a few hundred milliseconds (it restores the template's disk, as a resume does).
- Templates belong to your account; other accounts cannot see or use them.
- `GET /v1/templates` lists them; `DELETE /v1/templates/:name` deletes one.
