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

# Environments and organizations

> Set one network policy for every sandbox of a personal or organization environment, and roll a change out to running sandboxes.

## Set it

```bash CLI theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
boat env set base --network deny --inbound boat-only
boat env set base --network allow --allow github.com --allow '*.npmjs.org'
boat env set base --network none        # remove the policy
boat env info base
```

```bash curl theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
curl -sS -X PUT "$BOAT_API_BASE/environments/$ENV_ID" \
  -H "Authorization: Bearer $BOAT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"network":{"mode":"deny","inbound":"boat-only"}}'
```

```ts TypeScript theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
await sandbox.updateEnvironment({
  environmentId: envId,
  network: { mode: "deny", inbound: "boat-only" },
});
```

```python Python theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
from boat_sdk.models.environment_network_policy import EnvironmentNetworkPolicy
from boat_sdk.models.update_sandbox_environment_request import UpdateSandboxEnvironmentRequest

sandbox.update_environment(env_id, UpdateSandboxEnvironmentRequest(
    network=EnvironmentNetworkPolicy(mode="deny", inbound="boat-only"),
))
```

`$BOAT_API_BASE` is `https://boat.dev/api/v1`. Get `$ENV_ID` from `GET /environments`. In the API, `"network": null` removes the policy.

## Which policy applies

```text theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
Policy on the sandbox?      ─yes─▶ that policy
      │ no
Policy on its environment?  ─yes─▶ the environment's
      │ no
    open
```

`boat network get <id>` shows which one applies: `source` is `sandbox`, `environment` or `default`.

* When you set one side on a sandbox, the sandbox gets a policy of its own. It then stops following its environment.
* To follow the environment again, run `boat network set <id> environment`.
* `--no-env` and safe for third parties do not change the policy. The sandbox still follows its environment.

## Roll out a change

A saved change applies to sandboxes that start after it. To move the others, upgrade:

```bash theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
boat env upgrade base
```

| Sandbox | After the upgrade |
| - | - |
| Running, follows the environment | Has the new policy now |
| Stopped, follows the environment | Has the new policy before its next start |
| Has a policy of its own | Keeps it |

A sandbox that cannot take the policy stays as it is. The answer counts it in `failed` and gives the cause in `failures`. Read [Errors](https://docs.boat.dev/network-policy/reference.md#errors).

## Organization environments

Add `--org <org>` to the commands, or `?org=<org>` in the API.

```bash theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
boat env set agents --org acme --network allow --allow api.anthropic.com --allow github.com
boat --org acme new --environment agents
```

| Role | Can do |
| - | - |
| Owner or admin | Set the policy of the environment, and of any sandbox in it |
| Member | Use the environment. Their sandboxes follow its policy. |

While the environment sets a policy, a member cannot give a sandbox another policy. boat answers `403 network_policy_managed`. The same rule applies to a move to another environment, and to a new sandbox from a saved snapshot. One move is allowed: to an environment of the same organization that sets a policy.

> [!NOTE]
>
> An organization cannot force its members to use one environment. To keep members out of an environment, [limit who can use it](https://docs.boat.dev/organizations.md#limit-who-can-use-an-environment-or-profile).


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