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

# Authenticate

> Set up your API key for the CLI and MCP server

The agent talks to the Percio API, so it needs a key. You have two options.

## Option A — `percio login` (recommended)

Run:

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

You'll be prompted to paste your API key. Percio stores it at:

```
~/.config/percio/credentials.json
```

Both the CLI and the MCP server read from this file automatically. You only need to log in once per machine.

## Option B — `PERCIO_API_KEY` environment variable

Set:

```bash theme={null}
export PERCIO_API_KEY="pk_..."
```

Useful for:

* **CI.** Store the key in a secret, expose it as an env var, run `percio test` directly.
* **Ephemeral shells** where you don't want to write credentials to disk.
* **Shared machines** where each user's key stays scoped to their shell session.

The env var takes precedence over the credentials file if both are set.

## Getting an API key

Keys are created in the web app:

1. Sign in at [percio.app](https://percio.app).
2. Go to **Integrations**.
3. Under **Agent integrations**, generate a new API key.
4. Copy it immediately — you won't see it again.

## Rotating or revoking a key

On the **Integrations** page you can revoke an existing key and generate a new one. After revoking, update your credentials:

```bash theme={null}
percio login   # paste the new key
```

Or re-export `PERCIO_API_KEY` in any shell that uses the env-var approach.

## Verifying it worked

Any command that talks to the API will fail fast with `No API key found` if it can't read a key. The simplest smoke test:

```bash theme={null}
percio personas list
```

If the CLI prints your personas, you're authenticated.

## What's next

* [The local daemon](/agent/daemon)
* [Run your first test](/agent/cli/test)
