# Sandboxes (/docs/api/sandboxes)



## Creating a sandbox [#creating-a-sandbox]

```ts title="sandbox.ts"
const sandbox = await createSandbox({
  provider,
  cwd: "/workspace",
  env: { NODE_ENV: "development" },
  timeout: 300_000,
  signal: abortController.signal,
});
```

| Option     | Type                     | Default          | Behavior                                                      |
| ---------- | ------------------------ | ---------------- | ------------------------------------------------------------- |
| `provider` | `SandboxProvider`        | Required         | Adapter used to create the runtime.                           |
| `cwd`      | `string`                 | `/workspace`     | Absolute working directory for normalized paths and commands. |
| `env`      | `Record<string, string>` | `{}`             | Environment variables passed during creation.                 |
| `timeout`  | `number`                 | Provider default | Creation timeout in milliseconds.                             |
| `signal`   | `AbortSignal`            | None             | Cancels creation when supported by the provider.              |

`cwd` must be absolute and cannot contain a null byte.

## Sandbox properties [#sandbox-properties]

| Property       | Type                 | Description                                         |
| -------------- | -------------------- | --------------------------------------------------- |
| `id`           | `string`             | Provider or adapter identifier for this sandbox.    |
| `provider`     | `ProviderName`       | `local`, `e2b`, `daytona`, `vercel`, or `upstash`.  |
| `cwd`          | `string`             | Normalized working directory.                       |
| `capabilities` | `CapabilityMap`      | Supported operations and their modes.               |
| `raw`          | Provider-native type | Typed access to the underlying provider SDK object. |

## Stopping a sandbox [#stopping-a-sandbox]

```ts title="sandbox.ts"
await sandbox.stop();
await sandbox.stop(); // safe: stop is idempotent
```

## Read next [#read-next]

Write [files](/docs/api/files) or run [commands](/docs/api/commands).
