Skip to main content

Installation

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)

Use SandboxManager for administrative tasks and finding existing sandboxes.

Configuration

Connection Configuration

The ConnectionConfig class manages API server connection settings. Runtime notes:
  • In browsers, the SDK uses the global fetch implementation.
  • In Node.js, every Sandbox and SandboxManager clones the base ConnectionConfig via withTransportIfMissing(), so each instance gets an isolated undici keep-alive pool. Call sandbox.close() or manager.close() when you are done so the SDK can release the associated agent.

Sandbox Creation Configuration

Sandbox.create() allows configuring the sandbox environment.

Resource Cleanup

Both Sandbox 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 ReadableStream or AsyncIterable for writeFiles, the browser will fall back to buffering in memory before upload.
  • Reason: browsers do not support streaming multipart/form-data bodies 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 configuration
  • image (string): Docker image to use
  • timeoutSeconds (number, optional): Sandbox lifetime in seconds
  • entrypoint (string[], optional): Custom entrypoint
  • resource (object, optional): CPU/memory limits
  • env (object, optional): Environment variables
  • metadata (object, optional): Custom metadata
  • networkPolicy (NetworkPolicy, optional): Network egress rules
  • healthCheck (function, optional): Custom health check function
  • readyTimeoutSeconds (number, optional): Readiness timeout
Returns: Promise<Sandbox>
property
Access to command execution operations.Returns: CommandsClient
property
Access to file system operations.Returns: FilesClient
method
Extends the sandbox expiration time.Parameters:
  • timeoutSeconds (number): Extension duration in seconds
Returns: 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
Returns: Promise<SandboxEndpoint>
method
Gets the full URL for a port (with scheme).Parameters:
  • port (number): Internal port number
Returns: 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