Template aliases are unique identifiers used to reference and create sandboxes from your templates. They serve as human-readable names that make it easy to identify and use your templates across your applications.
An alias is a string identifier that you assign to a template when building it. Once a template is built with an alias, you can use that alias to create sandboxes from the template.
Copy
Ask AI
// Build a template with an aliasawait Template.build(template, 'my-python-env', { cpuCount: 2, memoryMB: 2048,})// Create a sandbox using the aliasconst sandbox = await Sandbox.create('my-python-env')
Template aliases must be globally unique across the entire E2B platform, not just within your team or account. This means if another user has already claimed an alias, you cannot use it for your template.
When choosing an alias, consider using:
Your company or project name as a prefix (e.g., acme-api-server)
Version numbers or environment indicators (e.g., myapp-v2, myapp-staging)
Descriptive names that indicate the template’s purpose (e.g., data-analysis-python)
Create different variants of the same template with different configurations:
Copy
Ask AI
// Small instanceawait Template.build(template, 'myapp-small', { cpuCount: 1, memoryMB: 512,})// Large instanceawait Template.build(template, 'myapp-large', { cpuCount: 8, memoryMB: 16384,})
When building variants with the same template definition but different CPU/RAM configurations, E2B’s caching system will reuse common layers, making subsequent builds much faster.