Skip to main content
A sandbox transitions between two long-lived states:
  • active - VM is running, processes executing, compute billed
  • paused - VM paused, state persisted to disk, no compute billed
You’ll briefly see pausing while a sandbox is being checkpointed and resuming while a paused sandbox is being restored to active. connect() and resume() wait a pause out for you; a pause still finishing after that wait answers 409 with code sandbox_pausing and a Retry-After header, so retry shortly. failed indicates the sandbox couldn’t boot or resume; the entry remains until you delete it. Deletion removes the sandbox entirely; further API calls return 404.

Pause

pause() checkpoints the full VM state (memory, processes, filesystem) to disk and stops billing for compute. It returns once the pause is accepted and the sandbox finishes pausing on its own; pass wait: true / wait=True to return once the sandbox is paused. A waited pause is a single request the server holds until the pause lands, so it costs no polling.

Resume

resume() restores a paused sandbox you already hold a reference to. Processes pick up where they left off.
A paused sandbox is auto-resumed by both Sandbox.connect() and commands.run().
After a resume, keep using the same sandbox — your commands and files calls keep working with no changes on your side.

Kill

kill() deletes the sandbox and all its resources. It’s idempotent - deleting an already-deleted sandbox is a no-op that swallows the 404.

Kill without an instance

In serverless contexts you often don’t have the sandbox - just the ID. Use killById / kill_by_id to delete it anyway.

Auto-pause

Set timeoutSeconds to auto-pause a sandbox after it has been active for that long. Pausing checkpoints its state and stops compute billing, so a sandbox you forget about won’t keep running and billing. It isn’t deleted; the next commands.run(), file operation, or connect() resumes it where it left off.
The timeout is scoped to the current active session:
  • It’s a cap on active time, not idle time. Running work doesn’t reset it, so a task still going when the window elapses is paused mid-run. Size it for your longest active session.
  • Each resume starts a fresh window.
  • The sandbox is paused, not deleted. Resume restores full memory and filesystem.
  • Leave it unset (the default) to disable auto-pause; the sandbox stays active until you pause or kill it.
Set or clear it on an existing sandbox:

Idle timeout

Set idleTimeoutSeconds to auto-pause a sandbox after this many seconds with no activity. Unlike timeoutSeconds, the idle timeout never pauses a sandbox while a request or connection to it is open. Use it for a sandbox that must stay active while someone works in it and stop billing when it goes quiet.
Requires SDK 0.11.6+ (@superserve/sdk and superserve), CLI 2.1.2+, and MCP 0.3.4+ (@superserve/mcp). Older TypeScript SDK versions ignore idleTimeoutSeconds and show no error.
These count as activity and keep the sandbox active:
  • A running command, including a commands.run() call that streams output for a long time.
  • An open terminal or command stream, even when nothing is typed.
  • File reads, writes, and directory listings, and saved-snapshot captures.
  • Desktop actions, such as screenshots, clicks, and typing.
  • Traffic to the sandbox’s preview URLs.
These don’t count as activity:
  • Outbound traffic from the sandbox, such as downloads or calls to other APIs.
  • A background process started with nohup or &. After the command that started it returns, the process does not keep the sandbox active.
  • CPU or disk activity on its own.
  • Changes to the sandbox’s settings, such as metadata or egress rules.
Background jobs and outbound-only workloads, such as an agent loop that only calls external APIs, do not keep the sandbox active. The idle timeout can pause the sandbox while this work runs. For this kind of work, use timeoutSeconds or leave the idle timeout unset.
The sandbox pauses shortly after the idle timeout expires. As with any pause, Superserve checkpoints the memory and filesystem, and the next commands.run(), file operation, or connect() resumes the sandbox where it stopped. Each resume restarts the idle count. The value can be 60 to 604800 seconds (7 days). By default, the idle timeout is unset, and the sandbox never pauses for being idle.
A raw HTTP request that uses X-Access-Token does not resume a paused sandbox. It fails with a 503 error (sandbox_unavailable). Call POST /sandboxes/{sandbox_id}/activate first, then send the request with the returned access token.
idleTimeoutSeconds and timeoutSeconds are independent. Whichever expires first pauses the sandbox. Use both to pause an inactive sandbox and also cap a session that never goes quiet. Set, clear, or read the idle timeout on an existing sandbox. When the idle timeout is off, the current value is undefined (TypeScript) or None (Python):
A new value takes effect immediately. If the new value is shorter than the time the sandbox has already been idle, the sandbox pauses shortly after the change.

Auto-delete

By default a paused sandbox is kept forever. Set autoDeleteSeconds to delete it once it has been continuously paused for that long. This suits short-lived or unattended sandboxes: scheduled jobs, one-off experiments, or agent sessions that never get an explicit kill().
The countdown is tied to the paused state:
  • Pause starts it and resume cancels it. Pausing again starts a fresh window, so a sandbox in use is never deleted.
  • 0 deletes the sandbox as soon as it pauses.
  • While paused, the sandbox’s info includes autoDeleteAt, the exact deletion time.
  • Maximum window: 30 days.
You can also set or clear the window on an existing sandbox:
Pair autoDeleteSeconds with timeoutSeconds or idleTimeoutSeconds: the timeout pauses the sandbox, then the auto-delete window cleans it up. A sandbox that never pauses is never auto-deleted.