Create
on_timeout="pause", auto_resume=True when preview URL traffic should wake
a paused sandbox before forwarding the original request. auto_resume=True is
only valid with pause/hibernate timeout behavior.
Use a template warm pool for ready capacity before a burst:
warm_pool_mode="require" fails with warm_pool_unavailable when no matching
ready instance is available. Snapshot restore, resume, fork, hibernate, and
pause do not use template warm-pool checkout.
Inspect and connect
Sandbox.connect(id) is an explicit reconnect operation. If id currently
points at a paused snapshot, connect() resumes it and returns the running
sandbox execution. Sandbox.get_info_by_id(id) is read-only and does not wake a
paused sandbox.
Pass fields=["id", "status"] to Sandbox.list() or
Sandbox.get_info_by_id() for compact raw dictionaries instead of full model
objects. This is useful for dashboards and polling loops that only need a few
attributes.
Preview URLs and timeout
on_timeout="pause", auto_resume=True, HTTP and
websocket traffic to those preview URLs wakes the paused sandbox, waits for the
bounded resume window, and then forwards to the resumed execution. If
auto-resume is disabled or the wake does not complete in time, the preview URL
returns 503 Service Unavailable with Retry-After: 5.
Use sandbox.create_preview_proxy_target(8080) when your application proxy
should forward to Nullspace with x-nullspace-preview-proxy-token instead of
putting signed edge tokens in browser-visible URLs.
Use redact_preview_url(...) or redact_preview_token(...) before printing
preview credentials to logs or terminal output.
Lifecycle events
Usesandbox.stream_events() to tail lifecycle events related to one sandbox
without polling:
GET /v1/sandboxes/{id}/lifecycle/ws, reconnects
automatically, and resumes with after_event_id from the last yielded event.
Use live_only=True to skip the initial replay while still keeping reconnects
gap-resistant after the first event.
Shared volume data is external durable storage. Resume and fork remount shared
volume attachments, but do not make VM memory or mutable rootfs state portable
across incompatible runtime hosts.
One-shot runs
run_once for simple tasks where the SDK should create a sandbox, run the
code, and clean up without exposing a long-lived handle.
Async API
fields behavior as the
synchronous SDK.
Concepts: Create, Destroy,
Fork. API reference:
createSandbox, getSandbox,
getHost, setTimeout.