Create
Use either the Python SDK or CLI to create a sandbox. The two examples below are equivalent alternatives; the CLI command does not attach to the Python object above.disk_mb sets the minimum rootfs size (MB). On cold create the disk is grown to this
size before boot. Snapshot-backed templates fix their disk size at build time, so for
those set the size with Template.build(..., disk_mb=...) rather than per-create —
passing a larger disk_mb than the template’s built-in size is rejected.
Create From A Template Warm Pool
Use a template warm pool when many sandboxes should start from the same ready custom template. Pass an explicit pool ID and checkout mode:prefer may cold-fallback, require fails with warm_pool_unavailable, and
bypass forces cold create. Snapshot restore, resume, fork, hibernate, and
pause do not use template warm-pool checkout.
Connect
Useconnect when another process created the sandbox or when a previous script
handed you a sandbox ID.
connect() resumes the snapshot and
returns a running sandbox handle. Use Sandbox.get_info_by_id("sb_...") for a
read-only lookup that does not wake paused work.
List
fields when you only need a compact response:
fields is set, the SDK returns raw dictionaries instead of a
SandboxPaginator.
Inspect
Sandbox.get_info_by_id("sb_..."). For metrics without a handle, use
Sandbox.get_metrics_by_id("sb_...").
Cleanup
Use a context manager for short-lived tasks:sandbox.kill() or Sandbox.kill_by_id("sb_...")
when the work is complete.