Skip to main content
Sandbox is the main entry point in the TypeScript SDK. All methods are async and return Promises. The constructor is private — use Sandbox.create() or Sandbox.connect().

Static methods

Sandbox.create()

Create a new sandbox and return a connected Sandbox instance.
SandboxOpts
Optional sandbox creation options. All fields are optional. See SandboxOpts for the full parameter list.
Returns Promise<Sandbox>

Sandbox.connect()

Connect to an existing sandbox by ID.
string
required
The sandbox ID to connect to. Must be alphanumeric with hyphens/underscores.
object
Optional: apiKey, domain, apiUrl, requestTimeout.
Returns Promise<Sandbox>

Sandbox.list()

List sandboxes with optional filtering and pagination.
Record<string, string>
Filter query parameters passed directly to the API.
number
Maximum number of sandboxes to return.
string
Pagination cursor from a previous list() call.
string
API key override.
string
Domain override.
number
Per-request HTTP timeout in milliseconds.
Returns Promise<{ sandboxes: SandboxInfo[]; nextToken?: string }>

Instance methods

sbx.kill()

Kill and destroy the sandbox. The sandbox ID becomes invalid after this call.
number
Per-request HTTP timeout in milliseconds.
Returns Promise<boolean>true if killed, false if already dead.

sbx.isRunning()

Check whether the sandbox is currently running.
number
Per-request HTTP timeout in milliseconds.
Returns Promise<boolean>

sbx.setTimeout()

Update the sandbox timeout.
number
required
New timeout in seconds.
number
Per-request HTTP timeout in milliseconds.
Returns Promise<void>

sbx.getInfo()

Fetch current metadata and state of the sandbox.
number
Per-request HTTP timeout in milliseconds.
Returns Promise<SandboxInfo>

sbx.getMetrics()

Retrieve CPU, memory, and disk usage metrics.
Date
Start of time range.
Date
End of time range.
number
Per-request HTTP timeout in milliseconds.
Returns Promise<SandboxMetrics[]>

sbx.pause()

Pause the sandbox.
number
Per-request HTTP timeout in milliseconds.
Returns Promise<void>

sbx.createSnapshot()

Create a snapshot of the sandbox.
number
Per-request HTTP timeout in milliseconds.
Returns Promise<SnapshotInfo>

sbx.getHost()

Return the URL that reverse-proxies HTTP traffic to the given port inside the sandbox. Requires allowPublicTraffic to be enabled in the sandbox’s network config (the default).
number
required
The port number to proxy to inside the sandbox.
Returns string

sbx.getMcpUrl()

Return the URL for an MCP server listening on port 50005 inside the sandbox. Equivalent to sbx.getHost(50005) + "/mcp".
Returns string

sbx.close()

Close the underlying HTTP client and release resources. Does not kill the sandbox.
Returns void

Properties


Automatic disposal

Sandbox implements Symbol.asyncDispose, so you can use the await using syntax from TypeScript 5.2+ for automatic cleanup:

Data models

SandboxInfo

SandboxState

SandboxMetrics

SandboxLifecycle

SnapshotInfo

SandboxQuery