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:
OptionTypeDescription
namestringRequired. Human-readable sandbox name.
fromTemplate / from_templatestring | TemplateTemplate name, UUID, or Template instance to boot from. Defaults to superserve/base.
fromSnapshot / from_snapshotstringSnapshot UUID to boot from.
timeoutSeconds / timeout_secondsnumberAuto-pause after this many seconds of active time (per session; re-armed on resume). See Lifecycle.
autoDeleteSeconds / auto_delete_secondsnumberDelete the sandbox once continuously paused for this many seconds (max 30 days, 0 = delete on pause). See Lifecycle.
metadataRecord<string, string>String tags.
envVars / env_varsRecord<string, string>Env vars injected into every process.
secretsRecord<string, string>Bind secrets to env vars (ENV_VAR → secret name). The agent sees a stand-in token; the real credential is attached to outbound requests. See Secrets.
networkNetworkConfigEgress allow/deny rules.
apiKey / api_keystringOverrides SUPERSERVE_API_KEY.
baseUrl / base_urlstringOverrides SUPERSERVE_BASE_URL.
signalAbortSignalTypeScript only - abort the creation request.

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, autoDeleteSeconds, and/or timeoutSeconds 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.

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.
OptionTypeDescription
limitnumberMax events per page.
beforestringOpaque pagination cursor — pass the previous page’s nextCursor to page through results. Also accepts an RFC3339 timestamp as a time filter (rows strictly older than it).
sincestringRFC3339 — rows at or newer than this.
verdict"allowed" | "blocked" | "failed"Filter to connections with this verdict (excludes request rows).
NetworkLogPage has events (NetworkEvent[]), nextCursor / next_cursor, and hasMore / has_more.

Properties on sandbox

id, name, status, metadata, and secrets are read-only snapshots taken at construction. Call getInfo() / get_info() for fresh data.
PropertyTypeDescription
idstringUnique sandbox UUID.
namestringHuman-readable name.
statusSandboxStatusStatus at construction time.
metadataRecord<string, string>Tags at construction time.
secretsSandboxSecretBinding[] | undefinedBound secrets (envKeysecretName, with a revoked flag) at construction time.
commandsCommandsSee Commands.
filesFilesSee Files. Rebuilt after resume().

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.