> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e2b.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Sandbox

## e2b sandbox

work with sandboxes

### Usage

```bash theme={"theme":"css-variables"}
e2b sandbox [options] [command]
```

**Alias:** `sbx`

## e2b sandbox connect

connect terminal to already running sandbox

### Usage

```bash theme={"theme":"css-variables"}
e2b sandbox connect [options] <sandboxID>
```

**Alias:** `cn`

### Arguments

* `<sandboxID>`: connect to sandbox with `<sandboxID>`

### Options

* `-u, --user <user>`: user to start the terminal session as
* `-c, --cwd <dir>`: working directory for the terminal session
* `-e, --env <KEY=VALUE>`: set environment variable for the terminal session (repeatable)

## e2b sandbox info

show information for a sandbox

### Usage

```bash theme={"theme":"css-variables"}
e2b sandbox info [options] <sandboxID>
```

**Alias:** `in`

### Arguments

* `<sandboxID>`: show information for sandbox specified by `<sandboxID>`

### Options

* `-f, --format <format>`: output format, eg. json, pretty (default: "pretty")

## e2b sandbox list

list all sandboxes, by default it list only running ones

### Usage

```bash theme={"theme":"css-variables"}
e2b sandbox list [options]
```

**Alias:** `ls`

### Options

* `-s, --state <state>`: filter by state, eg. running, paused. Defaults to running
* `-m, --metadata <metadata>`: filter by metadata, eg. key1=value1
* `-t, --template <template>`: filter by template ID or alias, eg. base
* `--started-after <date>`: filter by start time, only sandboxes started at or after this time are returned, eg. 2025-01-01T00:00:00Z
* `-o, --order <order>`: sort order by start time, asc or desc (default: desc)
* `-l, --limit <limit>`: limit the number of sandboxes returned (default: 1000, 0 for no limit)
* `-f, --format <format>`: output format, eg. json, pretty (default: "pretty")

## e2b sandbox kill

kill sandbox

### Usage

```bash theme={"theme":"css-variables"}
e2b sandbox kill [options] [sandboxIDs...]
```

**Alias:** `kl`

### Arguments

* `[sandboxIDs...]`: kill the sandboxes specified by \[sandboxIDs...]

### Options

* `-a, --all`: kill all sandboxes
* `-s, --state <state>`: when used with -a/--all flag, filter by state, eg. running, paused. Defaults to running
* `-m, --metadata <metadata>`: when used with -a/--all flag, filter by metadata, eg. key1=value1

## e2b sandbox pause

pause sandbox

### Usage

```bash theme={"theme":"css-variables"}
e2b sandbox pause [options] <sandboxID>
```

**Alias:** `ps`

### Arguments

* `<sandboxID>`: pause the sandbox specified by `<sandboxID>`

## e2b sandbox resume

resume paused sandbox

### Usage

```bash theme={"theme":"css-variables"}
e2b sandbox resume [options] <sandboxID>
```

**Alias:** `rs`

### Arguments

* `<sandboxID>`: resume the sandbox specified by `<sandboxID>`

## e2b sandbox create

create sandbox and connect terminal to it

### Usage

```bash theme={"theme":"css-variables"}
e2b sandbox create [options] [template]
```

**Alias:** `cr`

### Arguments

* `[template]`: create and connect to sandbox specified by \[template]. Defaults to base

### Options

* `-d, --detach`: create sandbox without connecting terminal to it
* `--lifecycle.ontimeout <action>`: action when sandbox timeout is reached: pause or kill
* `--lifecycle.autoresume`: enable sandbox auto-resume, requires --lifecycle.ontimeout pause
* `--timeout <seconds>`: sandbox timeout in seconds
* `-u, --user <user>`: user to start the terminal session as
* `-c, --cwd <dir>`: working directory for the terminal session
* `-e, --env <KEY=VALUE>`: set environment variable for the terminal session (repeatable)

## e2b sandbox logs

show logs for sandbox

### Usage

```bash theme={"theme":"css-variables"}
e2b sandbox logs [options] <sandboxID>
```

**Alias:** `lg`

### Arguments

* `<sandboxID>`: show logs for sandbox specified by `<sandboxID>`

### Options

* `--level <level>`: filter logs by level (DEBUG, INFO, WARN, ERROR). The logs with the higher levels will be also shown. (default: "INFO")
* `-f, --follow`: keep streaming logs until the sandbox is closed
* `--format <format>`: specify format for printing logs (json, pretty) (default: "pretty")
* `--loggers [loggers]`: filter logs by loggers. Specify multiple loggers by separating them with a comma.

## e2b sandbox metrics

show metrics for sandbox

### Usage

```bash theme={"theme":"css-variables"}
e2b sandbox metrics [options] <sandboxID>
```

**Alias:** `mt`

### Arguments

* `<sandboxID>`: show metrics for sandbox specified by `<sandboxID>`

### Options

* `-f, --follow`: keep streaming metrics until the sandbox is closed
* `--format <format>`: specify format for printing metrics (json, pretty) (default: "pretty")

## e2b sandbox exec

execute a command in a running sandbox

### Usage

```bash theme={"theme":"css-variables"}
e2b sandbox exec [options] <sandboxID> <command...>
```

**Alias:** `ex`

### Arguments

* `<sandboxID>`: sandbox ID to execute command in
* `<command...>`: command to execute

### Options

* `-b, --background`: run in background and return immediately
* `-c, --cwd <dir>`: working directory
* `-u, --user <user>`: run as specified user
* `-e, --env <KEY=VALUE>`: set environment variable (repeatable)

## e2b sandbox snapshot

work with sandbox snapshots

### Usage

```bash theme={"theme":"css-variables"}
e2b sandbox snapshot [options] [command]
```

**Alias:** `snap`

## e2b sandbox snapshot create

create a snapshot from a sandbox

### Usage

```bash theme={"theme":"css-variables"}
e2b sandbox snapshot create [options] <sandboxID>
```

**Alias:** `cr`

### Arguments

* `<sandboxID>`: create a snapshot from `<sandboxID>`

### Options

* `-n, --name <name>`: name for the snapshot template, reuses the existing template if it already exists

## e2b sandbox snapshot list

list snapshots

### Usage

```bash theme={"theme":"css-variables"}
e2b sandbox snapshot list [options] [sandboxID]
```

**Alias:** `ls`

### Arguments

* `[sandboxID]`: list only snapshots created from \[sandboxID]

### Options

* `-n, --name <name>`: filter by snapshot name or ID, optionally tag-qualified, eg. my-snapshot:v1
* `-l, --limit <limit>`: limit the number of snapshots returned (default: 1000, 0 for no limit)
* `-f, --format <format>`: output format, eg. json, pretty (default: "pretty")

## e2b sandbox snapshot delete

delete snapshots

### Usage

```bash theme={"theme":"css-variables"}
e2b sandbox snapshot delete [options] <snapshotIDs...>
```

**Alias:** `dl`

### Arguments

* `<snapshotIDs...>`: delete the snapshots specified by `<snapshotIDs...>`

## e2b sandbox fork

fork running sandbox into new sandboxes and print their IDs, one per line

### Usage

```bash theme={"theme":"css-variables"}
e2b sandbox fork [options] <sandboxID>
```

**Alias:** `fk`

### Arguments

* `<sandboxID>`: fork the sandbox specified by `<sandboxID>`

### Options

* `-n, --count <count>`: number of forks to create, at most 20 (default: 1)
* `--timeout <seconds>`: timeout of the forked sandboxes in seconds
