Use tags to version your templates and manage environment-based deployments
Template versioning allows you to maintain multiple versions of the same template using tags. This enables workflows like semantic versioning, environment-based deployments, and gradual rollouts.
Instead of using a named tag, you can start a sandbox from a specific build by passing its build_id directly. This is useful when you need to pin a sandbox to an exact build artifact — for example, during debugging or when reproducing an issue from a known build.The format follows the same colon syntax as tags: <template>:<build_id> or <namespace>/<template>:<build_id>.You can find the build_id from the return value of Template.build() or by listing tags with Template.getTags() / Template.get_tags().
Copy
Ask AI
import { Sandbox } from 'e2b'// Start a sandbox from a specific build IDconst sandbox = await Sandbox.create('my-template:f47ac10b-58cc-4372-a567-0e02b2c3d479')// With namespaceconst sandbox2 = await Sandbox.create('acme/my-template:f47ac10b-58cc-4372-a567-0e02b2c3d479')
Build with multiple tags to assign several version labels to the same build artifact.
Copy
Ask AI
import { Template } from 'e2b'// Build with multiple tags pointing to the same artifactawait Template.build(template, 'my-template', { tags: ['v1.2.0', 'latest'] })
Assign new tag(s) to an existing build. This is useful for promoting a tested version to production or marking a version as stable.
Copy
Ask AI
import { Template } from 'e2b'// Assign a single tagawait Template.assignTags('my-template:v1.2.0', 'production')// Assign multiple tags at onceawait Template.assignTags('my-template:v1.2.0', ['production', 'stable'])
// Build new versionawait Template.build(template, 'my-app:v1.5.0')// Promote through environmentsawait Template.assignTags('my-app:v1.5.0', 'staging')// After testing, promote to productionawait Template.assignTags('my-app:v1.5.0', 'production')// Use in your applicationconst env = process.env.NODE_ENVconst sandbox = await Sandbox.create(`my-app:${env}`)
Maintain rolling tags that always point to specific versions.
Copy
Ask AI
// Build with version and latest tagawait Template.build(template, 'my-tool', { tags: ['v3.0.0', 'latest'] })// Mark a tested version as stableawait Template.assignTags('my-tool:v2.9.0', 'stable')// You can choose your risk toleranceconst latestSandbox = await Sandbox.create('my-tool:latest') // Newestconst stableSandbox = await Sandbox.create('my-tool:stable') // Tested