# API key

The API key authenticates CLI and MCP access to the panel. Use it with
[`am-cloud platform`](/docs/cli) commands or the [MCP server](/docs/mcp-server).

## Generate a key

1. Go to **Settings → API key**.
2. Click **Generate key**.
3. **Copy and save the key immediately** — it starts with `amk_` and is shown
   only once. Generate a new key to rotate.

## Use the key

Set the `AM_API_KEY` environment variable on the machine running `am-cloud`:

```bash
export AM_API_KEY=amk_…
```

Or pass it as a flag:

```bash
am-cloud platform --panel https://automaintainer.intrane.fr --api-key amk_… status
```

For the [MCP server](/docs/mcp-server), configure it in your client's MCP
settings:

```json
{
  "mcpServers": {
    "automaintainer": {
      "command": "am-cloud",
      "args": ["mcp"],
      "env": {
        "AM_PANEL": "https://automaintainer.intrane.fr",
        "AM_API_KEY": "amk_…"
      }
    }
  }
}
```

## Security

- Keys start with `amk_` (distinct from worker license keys).
- The key is masked in all output — never printed in logs.
- Generate a new key to invalidate the old one. There is no way to retrieve a
  lost key.

## Related

- [am-cloud CLI](/docs/cli) — `platform` subcommand reference
- [MCP server](/docs/mcp-server) — drive AM as native agent tools
- [Security & data](/docs/security)
