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

# Authentication

> Operator login and credential management for the Esper CLI.

## API key flow

For most CLI and hybrid runtime usage, initialize the workspace with a
tenant-scoped API key:

```bash theme={null}
esper init \
  --api-base https://api.esperr.com \
  --api-key <secret> \
  --tenant-id <tenant-id>
```

The CLI sends configured API keys with `x-esper-api-key`. When `api_key` is set
in `~/.esper/config.yaml`, it takes precedence over stored operator-token
credentials.

## Hosted token flow

Use hosted token login when you need an operator session, such as listing keys
for a tenant:

```bash theme={null}
esper auth login --token <jwt>
esper auth whoami
esper keys list
```

## Checking authentication

Verify the current stored token or configured API key:

```bash theme={null}
esper auth whoami
```

## Logout

Clear stored credentials:

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