Skip to main content

Installation


Sandbox

Static Methods

Sandbox.create(opts?): Promise<Sandbox>

Create a new sandbox.

Sandbox.connect(sandboxId, opts?): Promise<Sandbox>

Connect to an existing sandbox.

Sandbox.createFromCheckpoint(checkpointId, opts?): Promise<Sandbox>

Create a new sandbox from a checkpoint.

Sandbox.createCheckpointPatch(checkpointId, opts): Promise<PatchResult>

Create a patch for a checkpoint.

Sandbox.listCheckpointPatches(checkpointId, opts?): Promise<PatchInfo[]>

Sandbox.deleteCheckpointPatch(checkpointId, patchId, opts?): Promise<void>

Instance Methods

sandbox.kill(): Promise<void>

Terminate the sandbox.

sandbox.isRunning(): Promise<boolean>

Check if the sandbox is running.

sandbox.hibernate(): Promise<void>

Snapshot VM state and stop. No compute cost while hibernated.

sandbox.wake(opts?): Promise<void>

Resume a hibernated sandbox.

sandbox.setTimeout(timeout): Promise<void>

Update the idle timeout.

sandbox.createCheckpoint(name): Promise<CheckpointInfo>

Create a named checkpoint.

sandbox.listCheckpoints(): Promise<CheckpointInfo[]>

List all checkpoints for the sandbox.

sandbox.restoreCheckpoint(checkpointId): Promise<void>

Revert in-place to a checkpoint.

sandbox.deleteCheckpoint(checkpointId): Promise<void>

Delete a checkpoint.

sandbox.createPreviewURL(opts): Promise<PreviewURLResult>

sandbox.listPreviewURLs(): Promise<PreviewURLResult[]>

sandbox.deletePreviewURL(port): Promise<void>

Properties

Types

SandboxOpts

CheckpointInfo

PatchInfo

PatchResult

PreviewURLResult


Usage & Tags

Query billing-aligned usage, inspect per-sandbox memory points, and manage sandbox tags used for grouping. Full reference: Usage & Tags.
Preview: Usage and tag APIs are new. Endpoints, response fields, and SDK method names may change before GA; temporary inaccuracies or rough edges are possible while the surface settles.

usage.forSandbox(sandboxId, opts?): Promise<SandboxUsageResponse>

Return 1-minute allocated and used memory points for one sandbox. from and to accept ISO dates (YYYY-MM-DD) or RFC3339 timestamps; default window is the last hour.

usage.bySandbox(opts?): Promise<UsageBySandboxResponse>

Rank sandboxes by usage. Supports ISO date or RFC3339 from / to, filter, sort, limit, and cursor.

usage.byTag(tagKey, opts?): Promise<UsageByTagResponse>

Group usage by one tag key, with an untagged sibling bucket.

tags.set(sandboxId, tags): Promise<{ tags; tagsLastUpdatedAt }>

Replace the full tag set for a sandbox. {} clears all tags.

tags.get(sandboxId): Promise<{ tags; tagsLastUpdatedAt }>

Read the current tag set for a sandbox.

tags.listKeys(): Promise<TagKeyInfo[]>

List tag keys seen in the organization.
All *GbSeconds fields are GiB-seconds. For example, 4096 MiB provisioned for one minute reports 240 memoryAllocatedGbSeconds.

Agent

Accessed via sandbox.agent.

sandbox.agent.start(opts?): Promise<AgentSession>

Start an agent session.

sandbox.agent.attach(sessionId, opts?): Promise<AgentSession>

Reconnect to a running agent session. Accepts onEvent, onError, onExit, onScrollbackEnd.

sandbox.agent.list(): Promise<AgentSessionInfo[]>

List all agent sessions.

AgentSession

Types

AgentEvent

McpServerConfig


Exec

Accessed via sandbox.exec.

sandbox.exec.run(command, opts?): Promise<ProcessResult>

Run a command synchronously.

sandbox.exec.start(command, opts?): Promise<ExecSession>

Start a long-running command with streaming.

sandbox.exec.background(command, opts?): Promise<ExecSession>

