Skip to content

Lifecycle + Environment

Sandboxes can self-terminate based on age or inactivity. Both fields are optional and can be set independently.

FieldBehavior
stopIfIdleForStop the sandbox after this duration of inactivity (nanoseconds).
destroyAtAgeDestroy the sandbox once it is this old (nanoseconds from creation).

Go uses time.Duration for these fields. TypeScript, Python, and Rust use integer nanoseconds.

const sandbox = await client.create({
image: 'ubuntu:22.04',
lifecycle: {
stopIfIdleFor: 60 * 60 * 1_000_000_000, // 1 hour
destroyAtAge: 24 * 60 * 60 * 1_000_000_000, // 24 hours
},
})

The sandbox environment is fully specified at creation time. All fields are optional except image.

Pass key-value pairs into the container at creation. Variables are stored encrypted at rest and are not returned by list or get endpoints.

const sandbox = await client.create({
image: 'ubuntu:22.04',
env: {
DATABASE_URL: 'postgres://...',
APP_ENV: 'sandbox',
},
})
FieldUnitDefaultDescription
cpuvCPUs1CPU quota
memoryMBmegabytes512Memory limit
diskGBgigabytes10Writable layer size

Resources can be changed on a live sandbox without a restart using resize.

const sandbox = await client.create({
image: 'ubuntu:22.04',
cpu: 2,
memoryMB: 2048,
diskGB: 20,
})

The sandbox image's default entrypoint and CMD are not used. Your workload runs via the exec or session APIs instead. See Process & Code Execution and Sessions.