# Azion auth.md

Agents authenticate to the Azion API v4 and the Azion MCP servers with a personal token that the user creates in Azion Console. Azion does not run agentic registration: it publishes no `agent_auth` block or `identity_endpoint`, and it does not accept an `identity_assertion` (ID-JAG, `urn:ietf:params:oauth:token-type:id-jag`), `service_auth`, or anonymous registration. Skip those flows and follow the steps below.

## Discover

- The API security schemes are in the [OpenAPI spec](https://www.azion.com/openapi.json): `TokenAuth` for a personal token and `BearerAuth` for a user JWT.
- A request to the API without credentials gets `401` with `WWW-Authenticate: Bearer realm="api"`.
- A request to an MCP server without credentials gets `401` with `WWW-Authenticate: Bearer resource_metadata="..."`, which points at the server's protected-resource metadata, such as the [docs server metadata](https://docs-mcp.azion.com/.well-known/oauth-protected-resource).

## Pick a method

| Method | Header | Use it for |
| --- | --- | --- |
| Personal token | `Authorization: Token <personal token>` | Agents. Works with the Azion API v4, the MCP servers, and the Azion CLI. |
| User JWT | `Authorization: Bearer <access_token>` | A session where the user signs in to the Azion API v4 themselves. Don't ask the user for their password. |

## Register

1. The user signs up at [Azion Console](https://console.azion.com/signup). Sign-up is self-serve.
2. In Azion Console, the user opens **Account Menu** > **Personal Tokens**, selects **+ Personal Token**, names it, and chooses when it expires: 1, 7, 15, 30, or 90 days, 1 year, or a custom date.
3. The user copies the token right away. Console shows it only once.
4. The agent asks the user for the token and keeps it in the client's user configuration or a secret store, never in a file that gets committed.

A personal token is `azion` followed by 35 letters and digits, 40 characters in all.

## Claim

There is no claim ceremony. The user creates the personal token and hands it to the agent in step 4 of Register.

## Exchange

A personal token needs no exchange. Send it as is.

A user JWT comes from `POST https://api.azion.com/v4/account/auth/login` with `email` and `password` (and `account_id`, optional). The response `data` carries an `access_token` and a `refresh_token`, or a multi-factor challenge (`two_factor_required`) when the account uses MFA. To get a new `access_token`, call `POST https://api.azion.com/v4/account/auth/token` with `Authorization: Bearer <refresh_token>`.

## Use the access_token

- [Azion API v4](https://api.azion.com/v4): send `Authorization: Token <personal token>`, or `Authorization: Bearer <access_token>` with a user JWT.
- Azion MCP servers, over streamable HTTP: send `Authorization: Token <personal token>` on every request.
  - docs: https://docs-mcp.azion.com/mcp (reads the Azion documentation)
  - build: https://build-mcp.azion.com/mcp
  - secure: https://secure-mcp.azion.com/mcp
  - observe: https://observe-mcp.azion.com/mcp
  - storage: https://storage-mcp.azion.com/mcp
- Azion CLI: `azion login` saves the personal token for the active profile.

A coding agent can connect itself to the MCP servers with this skill: https://www.azion.com/.well-known/agent-skills/azion-mcp-setup/SKILL.md

## Errors

| Response | Cause | What to do |
| --- | --- | --- |
| API `401` with `{"errors":[{"code":"10002","title":"Not Authenticated",...}]}` and `WWW-Authenticate: Bearer realm="api"` | The request has no credentials. | Send the `Authorization` header. |
| MCP `401` `No authentication provided` (JSON-RPC error `-32001`) | The request has no `Authorization` header. | Send `Authorization: Token <personal token>`. |
| MCP `401` `OAuth validation failed` | A personal token was sent with the `Bearer` scheme. | Send it with the `Token` scheme. |
| MCP `403` `Authentication failed` | The value is not a valid personal token. | Check the token, or ask the user to create a new one. |

More fixes for MCP connections: https://www.azion.com/en/documentation/devtools/mcp/troubleshooting/

## Revocation

- A personal token stops working on the expiry date the user chose, and it can't be changed after it is created. Pick the shortest expiry the task needs.
- `azion logout` removes the personal token that the Azion CLI saved for the active profile.
- A user JWT session ends with `POST https://api.azion.com/v4/account/auth/revoke`, sent with `Authorization: Bearer <refresh_token>`.

More about personal tokens: https://www.azion.com/en/documentation/fundamentals/personal-tokens/
