Lifecycle states
Every sandbox moves through a well-defined set of states.
A sandbox starts in
running immediately after creation. From there you can pause it, resume it from paused, or delete it from either running or paused.
Creating a sandbox
Creating a sandbox requires a template — either a template alias like"base" or an immutable artifact ID. You can optionally set a human-readable name, a deadline in seconds (how long the sandbox may run before it is automatically terminated), and arbitrary metadata key-value pairs you can filter on later.
Pass an
idempotencyKey (TypeScript) or idempotency_key (Python) whenever your code might retry sandbox creation. The platform returns the sandbox from the first successful request for any duplicate key, so you will never accidentally create two sandboxes from a retry loop.Running commands
Once a sandbox is running, callcommands.run() to execute a command and wait for it to finish. You get back the exit code, standard output, and standard error.
Working with files
Filesystem operations go directly to the sandbox data plane — they do not route through the control plane.Pausing and resuming
Pausing saves a complete snapshot — memory, filesystem, and all running processes — to object storage, then releases the compute slot on the node. Resume restores everything from that snapshot, exactly where it left off.Each resume creates a new epoch. Capability tokens are scoped to an epoch, so any token you held before pausing is no longer valid after a resume. The SDK automatically obtains a fresh token on the sandbox handle after
resume(). See Security for the full token model.Sandbox deadlines
A deadline is a maximum lifetime enforced from outside the guest. When the deadline expires, the platform terminates the sandbox — even if a process is still running inside. You set the initial deadline at creation time withdeadline_seconds. You can extend an active sandbox’s deadline at any time:
Deleting a sandbox
Deleting a sandbox tears down the microVM immediately, releases all compute and network resources, and marks the record asterminated. Delete works whether the sandbox is running or paused.
Listing and filtering sandboxes
Uselist() to read one page of sandboxes. Filter by state, by name, or by any metadata key-value pairs you attached at creation.
iterate() follows each page’s cursor automatically and fetches a new page only when the previous one is exhausted. Break out of the loop at any time to stop.
Full lifecycle example
1
Create the sandbox
Pass a template alias and a deadline. Use an idempotency key if your code might retry.
2
Run your workload
Execute commands, read and write files, or start a streaming process.
3
Pause if you need to preserve state
Pause to object storage if the sandbox will be idle for a while. Resume it later with its processes intact.
4
Delete when finished
Call
delete() to release all resources. A try/finally block keeps cleanup reliable.TypeScript