Skip to content

Sandboxes

from svm import Sandbox
sandbox = Sandbox.create(
template="base",
cpu_count=2,
memory_mb=1024,
timeout_seconds=600,
metadata={"project": "docs", "step": "lifecycle"},
)
try:
info = sandbox.get_info()
print(info.sandbox_id, info.state, "ends at", info.end_at)
sandbox.set_timeout(1800) # 30 minutes from now
page = Sandbox.list(state=Sandbox.LIVE_STATES, metadata={"project": "docs"})
for found in page.items:
print("found", found.id, found.state)
same = Sandbox.connect(sandbox.id) # a second handle, e.g. from another process
print(same.commands.run("uptime").stdout)
finally:
sandbox.kill()
Option Default Notes
template base A catalog template, or one you built. See Templates.
cpu_count, memory_mb the template’s Billed while the sandbox runs.
disk_mb the template’s root size The disk is grown as the sandbox starts. Give a template that installs packages room to work.
timeout_seconds 300 Lifetime from now, capped by your plan (at most 7 days).
metadata none String pairs. list filters on them.
envs none Environment variables for every command.
lifecycle kill at timeout on_timeout: pause keeps it. auto_resume controls whether traffic wakes a paused sandbox. See Persistence.
secure true Public URLs need the traffic access token. See Networking.
mcp_servers none Catalog MCP servers to turn on. See Agent tools.

Any process with the id can connect. It fetches fresh data-plane access, and it resumes the sandbox first if it was paused. connect returns once the sandbox runs; pass wait=False (in your SDK’s spelling) to return as soon as the resume is accepted.

list returns one page with items and a next_page_token. Listed sandboxes carry no access credentials, so connect to one before you use it.

base is always there, even when your team has built nothing, and even though a template list does not include it. It carries Python, Node.js, git, gh, tmux, ripgrep, jq and a compiler. The language templates (python, node, go) are slim. For example, python has no ps, so use commands.list() to look for processes.