# Authentication

> Sign in with the device flow or use an API key.

The CLI authenticates in one of two ways against `https://adtraces.adfactory.app`.

## Interactive login

```bash
traces login
traces whoami
```

`traces login` starts a device flow: the CLI opens `https://adtraces.adfactory.app/login/cli` in your browser, you sign in (password, or GitHub and Google when the operator enabled them), approve the request, and the CLI stores a device token. Credentials are stored per API origin, so this instance has its own login. On a machine without a browser use `traces login --no-browser` and open the printed URL elsewhere.

The first user who registers on a fresh instance becomes instance admin. Whether new sign-ups are allowed depends on `ADTRACES_SIGNUPS`, see [Configuration](/docs/self-hosting/configuration).

## API keys

For CI, containers and scripts, use a key instead of a login. Keys start with `trk_`, belong to one namespace and are created by namespace admins in `https://adtraces.adfactory.app/<namespace>/settings`.

```bash
export TRACES_API_KEY=trk_...
traces share --cwd .
```

Precedence: the `--key` flag, then a stored login, then `TRACES_API_KEY`. Scopes and details are in [Sharing via API key](/docs/sharing/api-key).

## Log out

```bash
traces logout
```