Alias for start. Same signature and return type — use when the intent is “run this in the background and observe it”.

sandbox.exec.shell(opts?): Promise<Shell>

Open a stateful shell session whose cwd, env vars, and shell functions persist across .run() calls. Foreground-only. See the full reference.

sandbox.exec.attach(sessionId, opts?): Promise<ExecSession>

Reconnect to a running exec session.

sandbox.exec.list(): Promise<ExecSessionInfo[]>

List all exec sessions.

sandbox.exec.kill(sessionId, signal?): Promise<void>

Kill an exec session. Default signal: 9 (SIGKILL).

ExecSession

Types

ProcessResult

ExecSessionInfo


Filesystem

Accessed via sandbox.files.

sandbox.files.read(path): Promise<string>

Read a file as a UTF-8 string.

sandbox.files.readBytes(path): Promise<Uint8Array>

Read a file as raw bytes.

sandbox.files.write(path, content): Promise<void>

Write content to a file. Accepts string or Uint8Array.

sandbox.files.list(path?): Promise<EntryInfo[]>

List directory contents. Default path: "/".

sandbox.files.makeDir(path): Promise<void>

Create a directory (recursive).

sandbox.files.remove(path): Promise<void>

Delete a file or directory.

sandbox.files.exists(path): Promise<boolean>

Check if a path exists. Client-side wrapper — attempts a read and returns false on error.

Types

EntryInfo


Pty

Accessed via sandbox.pty.

sandbox.pty.create(opts?): Promise<PtySession>

Create an interactive terminal session.

PtySession


Image

Fluent, immutable builder for declarative sandbox images. Each method returns a new Image instance.

Image.base(): Image

Start from the default OpenSandbox environment (Ubuntu 22.04, Python, Node.js, build tools).

Builder Methods

image.toJSON(): ImageManifest

Returns the image manifest as a plain object.

image.cacheKey(): string

Computes a deterministic SHA-256 hash of the manifest for cache lookups.

Snapshots

Standalone class — not a property on Sandbox.

new Snapshots(opts?)

snapshots.create(opts): Promise<SnapshotInfo>

Create a pre-built snapshot from a declarative image.

snapshots.list(): Promise<SnapshotInfo[]>

List all snapshots for the current organization.

snapshots.get(name): Promise<SnapshotInfo>

Get a snapshot by name.

snapshots.delete(name): Promise<void>

Delete a snapshot. Existing sandboxes created from it are not affected.

Types

SnapshotInfo


Secret Stores

SecretStore.create(opts)

Create a new secret store.
CreateSecretStoreOpts
required
Returns: Promise<SecretStoreInfo>

SecretStore.list(opts?)

List all secret stores.
Returns: Promise<SecretStoreInfo[]>

SecretStore.get(storeId, opts?)

Get a secret store by ID.
string
required
UUID of the secret store.
Returns: Promise<SecretStoreInfo>

SecretStore.update(storeId, opts)

Partial updates — only the fields you pass are changed.
string
required
UUID of the store to update.
UpdateSecretStoreOpts
required
Returns: Promise<SecretStoreInfo>

SecretStore.delete(storeId, opts?)

Deletes the store and all its secrets. Running sandboxes are not affected.
Returns: Promise<void>

SecretStore.setSecret(storeId, name, value, opts?)

Set a secret in a store. Secrets are encrypted at rest. The value is never returned by the API.
Optionally restrict which hosts can receive this secret:
string
required
UUID of the secret store.
string
required
Secret name (used as the env var name in sandboxes).
string
required
Secret value (encrypted at rest, never returned by API).
Returns: Promise<void>

SecretStore.listSecrets(storeId, opts?)

Returns secret metadata only. Values are never exposed.
Returns: Promise<SecretEntryInfo[]>

SecretStore.deleteSecret(storeId, name, opts?)

Returns: Promise<void>

Creating a Sandbox with a Secret Store

Pass the secretStore option to Sandbox.create() to inject the store’s secrets:

Types

SecretStoreInfo

SecretEntryInfo