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

# kanari login

> Authenticate and save your API key to ~/.kanari/config

## Overview

`kanari login` authenticates you with the Kanari backend via a magic link sent to your email. After verification, the API key is saved automatically to `~/.kanari/config` so you don't need to set environment variables manually.

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

***

## How it works

1. You enter your email address
2. Kanari sends you a magic link
3. You click the link in your email — the browser shows "Verified!"
4. The terminal receives the confirmation and saves your API key

```
$ kanari login
Enter your email: you@company.com
✓ Magic link sent — check your inbox
  Waiting for verification...  (Ctrl+C to cancel)

✓ Authenticated!
  API key: sk_a1b2c3...
  Saved to ~/.kanari/config

  Next step: kanari agent
```

***

## Flags

| Flag | Default | Description |
| - | - | - |
| `--api-url` | `https://api.getkanari.com` | Backend URL. Use `http://localhost:8000` for local dev |

***

## After login

Once authenticated, all Kanari commands automatically use the saved API key — no need to set `KANARI_API_KEY` or pass `--token`:

```bash theme={null}
kanari agent            # uses ~/.kanari/config automatically
kanari alerts configure --slack-webhook https://...
```

The saved config is at `~/.kanari/config` and is readable only by your user (`chmod 600`):

```yaml theme={null}
api_key: sk_a1b2c3d4...
api_url: https://api.getkanari.com
```

***

## Re-authenticating

If you need a new API key, just run `kanari login` again. The existing `~/.kanari/config` will be overwritten.

***

## Key resolution order

When running any Kanari command, the API key is resolved in this order:

1. `--token` flag (explicit override)
2. `KANARI_API_KEY` environment variable
3. `~/.kanari/config` (saved by `kanari login`)
4. `api_key` field in your `kanari.yaml`


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