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

# Authentication and scopes

> How keys and OAuth sign-in authenticate, what each scope allows, and how read, in-app and outward operations behave.

## Send your key

Every request carries an Avazal API key in one of two headers:

```http theme={null}
Authorization: Bearer avz_…
```

```http theme={null}
x-api-key: avz_…
```

If both are present, `x-api-key` wins. Requests without a valid key get `401` with `_tag: "KeyRequired"`. A key stops working when it is revoked or expires, or when the member who created it leaves the organization.

API keys suit scripts, CI, the REST API and MCP clients without sign-in support. MCP clients that support sign-in can skip the key: see [OAuth sign-in for clients](#oauth-sign-in-for-clients).

## What a key acts as

A key acts as the member who created it, in one organization. Every call runs with that member's current role and visibility, so a key can never see or do more than its member. On top of that, the key only reaches the operations its scopes allow.

A sign-in connection works the same way: it acts as the member who approved it, in the workspace they picked, with the scopes they approved.

Call `me.get` to see the member, organization, role and scopes a key carries, and the [identity](https://docs.avazal.com/guides/identities.md) it posts as, if any.

## OAuth sign-in for clients

An MCP client that follows the [MCP authorization spec](https://modelcontextprotocol.io/specification/2025-06-18/basic/authorization) can connect with just `https://api.avazal.com/mcp`. See [Connect an agent](https://docs.avazal.com/connect.md#add-the-server-by-url-and-sign-in) for the steps in each client.

A request without a credential gets `401` with a pointer to the sign-in metadata. The client then:

1. Reads the protected resource metadata at `https://api.avazal.com/.well-known/oauth-protected-resource`. It is also served at `/.well-known/oauth-protected-resource/mcp`.
2. Reads the authorization server metadata at `https://api.avazal.com/.well-known/oauth-authorization-server`. The issuer is `https://www.avazal.com/api/auth`, and the metadata is also served at `/.well-known/oauth-authorization-server/api/auth`.
3. Registers itself with [dynamic client registration](https://datatracker.ietf.org/doc/html/rfc7591).
4. Opens the browser for the authorization code flow with PKCE (`S256`). The resource indicator is `https://api.avazal.com/mcp`.
5. Sends the access token as a bearer token on every MCP request.

The person signs in with Slack or Google, picks a workspace if they have several, and approves per-area access on a consent screen. Areas start at read access and can only be lowered or raised up to what the app asked for. The scopes are the ones listed [below](#scopes), plus `offline_access` for staying signed in.

Access tokens last 1 hour. Refresh tokens last 30 days and rotate on every use. Every operation enforces the same scopes and workspace as an API key. People revoke an app under **Connected apps** in **Settings → API keys**, which cuts it off immediately, and leaving the workspace does the same.

## Scopes

Pick scopes per area when you create the key in **Settings → API keys**. A sign-in approves the same scopes on its consent screen. Each area has levels, and a higher level includes the ones below it. New keys start with the scopes marked below, and you can change them before you create the key.

| Scope | Allows | Settings level | On for new keys |
| - | - | - | - |
| `messages:read` | Read conversations, messages, drafts, scheduled sends, files, emoji and the agent inbox, across chat and email | Messages: Read | Yes |
| `messages:write` | Save drafts, change read, pinned, saved and done state, react, manage conversations and bookmarks, upload and delete files | Messages: Draft | No |
| `messages:send` | Send messages, replies, drafts and scheduled sends | Messages: Send | No |
| `tasks:read` | Read lists, tasks and their comments, from Slack Lists and Linear | Tasks: Read | Yes |
| `tasks:write` | Create, update and delete lists and tasks, comment on them, and link them to documents and pull requests | Tasks: Write | No |
| `documents:read` | Read documents, canvases, revisions and their comments | Documents: Read | Yes |
| `documents:write` | Create, edit, move, delete, restore and publish documents, and comment on canvases | Documents: Write | No |
| `events:read` | Read calendar events and huddles, and find free times | Events: Read | Yes |
| `events:write` | Answer invites and book meetings | Events: Write | No |
| `people:read` | Read contacts, workspace members and user groups | People: Read | Yes |
| `people:write` | Pin, hide or rename contacts, and change your own profile and status | People: Write | No |
| `automations:read` | Read triggers and the asks you owe | Automations: Read | Yes |
| `automations:write` | Create and change triggers, mark and claim asks, start agent runs and send reminders and notices | Automations: Write | No |
| `settings:read` | Read your drafting, availability, calendar and assistant settings | Settings: Read | Yes |
| `settings:write` | Change your drafting, availability, calendar and assistant settings | Settings: Write | No |
| `search:read` | Search everything and turn links into ids | Search: Read | Yes |

A few operations need no scope: `me.get`, and the `runs.*` operations an agent uses inside a [run](https://docs.avazal.com/guides/identities.md#runs). The [tool catalogue](https://docs.avazal.com/mcp-tools.md) lists the scope of every operation.

Calling an operation without its scope returns `403` with `_tag: "ScopeRequired"` and the missing `scope`. Over MCP, tools the key can't use are not listed at all.

## Risk

Every operation has a risk that says what it can change. MCP clients see it as the tool hints in the table.

| Risk | Means | MCP hints | Examples |
| - | - | - | - |
| `read` | Changes nothing | `readOnlyHint`, `idempotentHint` | `me.get`, `accounts.list`, `settings.get` |
| `inApp` | Changes only Avazal, nothing anyone outside sees | None | `settings.update`, `files.create`, `files.delete` |
| `outward` | Reaches people or systems outside Avazal | `destructiveHint`, `openWorldHint` | `me.update`, `conversations.create`, `conversations.update` |

### With your own key

Your key acts immediately, like you clicking the button. An outward call posts the Slack message or sends the email at once, so have your agent confirm with you before calling one.

Clients such as Claude Code and Cursor ask before running a tool marked destructive. Outward tools carry that hint, and so do the tools that always need approval, listed below.

### Inside a run

When Avazal hands work to an agent, the agent works inside a run, either with a key minted for that run or with your key and the `x-avazal-run` header. A run is limited to where it was started:

* It reads and acts in the conversation or thread it was handed, unless you gave it more places.
* It only has `read` and `inApp` tools, or for a run started by a trigger, `read` tools plus drafting and the `runs.*` tools.
* Before any `outward` call it asks first. The call returns `409` with `_tag: "AskFirst"` and the exact `action` to approve. The agent calls `runs.ask` with that action, and once you approve, makes the call with the approved input.

A few in-app operations change your settings or act on your behalf. These always need approval: they only run inside a run that asked first, and calling them with a plain key returns `403` with `_tag: "ToolNotGranted"`. The [tool catalogue](https://docs.avazal.com/mcp-tools.md) marks them "Runs only, after approval".

* `triggers.update`: Change a trigger
* `triggers.delete`: Delete a trigger
* `triggers.run`: Try a trigger now
* `asks.reply`: Send a drafted reply

## Keys for identities

An identity is a named agent persona, such as `@claude`, that posts as itself rather than as you. Create one in **Settings → Identities**, then create a key for it there. That key is limited to the identity's permissions and the scopes you pick, and `me.get` returns the identity. See [Identities and runs](https://docs.avazal.com/guides/identities.md).


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