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

> ## Agent Instructions
> Setting OneCLI up for your person? Follow https://onecli.sh/docs/quickstart.md. Never ask for or accept a key, token or password in the chat: OneCLI needs none.
> No OneCLI credential? Run `onecli connect`, or follow https://onecli.sh/auth.md. A person approves every new agent in their browser.
> Already connected? `onecli status`, `onecli items` and `onecli check <METHOD> <URL>` tell you what you can use. Full guide: https://onecli.sh/skill.md
> Search these docs over MCP at https://onecli.sh/docs/mcp. Report a wrong or unclear page with its `submit_feedback` tool.

# Connect agents that run in sandboxes

> Give an agent in an E2B, Daytona, boat, Modal or Vercel sandbox its own OneCLI credential, from your code or a terminal, with no key in the sandbox.

An agent in a sandbox connects to one vault, like any other agent. The sandbox gets its own agent credential and proxy settings, never a key. Your keys stay in the vault, and the gateway adds them to each call on the way out.

There are two ways to connect it:

| You | Use |
| - | - |
| Start sandboxes from your own code | The [TypeScript](https://onecli.sh/docs/sdks/node.md#an-agent-for-a-sandbox) or [Python](https://onecli.sh/docs/sdks/python.md#an-agent-for-a-sandbox) SDK. Your code makes an agent together with each sandbox. Pick your provider below. |
| Have one sandbox running, and a terminal where `onecli` is signed in | A one-use connect token and one line. See [From a terminal](#from-a-terminal). |

## Pick your provider

Each page has a full example in TypeScript and in Python, and the steps from a terminal.

> [card] [E2B](https://onecli.sh/docs/guides/sandboxes/e2b.md)
>
> `Sandbox.create` with `envs` and an outbound allow list.

> [card] [Daytona](https://onecli.sh/docs/guides/sandboxes/daytona.md)
>
> `daytona.v0.create` with the agent's environment and a domain allow list.

> [card] [boat](https://onecli.sh/docs/guides/sandboxes/boat.md)
>
> `boat.create` with `env` and an `allow` network policy.

> [card] [Modal](https://onecli.sh/docs/guides/sandboxes/modal.md)
>
> A sandbox with `env` and an outbound policy.

> [card] [Vercel Sandbox](https://onecli.sh/docs/guides/sandboxes/vercel-sandbox.md)
>
> A sandbox with `env` and a network policy.

> [card] [Another provider](#any-other-provider)
>
> What a provider needs to work with OneCLI.

## How it works

The names here are the TypeScript SDK's. The Python SDK has the same ones in snake case: `agent.allow_hosts`, `agent.setup_command`, and `agent.base_url(host)`.

**1. Make an agent for the sandbox**

`onecli.agents.create` makes an agent on one vault. Its answer holds everything the sandbox needs. The agent ends by itself after its lifetime: one hour unless you set another.

**2. Start the sandbox with the agent's settings**

Give the sandbox `agent.env` as its environment, and `agent.allowHosts` as its network allow list. `agent.env` holds the agent's credential, so don't log it.

**3. Run the setup line once**

Run `agent.setupCommand` in the sandbox. It writes the certificate files that `agent.env` points at. Until it has run, HTTPS calls in the sandbox fail with a certificate error.

From then on, HTTPS calls in the sandbox go through the gateway, which adds the vault's key for each host. When the work is done, stop the sandbox and call `agent.disconnect()`.

| Value | What it is |
| - | - |
| `agent.env` | The sandbox's environment: proxy settings, certificate paths and the agent's credential. |
| `agent.allowHosts` | The hosts the sandbox must reach: OneCLI's API and gateway. On OneCLI Cloud, `api.onecli.sh` and `gateway.onecli.sh`, both on port 443. |
| `agent.setupCommand` | One shell line to run once. It needs `sh`, `curl` and the system's root certificates (the `ca-certificates` package). It holds no secret. |
| `agent.baseUrl(host)` | A base URL on the gateway for one API, for a client that cannot use the proxy settings. See [Address form](https://onecli.sh/docs/guides/address-form.md). |
| `agent.disconnect()` | Ends the agent. Its credential stops working at once. |

The SDK pages for [TypeScript](https://onecli.sh/docs/sdks/node.md#an-agent-for-a-sandbox) and [Python](https://onecli.sh/docs/sdks/python.md#an-agent-for-a-sandbox) have every option: lifetimes, a vault by name, and which clients work through the gateway.

## Providers compared

The options are named as in each provider's TypeScript SDK. Each provider page has the Python names too.

| Provider | Environment | Allow list by host name | Its own key injection |
| - | - | - | - |
| [E2B](https://onecli.sh/docs/guides/sandboxes/e2b.md) | `envs` | `network.allowOut`, with all other traffic in `denyOut` | Secrets in network rules |
| [Daytona](https://onecli.sh/docs/guides/sandboxes/daytona.md) | `envVars` | `domainAllowList`, on Tier 3 and 4 only | Secrets with placeholder values |
| [boat](https://onecli.sh/docs/guides/sandboxes/boat.md) | `env` | `network: { mode: "allow" }` | The AI credentials proxy, for model keys and custom APIs |
| [Modal](https://onecli.sh/docs/guides/sandboxes/modal.md) | `env` | `outboundPolicy` with a `tls` route | Header replacements, in beta |
| [Vercel Sandbox](https://onecli.sh/docs/guides/sandboxes/vercel-sandbox.md) | `env` | `networkPolicy.allow` | Credentials brokering |

> [!NOTE]
>
> Behind an allow list by host name, Node's `http` and `https` modules, and clients built on them such as axios, fail: they send no host name to the gateway, so the allow list drops their calls. Give those clients `agent.baseUrl(host)`. `curl`, Node `fetch`, Python `requests`, `git`, `npm` and `pip` work through the proxy settings.

## Any other provider

A provider works with OneCLI when it can do three things:

1. Set environment variables for the sandbox, when it starts or for each command. Give it `agent.env`.
2. Let the sandbox reach `agent.allowHosts`. With no allow list, the sandbox reaches them anyway.
3. Run a shell line in the sandbox, with `sh`, `curl` and root certificates installed. Run `agent.setupCommand` there once.

An allow list by host name often opens only port 443, which is where OneCLI Cloud listens. If your self-hosted OneCLI serves its API or gateway on another port, allow its address by IP range instead.

For Docker, a server of your own, or CI, see [Docker, servers and CI](https://onecli.sh/docs/guides/servers-and-ci.md).

## Why OneCLI when a provider injects keys

Each provider above can also add a key to a sandbox's outgoing calls itself, as the table shows. Like OneCLI, the sandbox then never holds the key. If you use one provider and a few fixed keys, that can be enough.

What OneCLI adds:

* **One vault for every place your agents run:** any sandbox provider, your laptop, servers and CI. You add a key once, and moving to another provider changes nothing.
* **Permissions per item, and per tool for an app:** let a call through, ask a person first, or block it. See [Agent access](https://onecli.sh/docs/guides/agent-access.md).
* **Rules for the whole organization:** block, require approval, or limit the rate. See [Rules](https://onecli.sh/docs/guides/rules.md).
* **A log of every call** by every agent, allowed or blocked. See [Activity log](https://onecli.sh/docs/guides/activity-log.md).
* **App connections:** sign in to an app such as GitHub or Google once, and OneCLI renews its tokens. See [App connections](https://onecli.sh/docs/integrations/app-connections.md).
* **An agent per sandbox**, with its own credential that ends by itself or when you disconnect it.

## From a terminal

Use this to connect one sandbox that is already running, from a terminal where you are signed in. You make a one-use connect token, then run one line inside the sandbox. If your code starts the sandboxes, use your provider's page instead: the SDK makes an agent with each sandbox, with no token.

You need `onecli` 3.4 or later, signed in with `onecli login`. See the [Quickstart](https://onecli.sh/docs/quickstart.md).

### Make a connect token

Find the vault the agent should use:

```bash theme={null}
onecli vaults list
```

```json theme={null}
[
  {
    "id": "lhnojmifhyjqyshv",
    "name": "Personal",
    "slug": null,
    "personal": true,
    "item_count": 1,
    "agent_count": 0,
    "created_at": "2026-11-30T12:10:44.512Z",
    "last_used_at": null,
    "member_count": 1
  }
]
```

Make a token for that vault. Name the agent so you can tell your agents apart, and set the provider to a short label such as `e2b`, `daytona`, `boat` or `vercel`:

```bash theme={null}
onecli tokens create --vault lhnojmifhyjqyshv --name research-sandbox --provider e2b
```

```json theme={null}
{
  "id": "605ba657-1c5c-423f-ab62-7cfdf98751dd",
  "vault_id": "lhnojmifhyjqyshv",
  "name": "research-sandbox",
  "provider": "e2b",
  "created_at": "2026-12-01T14:58:22.013Z",
  "expires_at": "2026-12-01T15:13:22.004Z",
  "connect_token": "oc_connect_…",
  "connect_command": "onecli connect oc_connect_…",
  "install_command": "curl -fsSL https://api.onecli.sh/v1/install/connect | sh -s -- oc_connect_…"
}
```

The token works once, and expires after 15 minutes. `--expires-in` sets another time, from `1m` to `60m`. The token is a credential: pass it only to the sandbox it is for, and don't log or save it.

`install_command` needs only `sh` and `curl` in the sandbox. It writes `agent.env` (mode `0600`) and a line in the shell profile that reads it, so a new login shell sends its calls through OneCLI. Run it as the user the agent runs as.

### Give your machine access to the sandbox

You run `install_command` inside the sandbox with the vendor's own CLI. That needs your vendor account on this machine. Try these in order, and stop at the first one that works.

**1. Check whether this machine is signed in**

> [tab] E2B
>
> ```bash theme={null}
> e2b sandbox list --format json
> ```
>
> If `e2b` is missing, install it with `npm i -g @e2b/cli`.

> [tab] Daytona
>
> ```bash theme={null}
> daytona sandbox list --output json
> ```
>
> If `daytona` is missing, install it:
>
> ```bash theme={null}
> curl -fsSL https://github.com/daytona/clients/releases/latest/download/install.sh | sh
> ```

> [tab] boat
>
> ```bash theme={null}
> boat list --json
> ```
>
> If `boat` is missing, install it:
>
> ```bash theme={null}
> curl -fsSL https://boat.dev/install | sh
> ```

> [tab] Vercel Sandbox
>
> ```bash theme={null}
> sandbox list
> ```
>
> If `sandbox` is missing, install it with `npm i -g sandbox`.

A list, even an empty one, means this machine is signed in. Go to [Run the line in the sandbox](#run-the-line-in-the-sandbox).

**2. Sign in with your browser**

Run the vendor's sign-in in your own terminal. It opens your browser, and you type no key:

> [tab] E2B
>
> ```bash theme={null}
> e2b auth login
> ```

> [tab] Daytona
>
> ```bash theme={null}
> daytona login
> ```
>
> On a machine with no browser, run `daytona login --device`. It prints a link and a short code to use on any device.

> [tab] boat
>
> ```bash theme={null}
> boat login
> ```

> [tab] Vercel Sandbox
>
> ```bash theme={null}
> sandbox login
> ```

Then run the check from the first step again.

**3. If there is no browser sign-in, save a key in a file**

Make an API key in the vendor's dashboard. For E2B, that is [e2b.dev/dashboard?tab=keys](https://e2b.dev/dashboard?tab=keys). Then run this in your own terminal. It asks for the key without showing it, and saves it in a file only you can read:

> [tab] E2B
>
> ```bash theme={null}
> mkdir -p ~/.onecli && (umask 077; stty -echo; printf 'E2B API key: '; IFS= read -r key; stty echo; echo; printf '%s' "$key" > ~/.onecli/e2b.key)
> ```

> [tab] Daytona
>
> ```bash theme={null}
> mkdir -p ~/.onecli && (umask 077; stty -echo; printf 'Daytona API key: '; IFS= read -r key; stty echo; echo; printf '%s' "$key" > ~/.onecli/daytona.key)
> ```

> [tab] boat
>
> ```bash theme={null}
> mkdir -p ~/.onecli && (umask 077; stty -echo; printf 'boat API key: '; IFS= read -r key; stty echo; echo; printf '%s' "$key" > ~/.onecli/boat.key)
> ```

From then on, start each vendor command with the key read from the file, so the key never shows on screen:

```bash theme={null}
E2B_API_KEY="$(cat ~/.onecli/e2b.key)" e2b sandbox list --format json
DAYTONA_API_KEY="$(cat ~/.onecli/daytona.key)" daytona sandbox list --output json
```

For boat, sign the CLI in with the key once, from the file:

```bash theme={null}
boat login --key-stdin < ~/.onecli/boat.key
```

Vercel Sandbox has no key step: `sandbox login` prints a link you can open on any device.

Never put the key in a command as text. Once the agent is connected, you can remove the file, for example `rm ~/.onecli/e2b.key`.

> [!WARNING]
>
> If a coding agent sets this up for you, it never needs your vendor key. Run the sign-in or the key prompt in your own terminal. If you paste a key into a chat by mistake, delete it at the vendor and make a new one.

### Run the line in the sandbox

Pick the running sandbox the agent works in from the list. To start a new one:

> [tab] E2B
>
> ```bash theme={null}
> e2b sandbox create --detach
> ```

> [tab] Daytona
>
> ```bash theme={null}
> daytona sandbox create --name onecli-agent
> ```

> [tab] boat
>
> ```bash theme={null}
> boat new
> ```
>
> It prints the new sandbox's id.

> [tab] Vercel Sandbox
>
> ```bash theme={null}
> sandbox create --name onecli-agent --timeout 45m
> ```
>
> A Vercel sandbox stops after 5 minutes unless you set `--timeout`. 45 minutes is the most on the Hobby plan.

Run `install_command` there, as it is, in place of `<install_command>`:

> [tab] E2B
>
> ```bash theme={null}
> e2b sandbox exec <sandbox-id> "<install_command>"
> ```

> [tab] Daytona
>
> ```bash theme={null}
> daytona sandbox exec <sandbox-id> -- sh -c '<install_command>'
> ```

> [tab] boat
>
> ```bash theme={null}
> boat exec <sandbox-id> -- sh -c '<install_command>'
> ```

> [tab] Vercel Sandbox
>
> ```bash theme={null}
> sandbox exec onecli-agent -- sh -c '<install_command>'
> ```

For Modal, start the sandbox from your code instead, as in [Modal](https://onecli.sh/docs/guides/sandboxes/modal.md).

### Check the agent is connected

```bash theme={null}
onecli agents list --mine
```

```json theme={null}
[
  {
    "id": "3a7c9e1f-5b2d-4c8a-b6e4-0f9d2a1c7b35",
    "name": "research-sandbox",
    "vault_id": "lhnojmifhyjqyshv",
    "runtime": "linux",
    "provider": "e2b",
    "status": "active",
    "created_at": "2026-12-01T15:01:47.326Z",
    "expires_at": null,
    "last_seen_at": "2026-12-01T15:01:47.326Z",
    "created_by": {
      "via": "connect",
      "person": "Dana Levi",
      "key_name": "onecli login on a terminal"
    },
    "kind": null,
    "vault_name": "Personal"
  }
]
```

Then make the same call twice inside the sandbox, with your provider's exec command as above. Around OneCLI, it answers `401`:

```bash theme={null}
curl --noproxy '*' -s -o /dev/null -w "%{http_code}\n" https://httpbin.org/bearer
```

Through OneCLI, it answers `200`, because the gateway added the Test key. A login shell reads the proxy settings that connecting wrote:

```bash theme={null}
sh -lc 'curl -s -o /dev/null -w "%{http_code}\n" https://httpbin.org/bearer'
```

Start the agent from a login shell too, so its calls go through OneCLI.

### When something fails

| What you see | What to do |
| - | - |
| `You must be logged in` from `e2b`, `not logged in` from `daytona`, or a sign-in prompt from `boat` or `sandbox` | Sign in, as in [Give your machine access](#give-your-machine-access-to-the-sandbox). |
| The agent is not in `onecli agents list --mine` | The line did not run, or the token expired. Make a new token and run its line again. |
| `401` through OneCLI | The vault has no item for this host. Add one to the vault in the dashboard. |

## Next steps

* [An agent for a sandbox, in the TypeScript SDK reference](https://onecli.sh/docs/sdks/node.md#an-agent-for-a-sandbox)
* [An agent for a sandbox, in the Python SDK reference](https://onecli.sh/docs/sdks/python.md#an-agent-for-a-sandbox)
* [Disconnect an agent or revoke a token](https://onecli.sh/docs/cli/onecli-cli.md#connect-tokens)
* [Connect Docker, a server or CI](https://onecli.sh/docs/guides/servers-and-ci.md)
* [Set what agents may do with each item](https://onecli.sh/docs/guides/agent-access.md)


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