Sandboxes
A sandbox is the core primitive in Modbox — a running container instance with its own URL, lifecycle, and resource limits.
Lifecycle
Provision
Create a new sandbox. This is always async — the API returns immediately with status: provisioning.
The task_id is your identifier for the sandbox. Choose something meaningful like agent-{session_id} or pr-{pr_number}.
Wait for ready
After provisioning, poll for ready or use the blocking wait endpoint:
Once status is running, the sandbox_url field contains the live HTTPS endpoint.
List sandboxes
Pass X-Workspace-Id to filter by workspace.
Destroy
This immediately deletes all sandbox resources. The sandbox moves to status: destroyed.
TTL (time-to-live)
If a ttl_seconds is set when provisioning, the sandbox is automatically destroyed after that many seconds — even if you never call destroy. This is the recommended way to avoid resource leaks.
Always set a TTL for agent-driven sandboxes. If your agent crashes or your backend goes down, the sandbox will still be cleaned up automatically.