Installation
- npm
- pnpm
- yarn
Quick Start
Core Features
Lifecycle Management
Manage the sandbox lifecycle, including renewal, pausing, and resuming.Custom Health Check
Define custom logic to determine whether the sandbox is ready/healthy. This overrides the default ping check used during readiness checks.Command Execution & Streaming
Execute commands and handle output streams in real-time.File Operations
Manage files and directories, including read, write, list/search, and delete.Endpoints
getEndpoint() returns an endpoint without a scheme (for example "localhost:44772"). Use getEndpointUrl() if you want a ready-to-use absolute URL (for example "http://localhost:44772").
Sandbox Management (Admin)
UseSandboxManager for administrative tasks and finding existing sandboxes.
Configuration
Connection Configuration
TheConnectionConfig class manages API server connection settings.
Runtime notes:
- In browsers, the SDK uses the global
fetchimplementation. - In Node.js, every
SandboxandSandboxManagerclones the baseConnectionConfigviawithTransportIfMissing(), so each instance gets an isolatedundicikeep-alive pool. Callsandbox.close()ormanager.close()when you are done so the SDK can release the associated agent.
- Basic
- Advanced
Sandbox Creation Configuration
Sandbox.create() allows configuring the sandbox environment.
Resource Cleanup
BothSandbox and SandboxManager own a scoped HTTP agent when running on Node.js so you can safely reuse the same ConnectionConfig. Once you are finished interacting with the sandbox or administration APIs, call sandbox.close() / manager.close() to release the underlying agent.
Browser Notes
- The SDK can run in browsers, but streaming file uploads are Node-only.
- If you pass
ReadableStreamorAsyncIterableforwriteFiles, the browser will fall back to buffering in memory before upload. - Reason: browsers do not support streaming
multipart/form-databodies with custom boundaries (required by the execd upload API).
API Reference
Sandbox
Main class for interacting with sandboxes.
Methods
static method
Creates and initializes a new sandbox instance.Parameters:
connectionConfig(ConnectionConfig): Connection configurationimage(string): Docker image to usetimeoutSeconds(number, optional): Sandbox lifetime in secondsentrypoint(string[], optional): Custom entrypointresource(object, optional): CPU/memory limitsenv(object, optional): Environment variablesmetadata(object, optional): Custom metadatanetworkPolicy(NetworkPolicy, optional): Network egress ruleshealthCheck(function, optional): Custom health check functionreadyTimeoutSeconds(number, optional): Readiness timeout
Promise<Sandbox>property
Access to command execution operations.Returns:
CommandsClientproperty
Access to file system operations.Returns:
FilesClientmethod
Extends the sandbox expiration time.Parameters:
timeoutSeconds(number): Extension duration in seconds
Promise<void>method
Pauses the sandbox (suspends all processes).Returns:
Promise<void>method
Resumes this paused sandbox.Returns:
Promise<Sandbox>method
Terminates the sandbox immediately.Returns:
Promise<void>method
Retrieves current sandbox information.Returns:
Promise<SandboxInfo>method
Gets the external endpoint for a port (without scheme).Parameters:
port(number): Internal port number
Promise<SandboxEndpoint>method
Gets the full URL for a port (with scheme).Parameters:
port(number): Internal port number
Promise<string>method
Releases the underlying HTTP agent (Node.js only).Returns:
Promise<void>Examples
Running a Node.js Script
Network Policy Example
Port Forwarding
Error Handling
TypeScript Support
The SDK is written in TypeScript and provides full type definitions.Next Steps
Python SDK
Explore the Python SDK
API Reference
Detailed API documentation
Examples
Browse more code examples
Configuration
Advanced configuration options