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

# auth

> DevHelm CLI auth commands — login, logout, token display, and context management

Manage CLI authentication. Log in interactively, switch between saved contexts, and inspect the current token.

## Commands

| Command                              | Description                                                |
| ------------------------------------ | ---------------------------------------------------------- |
| `devhelm auth login`                 | Authenticate and save credentials                          |
| `devhelm auth logout`                | Remove the active context                                  |
| `devhelm auth me`                    | Show API key identity, organization, plan, and rate limits |
| `devhelm auth token`                 | Display the current API token                              |
| `devhelm auth context`               | Show the active context                                    |
| `devhelm auth context create <name>` | Create a named context                                     |
| `devhelm auth context list`          | List all contexts                                          |
| `devhelm auth context use <name>`    | Switch to a context                                        |
| `devhelm auth context delete <name>` | Delete a context                                           |

## auth login

Authenticate interactively and save credentials to `~/.devhelm/contexts.json`. The token is validated against the API before saving — an invalid token exits with code `11` and saves nothing.

```bash theme={null}
devhelm auth login
```

Skip the interactive prompt by passing the token directly:

```bash theme={null}
devhelm auth login --token dh_live_xxxxxxxx --name production
```

| Flag      | Type   | Default   | Description                          |
| --------- | ------ | --------- | ------------------------------------ |
| `--token` | string | —         | API token (skips interactive prompt) |
| `--name`  | string | `default` | Context name to save under           |

## auth logout

Remove the active context from `~/.devhelm/contexts.json`. If other contexts remain, the first one becomes active.

```bash theme={null}
devhelm auth logout
```

## auth me

Show the API key identity, organization, plan tier, rate limits, and usage counters for the resolved token.

```bash theme={null}
devhelm auth me
```

```bash theme={null}
devhelm auth me -o json
```

## auth token

Display the resolved API token. Useful for piping into other tools:

```bash theme={null}
devhelm auth token
```

```bash theme={null}
export TOKEN=$(devhelm auth token)
curl -H "Authorization: Bearer $TOKEN" https://api.devhelm.io/api/v1/monitors
```

## auth context

### Show active context

```bash theme={null}
devhelm auth context
```

### Create a context

```bash theme={null}
devhelm auth context create staging \
  --token dh_live_xxxxxxxx \
  --api-url https://api.devhelm.io
```

| Flag            | Type    | Default                  | Description                                                                                                                              |
| --------------- | ------- | ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `--token`       | string  | —                        | API token (required)                                                                                                                     |
| `--api-url`     | string  | `https://api.devhelm.io` | API base URL for this context                                                                                                            |
| `--set-current` | boolean | `true`                   | Switch to this context immediately (always on — there is currently no `--no-set-current` variant; use `auth context use` to switch back) |

### List contexts

```bash theme={null}
devhelm auth context list
```

The active context is marked with `*`.

### Switch context

```bash theme={null}
devhelm auth context use production
```

### Delete a context

```bash theme={null}
devhelm auth context delete staging
```

## Next steps

<CardGroup cols={2}>
  <Card title="CLI authentication guide" icon="key" href="/cli/authentication">
    Token resolution order and best practices.
  </Card>

  <Card title="API keys" icon="lock" href="/cli/commands/api-keys">
    Create and manage API keys.
  </Card>
</CardGroup>
