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 resuming while a paused sandbox is being restored to active - 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.
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:
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: the timeout pauses the sandbox, then the auto-delete window cleans it up. A sandbox that never pauses is never auto-deleted.