> ## Documentation Index
> Fetch the complete documentation index at: https://e2b.manicule.dev/sdk-python-v2.10.0/llms.txt
> Use this file to discover all available pages before exploring further.
> For every page in one file, fetch https://e2b.manicule.dev/sdk-python-v2.10.0/llms-full.txt (large).
> To search and read these docs as tools, connect the MCP server at https://e2b.manicule.dev/api/mcp.
> Every agent surface: https://e2b.manicule.dev/.well-known/llms-manifest.json

# Template Sync (/sdk-python-v2.10.0/template_sync)

<!-- agent-signals: reading_time_min: 2 · est_tokens: 914 · updated: 2026-07-30 -->
Related: [Exceptions](/sdk-python-v2.10.0/exceptions.md), [Sandbox Async](/sdk-python-v2.10.0/sandbox_async.md), [Sandbox Sync](/sdk-python-v2.10.0/sandbox_sync.md), [Template](/sdk-python-v2.10.0/template.md), [Template Async](/sdk-python-v2.10.0/template_async.md), [Template Async Logger](/sdk-python-v2.10.0/template_async-logger.md)

## Template

```python
class Template(TemplateBase)
```

Synchronous template builder for E2B sandboxes.

### build

```python
@staticmethod
def build(template: TemplateClass,
          alias: str,
          cpu_count: int = 2,
          memory_mb: int = 1024,
          skip_cache: bool = False,
          on_build_logs: Optional[Callable[[LogEntry], None]] = None,
          **opts: Unpack[ApiParams]) -> BuildInfo
```

Build and deploy a template to E2B infrastructure.

**Arguments**:

* `template`: The template to build
* `alias`: Alias name for the template
* `cpu_count`: Number of CPUs allocated to the sandbox
* `memory_mb`: Amount of memory in MB allocated to the sandbox
* `skip_cache`: If True, forces a complete rebuild ignoring cache
* `on_build_logs`: Callback function to receive build logs during the build process
  Example

```python
from e2b import Template

template = (
    Template()
    .from_python_image('3')
    .copy('requirements.txt', '/home/user/')
    .run_cmd('pip install -r /home/user/requirements.txt')
)

Template.build(
    template,
    alias='my-python-env',
    cpu_count=2,
    memory_mb=1024
)
```

### build_in_background

```python
@staticmethod
def build_in_background(template: TemplateClass,
                        alias: str,
                        cpu_count: int = 2,
                        memory_mb: int = 1024,
                        skip_cache: bool = False,
                        on_build_logs: Optional[Callable[[LogEntry],
                                                         None]] = None,
                        **opts: Unpack[ApiParams]) -> BuildInfo
```

Build and deploy a template to E2B infrastructure without waiting for completion.

**Arguments**:

* `template`: The template to build
* `alias`: Alias name for the template
* `cpu_count`: Number of CPUs allocated to the sandbox
* `memory_mb`: Amount of memory in MB allocated to the sandbox
* `skip_cache`: If True, forces a complete rebuild ignoring cache

**Returns**:

BuildInfo containing the template ID and build ID
Example

```python
from e2b import Template

template = (
    Template()
    .from_python_image('3')
    .run_cmd('echo "test"')
    .set_start_cmd('echo "Hello"', 'sleep 1')
)

build_info = Template.build_in_background(
    template,
    alias='my-python-env',
    cpu_count=2,
    memory_mb=1024
)
```

### get_build_status

```python
@staticmethod
def get_build_status(build_info: BuildInfo,
                     logs_offset: int = 0,
                     **opts: Unpack[ApiParams])
```

Get the status of a build.

**Arguments**:

* `build_info`: Build identifiers returned from build_in_background
* `logs_offset`: Offset for fetching logs

**Returns**:

TemplateBuild containing the build status and logs
Example

```python
from e2b import Template

build_info = Template.build_in_background(template, alias='my-template')
status = Template.get_build_status(build_info, logs_offset=0)
```

### alias_exists

```python
@staticmethod
def alias_exists(alias: str, **opts: Unpack[ApiParams]) -> bool
```

Check if a template with the given alias exists.

**Arguments**:

* `alias`: Template alias to check

**Returns**:

True if the alias exists, False otherwise
Example

```python
from e2b import Template

exists = Template.alias_exists('base')
if exists:
    print('Template exists!')
```

### check_alias_exists

```python
def check_alias_exists(client: AuthenticatedClient, alias: str) -> bool
```

Check if a template with the given alias exists.

**Arguments**:

* `client` - Authenticated API client
* `alias` - Template alias to check

**Returns**:

True if the alias exists, False otherwise
