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.
Optional sandbox creation options. All fields are optional. See
SandboxOpts for the full
parameter list.
Promise<Sandbox>
Sandbox.connect()
Connect to an existing sandbox by ID.
The sandbox ID to connect to. Must be alphanumeric with hyphens/underscores.
Optional:
apiKey, domain, apiUrl, requestTimeout.Promise<Sandbox>
Sandbox.list()
List sandboxes with optional filtering and pagination.
Filter query parameters passed directly to the API.
Maximum number of sandboxes to return.
Pagination cursor from a previous
list() call.API key override.
Domain override.
Per-request HTTP timeout in milliseconds.
Promise<{ sandboxes: SandboxInfo[]; nextToken?: string }>
Instance methods
sbx.kill()
Kill and destroy the sandbox. The sandbox ID becomes invalid after this call.
Per-request HTTP timeout in milliseconds.
Promise<boolean> — true if killed, false if already dead.
sbx.isRunning()
Check whether the sandbox is currently running.
Per-request HTTP timeout in milliseconds.
Promise<boolean>
sbx.setTimeout()
Update the sandbox timeout.
New timeout in seconds.
Per-request HTTP timeout in milliseconds.
Promise<void>
sbx.getInfo()
Fetch current metadata and state of the sandbox.
Per-request HTTP timeout in milliseconds.
Promise<SandboxInfo>
sbx.getMetrics()
Retrieve CPU, memory, and disk usage metrics.
Start of time range.
End of time range.
Per-request HTTP timeout in milliseconds.
Promise<SandboxMetrics[]>
sbx.pause()
Pause the sandbox.
Per-request HTTP timeout in milliseconds.
Promise<void>
sbx.createSnapshot()
Create a snapshot of the sandbox.
Per-request HTTP timeout in milliseconds.
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).
The port number to proxy to inside the sandbox.
string
sbx.getMcpUrl()
Return the URL for an MCP server listening on port 50005 inside the sandbox. Equivalent to sbx.getHost(50005) + "/mcp".
string
sbx.close()
Close the underlying HTTP client and release resources. Does not kill the sandbox.
void
Properties
| Property | Type | Description |
|---|---|---|
sbx.sandboxId | string | Unique sandbox identifier. |
sbx.config | ConnectionConfig | Connection config used by this instance. |
sbx.envdAccessToken | string | undefined | Access token for the in-VM envd service. |
sbx.sandboxDomain | string | undefined | Domain where the sandbox is accessible. |
sbx.trafficAccessToken | string | undefined | Token for traffic routing. |
sbx.commands | Commands | Commands sub-module. |
sbx.files | Filesystem | Filesystem sub-module. |
sbx.pty | Pty | PTY sub-module. |
Automatic disposal
Sandbox implements Symbol.asyncDispose, so you can use the await using syntax from TypeScript 5.2+ for automatic cleanup: