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

# Authentication

> Log in once through the browser, or mint API keys for CI, scripts, and agents.

The CLI authenticates you once through the browser and stores the credentials locally. CI pipelines, scripts, and agents skip the browser with a token or a long-lived [API key](#api-keys).

## Log in

```bash theme={"theme":"github-dark"}
boxd auth login                # opens browser for one-time device login
boxd auth                      # show your identity and the orgs you belong to
boxd auth logout               # remove stored credentials
```

Any command that needs auth auto-starts the login flow if no credentials are found, so on a fresh install you can run any command and log in on the way.

You log in once, and the login works in every [region](https://docs.boxd.sh/guides/regions.md) your org uses. The same goes for API keys.

## Tokens

Authenticate a single invocation with a token, overriding stored credentials:

```bash theme={"theme":"github-dark"}
boxd --token=<token> machine list      # pass token directly
BOXD_TOKEN=<token> boxd machine list   # or via env var
```

## API keys

For CI pipelines, scripts, or agent integrations where the browser login flow is not an option, mint long-lived API keys under `boxd auth keys`. The raw value is shown **only once**, at creation time.

```bash theme={"theme":"github-dark"}
boxd auth keys create <name>                          # mint a new key, raw value to stdout
boxd auth keys create <name> --expires-in-secs=86400  # with an expiry (1 day in this example)
boxd auth keys create <name> --org acme               # fence the key to a specific org
boxd auth keys create <name> --kind org               # userless service credential (org admin only)
boxd auth keys list                                   # id, name, prefix, org, kind, created-by, last-used, expires (alias: ls)
boxd auth keys remove <name>                          # revoke a key by name or id (alias: rm)
```

Every key is fenced to **one organization** and never grants account-wide access. Without `--org`, the key is fenced to your active org context. `--kind member` (the default) acts as you within that org. `--kind org` is a userless service credential limited to the org's shared machines, and creating one requires org admin.

A `--kind org` key keeps working after the person who made it leaves the org, so CI doesn't break when someone moves on. That's why every admin of the org sees the org's `--kind org` keys in `boxd auth keys list`, whoever made them, and can revoke them with `boxd auth keys remove`. A member key is listed only for the person who made it.

`keys create` writes the raw `bxd_…` value to stdout, while the warning, id, and expiry go to stderr. To put it straight into a GitHub secret without copy and paste:

```bash theme={"theme":"github-dark"}
KEY=$(boxd auth keys create "gh-actions deploy owner/repo")
gh secret set BOXD_API_KEY --repo owner/repo --body "$KEY"
```

The key never lands in shell history or scrollback.

`--json` mode is also available for scripting:

| Command | JSON shape |
| - | - |
| `auth keys create --json` | `{"id", "api_key", "expires_at"}` (`expires_at: 0` = no expiry) |
| `auth keys list --json` | `[{"id", "name", "prefix", "org", "kind", "created_by", "last_used", "expires"}, …]` (`created_by` is `"you"` for your own keys) |

## Machine tokens

A machine token is a short-lived credential that acts only on the machines you name. Hand one to code you don't fully trust, such as an eval worker or an agent, instead of an API key. Machine tokens need CLI 0.3.7 or SDK 0.3.4 or later.

```bash theme={"theme":"github-dark"}
boxd machine token <machine>                   # mint a token for one machine, valid 1 hour
boxd machine token <machine> <machine>         # several machines, all in one org
boxd machine token <machine> --expires-in 2h   # longer lifetime: 3600, 90m, 2h, ... (at most 24h)
```

`machine token` writes the raw `bxdm_…` value to stdout, once. The holder uses it like any other [token](#tokens), or as `token` in the SDKs:

```bash theme={"theme":"github-dark"}
TOKEN=$(boxd machine token <machine>)
BOXD_TOKEN=$TOKEN boxd machine exec <machine> -- python run.py
```

With the token, a client can run commands, copy files, start and stop the machines, and change their settings. It can't delete them, create or fork machines, change networks, egress or secrets, see other machines, or manage the account. A token minted with an API key never outlives that key, and revoking the key ends the token.

> [!WARNING]
>
> A command the token runs inside a machine has what any process in that machine has. On a machine that isn't isolated, that includes the machine's own boxd access, which reaches the rest of the org. For code you don't trust, use [isolated machines](https://docs.boxd.sh/cli/commands.md#networks) (`boxd machine new --isolated`).

## Org context

Every account works inside an org, and every user has a default org of their own. Your active **context** decides which org a new machine is billed to and which machines `list` and `connect` see.

```bash theme={"theme":"github-dark"}
boxd auth                        # identity + the orgs you belong to (active context marked)
boxd auth switch acme            # work in the "acme" org context (multi-word names need no quotes)
```

The active org context is a **per-device** selection. `boxd auth switch` writes it locally, and each surface (this CLI, the console, other devices) keeps its own. Your default org is a normal org in the list, so you switch back to it by name like any other, and an unset context shows as `(default)`. To run one invocation in a specific org without switching, pass `--org`.

Sharing machines with the org happens on the machine side. See [Organizations](https://docs.boxd.sh/cli/commands.md#organizations) in the command reference.

## Next steps

You are logged in. Head to the full [command reference](https://docs.boxd.sh/cli/commands.md).


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