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

# List and manage templates

> List, inspect, and delete your templates with the E2B SDKs and API

You can list your project's templates and delete the ones you no longer need with the JavaScript and Python SDKs. To read a single template's default build or page through its builds, use the [REST API](#get-a-template-and-its-default-build).

## List templates

`Template.list` returns a paginator over your project's templates, newest first. Pass `limit` to set the page size (`1` to `100`, defaults to `100`) and `nextToken` to resume from a previous page.

```typescript JavaScript & TypeScript theme={"theme":"css-variables"}
import { Template } from 'e2b'

const paginator = Template.list()
while (paginator.hasNext) {
  const templates = await paginator.nextItems()
  for (const t of templates) {
    console.log(t.templateId, t.names, t.buildStatus)
  }
}
```

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

paginator = Template.list()
while paginator.has_next:
    for t in paginator.next_items():
        print(t.template_id, t.names, t.build_status)
```

In async Python, use `AsyncTemplate.list()` and `await paginator.next_items()`.

Each template includes `templateId`, `names`, `buildId`, `buildStatus`, `cpuCount`, `memoryMB`, `diskSizeMB`, `envdVersion`, `public`, `createdAt`, `updatedAt`, `lastSpawnedAt`, `spawnCount`, and `buildCount` (snake\_case in Python, e.g. `template_id`, `memory_mb`).

## Get a template and its default build

[`GET /v2/templates/{templateID}`](https://docs.e2b.dev/api-reference/templates/get-template-v2) returns one template by its ID, name, or `team/name`. Encode the slash in `team/name` as `%2F`, for example `/v2/templates/my-team%2Fmy-template`. The response includes `defaultBuild`, the build a sandbox starts from when you don't pass a tag. This is the latest ready build tagged `default`.

```bash cURL theme={"theme":"css-variables"}
curl "https://api.e2b.app/v2/templates/my-template" \
  -H "X-API-Key: $E2B_API_KEY"
```

* `defaultBuild` is absent until a build tagged `default` is ready.
* `buildStatus` reports the latest build tagged `default` in any state. During a rebuild it reads `building`, while `defaultBuild` still shows the ready build that sandboxes start from.
* The response doesn't include the deprecated `aliases` field. Use `names` instead.

## List a template's builds

[`GET /templates/{templateID}/builds`](https://docs.e2b.dev/api-reference/templates/list-template-builds) lists a template's builds, newest first. Each build includes `buildID`, `status`, `cpuCount`, `maxCpuCount`, `memoryMB`, and the `tags` that point at it.

```bash cURL theme={"theme":"css-variables"}
curl "https://api.e2b.app/templates/my-template/builds?statuses=ready,error&tags=default,v2&limit=50" \
  -H "X-API-Key: $E2B_API_KEY"
```

| Query parameter | Description |
| :- | :- |
| `statuses` | Comma-separated build statuses to include: `waiting`, `building`, `ready`, `error`. Repeating a status returns `400`. |
| `tags` | Comma-separated tags, up to 100. Only the builds these tags point at are returned. |
| `limit` | Page size, `1` to `100`. Defaults to `100`. |
| `nextToken` | The `X-Next-Token` header from the previous response, to get the next page. |

A template named `aliases` can't be given by its bare name here. Use its ID or its namespaced name, such as `my-team%2Faliases`.

A tag points at the latest **ready** build it was assigned to, which is the build a sandbox started with that tag runs. A pending or failed rebuild carries no tag.

Both endpoints return `400` when the template reference includes a tag, such as `my-template:v2`. They return `404` when the template is missing, deleted, or belongs to another team.

## Delete a template

`Template.delete()` deletes a template or snapshot by ID or name. It returns `true` if the template was deleted and `false` if it wasn't found.

```typescript JavaScript & TypeScript theme={"theme":"css-variables"}
import { Template } from 'e2b'

const deleted = await Template.delete('my-template')
```

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

deleted = Template.delete("my-template")
```

```python Python (async) theme={"theme":"css-variables"}
from e2b import AsyncTemplate

deleted = await AsyncTemplate.delete("my-template")
```
