Skip to main content
The Sandbox class is the main entry point for the SDK. Python ships both a sync Sandbox and an AsyncSandbox with identical method names.

Import

Authentication

The SDK reads SUPERSERVE_API_KEY from the environment by default. Pass apiKey / api_key explicitly to override, and baseUrl / base_url to target a different control-plane URL.

Factory methods

Sandbox.create

Create and boot a new sandbox. Synchronous - when the promise resolves, the VM is active.
Options:

Sandbox.connect

Reconnect to an existing sandbox by ID. Returns a live sandbox with a fresh access token. If the sandbox is currently paused, it is auto-resumed before returning so it’s immediately usable.

Sandbox.list

List sandboxes on the authenticated team. metadata filters combine with AND.
Returns an array of SandboxInfo.

Sandbox.killById / Sandbox.kill_by_id

Delete a sandbox by ID without instantiating it. Idempotent.

Sandbox.updateById / Sandbox.update_by_id

Update a sandbox by ID without instantiating it. Unlike connect(id) followed by update(...), this does not resume a paused sandbox — so it’s the right way to arm auto-delete or change the auto-pause timeout on a box you want to leave paused. Same fields and clear-with-null/None semantics as update.

Methods on sandbox

getInfo / get_info

Fetch the current server-side state. Returns a fresh SandboxInfo - the returned sandbox’s own status / metadata properties are snapshots and are not mutated.

pause

Checkpoint the VM state to disk. The sandbox transitions to paused. Returns nothing.

resume

Restore a paused sandbox. The backend rotates the per-sandbox access token; the SDK re-injects it into sandbox.files transparently.

kill

Delete the sandbox. Idempotent - swallows 404.

update

Patch metadata, network, lifecycle windows, and/or the default access for newly published preview ports on a sandbox.
On an already-paused sandbox, arming autoDeleteSeconds starts the countdown from the moment of the call — never retroactively from when the sandbox paused. See Lifecycle. Moving a compatibility sandbox onto public or private closes every unpublished port. See Preview URLs for the safe publication and migration flow. Changing between public and private later does not rewrite the access mode of ports that are already published.

Preview URL methods

Preview URLs use an explicit published-port allowlist. The URL builder alone does not publish or authenticate a port. See the Preview URLs guide for policy selection, machine headers, browser cookies, and revocation examples.

attachSecret / attach_secret

Bind a team secret to a live or paused sandbox under an environment variable. The sandbox sees a stand-in token; the real credential is swapped in for outbound requests to the secret’s allowed hosts. Takes effect for processes started after the call; a paused sandbox applies it on resume.

detachSecret / detach_secret

Remove a secret binding by its environment-variable key. The stand-in token is revoked, so requests using it are refused — within about a minute for a process already running. A paused sandbox applies the change on resume.

getNetworkLog / get_network_log

The sandbox’s network log — every outbound connection and secret-bearing request, newest first. Returns a NetworkLogPage. See the Network log guide for the full model.
NetworkLogPage has events (NetworkEvent[]), nextCursor / next_cursor, and hasMore / has_more.

Properties on sandbox

id, name, status, metadata, previewAccess / preview_access, and secrets are read-only snapshots taken at construction. Call getInfo() / get_info() for fresh data.

Types

SandboxStatus

  • active - running and ready to accept commands
  • paused - stopped with state saved to disk
  • resuming - transient, briefly visible while a paused sandbox is being restored to active (retry shortly)
  • failed - the sandbox couldn’t boot or resume; the entry remains until you delete it
Deletion removes the sandbox entirely - subsequent API calls return 404.

SandboxInfo

NetworkConfig

Retries

GET and DELETE requests auto-retry on 429, 502, 503, 504, and network errors with exponential backoff + jitter (3 attempts max). POST and PATCH are not retried - the SDK surfaces the error so you can decide. See Errors.

Errors

Sandbox methods commonly raise:
  • AuthenticationError - missing or invalid API key
  • ValidationError - bad request body
  • NotFoundError - sandbox doesn’t exist (except kill / killById, which swallow 404)
  • ConflictError - wrong state (e.g., pausing an already-paused sandbox, or patching network while paused)
  • ServerError - platform error
See Errors for the full hierarchy.