---
title: luna sandboxes
description: List the sandboxes an environment's lunas have, and stop or delete one by hand.
related:
  - /files-and-code/run-a-sandbox
  - /develop/browse-a-lunas-data
  - /cli/data
---

`luna sandboxes` lists the sandboxes your lunas have, running or kept, and stops or deletes one.

```bash
luna sandboxes list
```

## Reference

```bash
luna sandboxes <COMMAND>
```

`luna sandbox` is the same command. Every subcommand acts on one environment, and takes these options.

| Option | Type | Default | Does |
| --- | --- | --- | --- |
| `--dir <DIR>` | path | `.` | The app's folder. Its env file names the project and environment. |
| `--env <ENV>` | text | `LUNA_ENV`, then `production` | The environment, by name. |
| `--project <PROJECT>` | text | `LUNA_PROJECT` | The project, by name or as `organisation/project`. |
| `--tenant <TENANT>` | text | The environment's own | A tenant added to the environment, by name. |
| `--token <TOKEN>` | text | `LUNA_TOKEN`, then your login | An API token or account key to act with. |

### luna sandboxes list

Prints every sandbox: those running, and those kept while asleep or frozen. Each row gives its luna's type and key, its name, state, size, disk used and when it was last used.

```bash
luna sandboxes list [OPTIONS] [TYPE]
```

| Option | Type | Default | Does |
| --- | --- | --- | --- |
| `[TYPE]` | text | Every type | Lists only the sandboxes of lunas of this type. |
| `--json` | flag | Off | Prints the answer as JSON. |

### luna sandboxes stop

Powers a running sandbox off, as its luna's code stopping it would. Its processes end and its disks are kept. The next request its luna makes of it boots it again.

```bash
luna sandboxes stop [OPTIONS] <TYPE> <KEY> <NAME>
```

| Option | Type | Default | Does |
| --- | --- | --- | --- |
| `<TYPE>` | text | Required | The type of the luna that has the sandbox. |
| `<KEY>` | text | Required | The luna's key. |
| `<NAME>` | text | Required | The sandbox's name, as its luna's code names it. |

### luna sandboxes delete

Stops a sandbox if it runs, and deletes it with its disks. It asks first. `luna sandboxes rm` is the same subcommand.

```bash
luna sandboxes delete [OPTIONS] <TYPE> <KEY> <NAME>
```

| Option | Type | Default | Does |
| --- | --- | --- | --- |
| `<TYPE>` | text | Required | The type of the luna that has the sandbox. |
| `<KEY>` | text | Required | The luna's key. |
| `<NAME>` | text | Required | The sandbox's name. |
| `--yes` | flag | Off | Deletes without asking. |

## Good to know

- A key with one field is given as its value, such as `u_42`. A key with several fields is given as JSON, such as `'{"board":"b1","card":"c7"}'`.
- A sandbox's state is `running`, `frozen` or `asleep`. A stopped one also says what stopped it: `idle`, `code`, `luna`, `api` or `crash`.
- A sandbox that keeps nothing, with `persist: "none"`, is listed only while it runs.
- `list` prints at most 1000 sandboxes, and says when there are more.
- After a delete, its luna's next request of the sandbox makes a new, empty one.
- `list` needs the `data:read` scope. `stop` and `delete` need `data:write`.
- Without a terminal to ask at, `delete` stops with exit code 6 unless you pass `--yes`.

:::warning
`delete` removes the sandbox's disks with it. Nothing of it is kept, and it cannot be undone.
:::

## Examples

### List the sandboxes of one type

```bash
luna sandboxes list User
```

### Stop a sandbox

```bash
luna sandboxes stop User u_42 workspace
```

### Delete a sandbox in a script

```bash
luna sandboxes delete User u_42 workspace --yes
```
