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

# Environments

> Define what a sandbox starts from: its image, limits, network policy, scripts, volumes, and who may use it.

An environment is the template a sandbox starts from. It sets the image, the resource limits, what the sandbox can reach on the network, and who may run code in it. Admins with **Manage Sandboxes** manage environments under **Settings → Sandbox → Environments**.

![The Environments tab listing each environment's image, network, resources and grants](https://mintcdn.com/bagofwords/jdi37jk3RbRDCvpb/images/sandboxes/environments-tab.png?fit=max\&auto=format\&n=jdi37jk3RbRDCvpb\&q=85\&s=de0ae4cf84e2452f6675d7826d3d6ad3)

BOW creates one environment for you, named **Default**: Python with common data packages, no network, and marked as the default. It is granted to no one until you choose who may use it.

## Create an environment

Select **New environment**.

![The New environment form](https://mintcdn.com/bagofwords/jdi37jk3RbRDCvpb/images/sandboxes/environment-form.png?fit=max\&auto=format\&n=jdi37jk3RbRDCvpb\&q=85\&s=ea312f740a67c22a8416fdecdc7fc7da)

| Field | What it sets |
| - | - |
| **Name**, **Description** | The agent reads the description when it chooses an environment, so say what the environment is for |
| **Image** | Any container image the compute can pull, for example `python:3.12-bookworm` or one from your own registry. For Node or Go work, use an image that has that toolchain |
| **CPUs**, **Memory (MB)**, **Disk (MB)** | Limits for each sandbox. They are also what a sandbox counts for against its compute's [capacity](https://docs.bow.ai/sandboxes/compute.md#capacity) |
| **Timeout (seconds)** | A single run is stopped when it passes this. At most 3600 |
| **Network policy** | What code in the sandbox can reach. See [below](#network-policy) |
| **Ask before a run** | Whether the person in the chat must allow a run first. See [below](#ask-before-a-run) |
| **Scripts** | Shell scripts BOW runs inside each sandbox. See [below](#scripts) |
| **Volumes** | Volumes of a compute, mounted in every sandbox of this environment. See [below](#volumes) |
| **Internal networks** | Internal addresses sandboxes may reach. See [Network and security](https://docs.bow.ai/sandboxes/network-and-security.md#internal-networks) |
| **Compute labels** | Sandboxes run only on computes that have every label listed. Empty: any compute |
| **Require strong isolation** | Run only on computes with gVisor |
| **Default environment** | Used when a report has not chosen an environment. Only one environment is the default |
| **Enabled** | A disabled environment cannot start new sandboxes |
| **Who may use it** | The roles, groups and people who can run code in this environment |

A change to an environment applies to sandboxes created after it. A sandbox that already exists keeps the limits and network policy it was created with; when the image or the setup script changed, it is marked **Old setup** in the list of sandboxes until it is deleted and created again.

## Network policy

| Policy | What the sandbox can reach |
| - | - |
| **No network** | Nothing. Packages cannot be installed; runs use what is in the image |
| **Allowed domains only** | Only the domains listed under **Allowed outbound connections** in the Sandbox settings. By default these are the pip, npm and Go package registries, so runs can install packages |
| **Full internet** | Any public address, over HTTP and HTTPS only |

Under every policy, internal hosts and private addresses stay out of reach unless the environment lists them under **Internal networks**. See [Network and security](https://docs.bow.ai/sandboxes/network-and-security.md).

> [!TIP]
>
> Start with **No network** or **Allowed domains only**. Code in a sandbox with **Full internet** can send whatever the agent passed into it to any site.

## Ask before a run

| Option | When the person is asked |
| - | - |
| **Never** | Runs start without asking |
| **Always** | Before every run |
| **Only with full internet access** | Before every run while the environment has the **Full internet** policy |
| **Only when the run installs packages** | Only before a run that installs packages |

The question appears in the chat with the code that would run, and **Allow** and **Deny**. A run nobody answers within four minutes does not happen. Deleting a sandbox always asks first, whatever this is set to.

## Scripts

| Script | When it runs |
| - | - |
| **Setup script** | Once, when a sandbox is created. If it fails, the sandbox is not created |
| **Start script** | On every start: when a sandbox is created and each time it is resumed. It has 120 seconds |
| **Stop script** | Before a sandbox is stopped or deleted. Best effort: it has 30 seconds, and a failure does not prevent the stop |

Use the setup script for what every sandbox needs, such as `pip install -r /data/requirements.txt`. Each script's output is in the sandbox's timeline.

If the setup or start script fails three times in a row, BOW refuses new sandboxes from that environment and shows the last error on its row. Change a script or the image and save, and it is tried again.

## Volumes

Select **Mount a volume** to mount a [compute's volume](https://docs.bow.ai/sandboxes/compute.md#volumes) in every sandbox of the environment. For each mount you choose the **Volume**, the **Path in the sandbox**, and:

* **Read-only**: code can read the volume but not change it.
* **Who sees what is written**: **Each report gets its own folder**, so a sandbox sees only what its own report wrote, or **Shared by every sandbox**.

> [!WARNING]
>
> With **Shared by every sandbox**, every sandbox of the environment can read and change what the others wrote, across reports and people. Use it only for data everyone who may use the environment is allowed to see.

Sandboxes of an environment with volumes run only on a compute that has all of them.

## Who may use it

Under **Who may use it**, pick the roles, groups and people who can run code in the environment. A person needs both the **Use Agent Sandbox** permission and a grant on at least one enabled environment before an agent is offered a sandbox for them.

Grant an environment that has internet access, internal networks or shared volumes only to the people who may reach those systems and see that data.

## Which environment a report gets

A report's sandbox is created from, in order:

1. The environment the agent chose for the run, if the person may use it.
2. The **Default environment** set under **Settings → Sandbox → Settings**.
3. The environment marked **Default environment**.
4. The only environment the person may use, when there is exactly one.

Only environments the person has been granted, and that are enabled, are considered. If none of these applies, the agent is told which environments it can choose from.

Once a report has a sandbox, it stays on that environment. To move a report to another environment, delete its sandbox; the next run creates a new one.

## Delete an environment

Deleting an environment stops reports from starting sandboxes from it. If sandboxes created from it still exist, you can delete them together with the environment. Anything in them is lost, except the files already saved to their reports.

## Related

* [Compute](https://docs.bow.ai/sandboxes/compute.md)
* [Network and security](https://docs.bow.ai/sandboxes/network-and-security.md)
* [Roles & permissions](https://docs.bow.ai/users/roles-and-permissions.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.