Sandbox SDK
API Reference

Commands

Execute shell strings or argument arrays and inspect normalized results.

Running a command

commands.ts
const result = await sandbox.run("bun test", {
  timeout: 60_000,
  env: { CI: "true" },
});

if (!result.success) console.error(result.stderr);
Result fieldTypeDescription
stdoutstringCaptured standard output.
stderrstringCaptured standard error when the provider separates streams.
exitCodenumberProcess exit code.
successbooleantrue when exitCode is zero.
signalstring?Termination signal when reported by the provider.
durationMsnumber?Duration when measured or reported by the provider.

Nonzero exits return a result. Infrastructure failures, timeouts, and cancellation throw SandboxError.

Using argument arrays

arguments.ts
await sandbox.run({
  command: "bun",
  args: ["test", "--watch=false"],
});

Local and Vercel pass arrays directly without a shell. String-only provider APIs receive individually POSIX-quoted arguments.

Overriding command options

commands.ts
await sandbox.run("bun run build", {
  cwd: "packages/app",
  env: { NODE_ENV: "production" },
  timeout: 120_000,
  signal: abortController.signal,
});

Relative cwd values resolve against sandbox.cwd.

Use Processes for long-running work.

On this page