When To Use Sandboxes
| Need | Sandbox Pattern |
|---|---|
| Run untrusted or dependency-heavy code | Create a short-lived sandbox with a timeout and destroy it after collecting output. |
| Keep a repo or service warm between requests | Use hibernate, pause, or auto-resume instead of rebuilding state. |
| Start many sandboxes from one ready custom template | Use a template warm pool with explicit checkout mode. |
| Branch from a known setup | Create a snapshot or fork a warm sandbox. |
| Give an agent a workspace | Start from an agent, desktop, code-interpreter, or custom template. |
| Debug failed work | Retain the sandbox and inspect it with commands, PTY, SSH, files, or desktop viewer. |
Quick Example
The Python SDK and CLI snippets below are alternative control planes. Use one path end-to-end unless you are intentionally passing a sandbox ID between tools.Core Model
| Concept | What It Means |
|---|---|
| Template | The base environment used at create time. Use base for general work or a custom template for repeated setup. |
| Template warm pool | Ready capacity for a template. A checkout becomes a normal sandbox and is not recycled. |
| Sandbox ID | The handle for commands, files, preview URLs, metrics, lifecycle, PTY, and SSH. |
| Workdir | /workspace is the default mutable work tree for repo-style and agent workflows. |
| Timeout | Controls what happens when work is idle or runs too long. |
| Lifecycle | Sandboxes can be created, paused, hibernated, resumed, forked, snapshotted, and destroyed. |
Common Tasks
Create, connect, and list
Launch sandboxes, reconnect by ID, and paginate running or paused work.
Lifecycle
Understand create, exec, hibernate, reusable snapshots, fork, and destroy.
Persistence
Pause sandboxes and resume paused state later.
Snapshots
Capture reusable baseline state and spawn independent sandboxes from it.
Auto-resume
Wake paused sandboxes from SDK calls, HTTP, and WebSocket traffic.
Fork
Branch warm state into independent children.
Metrics and timeouts
Inspect resource usage and control timeout behavior.
Preview URLs
Expose HTTP and WebSocket services from inside a sandbox.
What To Read Next
- Use Commands to run work inside a sandbox.
- Use Filesystem to move data in and out.
- Use Templates when setup should be reusable.
- Use Template Warm Pools when a custom template needs ready capacity before a burst.
- Use Volumes when data must outlive the VM.
- Use PTY or SSH for human debugging.