Skip to content
Home

Sandbox Lifecycle

A sandbox moves through creation, readiness, runtime operation, and cleanup. Use the SDK object returned by create/connect as the boundary for all runtime work.

create -> starting -> running -> pause/connect or refresh -> delete
ActionUse it when
createAllocate a runtime from base, code-interpreter, or tpl-....
waitReadyThe next line needs files, commands, or ports to be available immediately.
connectRecover runtime URL/token for an existing sandbox ID.
pauseStop runtime resources while keeping metadata for a later connect flow.
refreshExtend TTL for active work.
setTimeoutChange lifecycle timeout in seconds.
deletePermanently clean up disposable work.

API responses expose product-safe states. Internal Atlas states such as new, warming, warm, creating, active, stopped, and destroying are collapsed before they reach public clients.

State/statusMeaning
startingRuntime is creating or waiting for a healthy heartbeat.
runningRuntime APIs are usable.
pausedRuntime is stopped, but durable metadata remains for connect/resume.
deletedSandbox has been removed.
failed / errorRuntime failed to become usable or a lifecycle operation failed.

Sandbox detail, list, and create responses may include timeline and diagnostic. Use those fields for user-facing progress and troubleshooting instead of parsing raw logs.

OptionUnitPurpose
templateIDstringRequired template reference.
timeoutsecondsSandbox lifecycle TTL.
waitReadybooleanWait for usable runtime state.
envVarsmapRuntime environment overrides.
metadatamapUser metadata for search and debugging.
autoPausebooleanWhen supported, timeout maps to pause instead of kill.

Do not send stale compatibility fields such as timeoutMs, autoResume, secure, allow_internet_access, network, mcp, volume_mounts, or request-level volumeMounts. They are rejected instead of silently ignored.

const sandbox = await Sandbox.create("base", {
timeout: 1800,
waitReady: true,
envVars: { FOO: "bar" },
metadata: { purpose: "demo" },
});
const sandboxId = sandbox.sandboxId;
await sandbox.connect({ timeout: 1800 });
// Or from a different process:
const reconnected = await Sandbox.connect(sandboxId, { timeout: 1800 });
await sandbox.setTimeout(3600);
await sandbox.refresh();
await sandbox.pause();
await sandbox.delete();
MethodPathPurpose
POST/api/v1/sandboxesCreate a sandbox.
GET/api/v1/sandboxes/:sandboxIDFetch detail and runtime connection data.
POST/api/v1/sandboxes/:sandboxID/connectReconnect and refresh runtime access.
POST/api/v1/sandboxes/:sandboxID/pausePause runtime.
POST/api/v1/sandboxes/:sandboxID/refreshesRefresh TTL.
POST/api/v1/sandboxes/:sandboxID/timeoutChange timeout in seconds.
DELETE/api/v1/sandboxes/:sandboxIDDelete sandbox.
SignalRouteUse it for
Sandbox detailGET /api/v1/sandboxes/:sandboxIDState, runtime URL/token, lifecycle timestamps, timeline, and diagnostic.
Sandbox logsGET /api/v1/sandboxes/:sandboxID/logsStartup output, readiness failures, application logs, and image pull issues.
Sandbox metricsGET /api/v1/sandboxes/:sandboxID/metricsCurrent CPU, memory, disk, network, and task counters.
Observability summaryGET /api/v1/observability/summaryUser/project usage, quota checks, endpoint availability, and suggested next actions.