Documentation Index Fetch the complete documentation index at: https://e2b.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Build and wait for completion
The build method builds the template and waits for the build to complete. It returns build information including the template ID and build ID.
JavaScript & TypeScript
Python
const buildInfo = await Template. build (template, 'my-template' , {
cpuCount: 2 , // CPU cores
memoryMB: 2048 , // Memory in MB
skipCache: false , // Configure cache skip (except for files)
onBuildLogs: defaultBuildLogger (), // Log callback receives LogEntry objects
apiKey: 'your-api-key' , // Override API key
domain: 'your-domain' , // Override domain
})
// buildInfo contains: { name, templateId, buildId }
Build in background
The buildInBackground method starts the build process and returns immediately without waiting for completion. This is useful when you want to trigger a build and check its status later.
JavaScript & TypeScript
Python
const buildInfo = await Template. buildInBackground (template, 'my-template' , {
cpuCount: 2 ,
memoryMB: 2048 ,
})
// Returns immediately with: { name, templateId, buildId }
Check build status
Use getBuildStatus to check the status of a build started with buildInBackground.
JavaScript & TypeScript
Python
const status = await Template. getBuildStatus (buildInfo, {
logsOffset: 0 , // Optional: offset for fetching logs
})
// status contains: { status: 'building' | 'ready' | 'error', logEntries: [...] }
Example: Background build with status polling
JavaScript & TypeScript
Python
// Start build in background
const buildInfo = await Template. buildInBackground (template, 'my-template' , {
cpuCount: 2 ,
memoryMB: 2048 ,
})
// Poll for build status
let logsOffset = 0
let status = 'building'
while (status === 'building' ) {
const buildStatus = await Template. getBuildStatus (buildInfo, {
logsOffset,
})
logsOffset += buildStatus.logEntries. length
status = buildStatus.status
buildStatus.logEntries. forEach (
( logEntry ) => console. log (logEntry. toString ())
)
// Wait for a short period before checking the status again
await new Promise ( resolve => setTimeout (resolve, 2000 ))
}
if (status === 'ready' ) {
console. log ( 'Build completed successfully' )
} else {
console. error ( 'Build failed' )
}