Skip to main content
Import the sandbox TypeScript SDK package @beadrun/sdk for async machine, command, file and account objects. Start with the quickstart.

Machines and options

Create options include template (default base), size, timeout (default 300), env, region, credentialProfile, kind, idle_timeout, autoPause and idempotencyKey. Size accepts a name or { vcpus, memoryMiB }. Memory restores require the source shape. Client options include apiKey, apiUrl, sandboxUrl, requestTimeout, operationTimeout, retries, retryDelay, pollInterval and fetch. Timeouts use seconds; polling defaults to one second. Region validates the deployment catalog; choose deployment through the API origin.

Commands

sb.commands.run is also available. Options include cwd, env, timeout, onStdout and onStderr. A nonzero exit is a result. Breaking a stream cancels reading, not necessarily remote execution.

Files and ports

Local filesystem access stays with your application. Port URLs use the server domain and may require sb.info.trafficAccessToken in e2b-traffic-access-token; the URL alone grants no access. Reserved ports are rejected.

Snapshots and parallel work

sb.snapshot({ name, retentionSeconds, inheritCredentials }) returns a Golden with id, info, wait() and delete(). Retained storage has its own lifetime.
Fleet.kill() deletes members. swarm.status() inspects the job and swarm.cancel() cancels it. A wait timeout keeps the job inspectable. BatchError.results preserves per-member typed errors and successful sandbox objects for explicit cleanup.

Account and agent resources

pricing.estimate(...) reads a cost estimate; limits() reads limits. new Bead().profiles exposes list(), put(id, name, material), revoke(id) and delete(id). sb.agent.prompt(...) yields runner events fetched through cursor pages; status() reads conversation state and interrupt(turnId) interrupts a turn. sb.desktop.screenshot() returns bytes. sb.browser.command(args) invokes the browser helper. Use supported templates and configured credentials; see coding agent runners.

Errors and retries

AuthenticationError, NotFoundError, TimeoutError, ProtocolError, LimitError, RateLimitError, PaymentRequiredError and BatchError extend BeadError. Preserve status, code and requestId. Limit errors expose limit; payment errors expose purchaseUrl. Creates, connects, pauses, resumes, sandbox deletions, snapshots, fleets and forks generate idempotency keys and retry selected transient failures. Reads also retry with bounded backoff. Snapshot deletion through Golden.delete() does not generate an idempotency key or automatically retry. Commands and prompts are not automatically replayed. Supply idempotencyKey on create for cross-process recovery.