> ## 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.

# Inbound

> Let only boat connect to a sandbox, so code inside cannot make a port public. Publish a port yourself, from outside the sandbox.

| `inbound` | Dashboard | Who can connect |
| - | - | - |
| `open` (default) | Anyone | Anyone on the internet, on the ports that the sandbox opens |
| `boat-only` | boat only | Only boat, and the URLs that you publish from outside the sandbox |

By default, code with root in a sandbox can open a port to the internet. With `boat-only`, the host drops every connection that does not come from boat. **Code in the sandbox cannot make a port public.**

## Set it

```bash CLI theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
boat new --inbound boat-only
boat network set bx_f7k2q9hd --inbound boat-only
boat network set bx_f7k2q9hd --inbound open
```

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

```ts TypeScript theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
await sandbox.setNetworkPolicy({ sandboxId, inbound: "boat-only" });
```

```python Python theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
from boat_sdk.models.network_policy_request import NetworkPolicyRequest

sandbox.set_network_policy(sandbox_id, NetworkPolicyRequest(inbound="boat-only"))
```

* `inbound` is separate from the [outbound](https://docs.boat.dev/network-policy/outbound.md) mode. A request that names one side keeps the other side.
* A change to `boat-only` also ends the connections that are open to the sandbox.
* For many sandboxes, set it on an [environment](https://docs.boat.dev/network-policy/environments.md): `boat env set base --inbound boat-only`.

## What works with boat only

> [card] Works
>
> * `boat exec` and the [command API](https://docs.boat.dev/ssh-access.md#run-commands)
> * File read and write through the API
> * Snapshots, stop, resume and fork
> * A port that you [publish from outside](#publish-a-port)

> [card] Stops
>
> * `boat ssh`, `boat scp`, `boat forward` and editors over SSH
> * Desktop and browser streaming
> * Raw ports on the IP address of the sandbox
> * `host <port>` inside the sandbox
> * [Signed URLs for large files](https://docs.boat.dev/ssh-access.md#large-files)

Each of these answers `403 inbound_closed`. The sandbox has no URL of its own: `url` and `sshEndpoint` are `null`.

> [!WARNING]
>
> `boat-only` also stops your own SSH. Root in the sandbox decides what answers on the SSH port, so boat cannot leave that port open.

## Publish a port

With `boat-only`, only a caller **outside** the sandbox can publish a port.

| Caller | Can publish |
| - | - |
| Your session: the dashboard, or the CLI on your computer | Yes |
| An API key with the `host` action, used outside the sandbox | Yes |
| The `host` command, the `ASCII_TOKEN` and the API key in the sandbox | No |
| Any key, used inside a sandbox with outbound `deny` or `allow` | No |

```bash CLI theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
boat exec bx_f7k2q9hd --detach "python -m http.server 3000"
boat host bx_f7k2q9hd 3000
```

```bash curl theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
curl -sS -X POST "$BOAT_API_BASE/sandboxes/bx_f7k2q9hd/host" \
  -H "Authorization: Bearer $BOAT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"port":3000}'
```

* The answer is the public URL. It carries a token, as on an open sandbox. Read [Public URLs](https://docs.boat.dev/hosting).
* A published port stays through stop and resume.
* When you set `boat-only`, boat keeps the ports that you published from outside. It removes the others.
* A published URL uses a tunnel that the sandbox opens. Outbound `deny` and `allow` block that tunnel today. Use outbound `open` with a published port.

> [!WARNING]
>
> Do not put your account API key in a sandbox that runs untrusted code. With outbound `open`, code that holds it can publish a port: boat cannot tell that call from yours. With outbound `deny` or `allow`, boat refuses it.


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