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

# Authentication

> Log in to Danube and configure API keys for the CLI.

## Device Code Login

The simplest way to authenticate. Opens your browser to authorize the CLI:

```bash theme={null}
danube login
```

This displays a code like `AB12-CDEF`, prompts you to press Enter to open your browser, and waits for you to authorize. Once authorized, your API key is saved to `~/.danube/config.json`.

## Log in for an Organization

Pass `--org` with the organization's id or slug and the key the device flow mints belongs to that organization instead of to you:

```bash theme={null}
danube login --org acme
```

The terminal says which organization the key will belong to, and the person who authorizes the code in the browser must be a member of it (anyone else is refused). Every command you then run acts in that organization without a `danube-org-id` header: its internal tools are searchable, its shared credentials apply, its rate and spend caps count the calls, and its audit log records them. An owner or admin of the organization sees the key on the organization's tab of the API Keys page and can revoke it. `--org` applies to the device flow only; a key saved with `--api-key` already belongs to an organization. See [Organizations](/organizations/overview#organization-keys-and-limits).

## API Key Login

If you already have an API key (e.g. from the dashboard), save it directly:

```bash theme={null}
danube login --api-key YOUR_API_KEY
```

The key is validated against the API before saving.

## Environment Variable

Set `DANUBE_API_KEY` to skip the config file entirely. Ideal for CI/CD:

```bash theme={null}
export DANUBE_API_KEY=YOUR_API_KEY
danube search "send email"
```

## Per-Command Override

Pass `--api-key` on any command:

```bash theme={null}
danube search "send email" --api-key YOUR_API_KEY
```

## Config File

The CLI stores credentials in `~/.danube/config.json` (permissions `600`):

```json theme={null}
{
  "profiles": {
    "default": {
      "api_key": "YOUR_API_KEY"
    }
  }
}
```

## Named Profiles

Use profiles for multiple accounts:

```bash theme={null}
# Login to a named profile
danube login --profile work

# Use that profile
danube search "send email" --profile work

# Check which profile and organization the key acts with
danube whoami --profile work

# List all profiles
danube config profiles
```

## Priority Order

API key is resolved in this order:

1. `--api-key` flag (highest)
2. `DANUBE_API_KEY` environment variable
3. Config file (`~/.danube/config.json`)

## Commands

| Command | Description |
| - | - |
| `danube login` | Authenticate via browser device code flow |
| `danube login --org <id-or-slug>` | Device code flow for a key owned by an organization you belong to |
| `danube login --api-key YOUR_API_KEY` | Save an existing API key |
| `danube logout` | Remove stored credentials |
| `danube whoami` | Show the profile, organization and role, context document counts and timezone |

## Troubleshooting

<AccordionGroup>
  <Accordion title="'No API key found' error">
    Run `danube login` to authenticate, or set `DANUBE_API_KEY` environment variable.
  </Accordion>

  <Accordion title="Browser doesn't open during login">
    Copy the verification URL from the terminal output and open it manually.
  </Accordion>

  <Accordion title="Login times out">
    The device code expires after 10 minutes. Run `danube login` again to get a new code.
  </Accordion>

  <Accordion title="'This device asked to join an organization you are not a member of'">
    The browser session that entered the code belongs to an account outside the organization named by `--org`. Sign in as a member and enter the code again, or run `danube login` without `--org`.
  </Accordion>

  <Accordion title="'Organization not found' with --org">
    The id or slug matches no organization. The slug is the one in the dashboard's organization URL; `danube login --org` takes either form.
  </Accordion>
</AccordionGroup>


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