# API keys and permissions

An API key is what your agent uses to act in Pombus. Each key has a scope, which says where it can act, and a set of permissions, which says what it can do. You can give a key an expiration date, and you can revoke it at any time.

A key starts with `pmb_`. Keys created before this prefix keep working. Send the key in the `Authorization` header:

```
Authorization: Bearer pmb_your_key
```

Pombus shows the secret once, when the key is created. It stores only a SHA-256 hash of it. After that, lists show a short hint: the first 10 and the last 5 characters.

## Two ways to give an agent access

| Where | What the agent gets | Scope | Lasts |
| --- | --- | --- | --- |
| **Settings › API keys** in the webmail | A key that you paste into the agent. | `domain` | The expiration you choose. |
| **Connect an agent**, opened by a hosted client through `https://mcp.pombus.com` | An OAuth authorization. No secret to copy. | `pod` (one space) | 1 hour. |

In both, the screen shows only the permissions that kind of access can hold, and the agent gets exactly the ones you leave on. Nothing you choose is dropped later.

Neither kind of access can create, list or revoke keys. Keys are managed by a person in the webmail.

## Scope

`GET /v0/auth/me` returns the scope of the key in `scope_type`.

| `scope_type` | Where the key acts |
| --- | --- |
| `inbox` | One inbox. |
| `domain` | Every inbox of one domain, inside one space. |
| `pod` | One space (the API calls it a pod): its inboxes, domains, labels, lists and reports. |
| `organization` | Reserved for Pombus' own services. Keys that you create are never of this type. |

Keys with scope `inbox` or `domain` have two fixed limits:

- They reach only routes that name an inbox, plus `GET /v0/inboxes` and `GET /v0/auth/me`. Any other route answers 403.
- They never hold the permissions `pod_*`, `api_key_*`, `webhook_*` or `inbox_delete`, even if you ask for them.

A request for an inbox outside the scope answers 404, the same as an inbox that does not exist.

## Create a key in the webmail

1. Go to **Settings › API keys** and choose **New key**.
2. Give it the **Agent name**. It shows in the key list and in reports.
3. Choose the **Agent domain**. The key will act on any inbox of that domain.
4. Choose the permissions. Start from a preset or set them one by one.
5. Choose the **Expiration**: 7, 30 or 90 days, a date, or no expiration. The form starts on 30 days.
6. Select **Create key** and copy the secret.

A key created in the webmail has scope `domain`. You can create up to 10 keys per hour.

It can hold these 11 permissions: `inbox_read`, `message_read`, `message_update`, `message_send`, `message_reply`, `draft_read`, `draft_create`, `draft_update`, `draft_delete`, `draft_send`, `label_trash_read`.

With this key, `message_update` changes labels. Moving a message to the trash and restoring it are not available to a `domain` key: they need access through **Connect an agent**.

### Presets

Both screens use the same presets. Each one is cut to what that kind of access can hold.

| Preset | **Settings › API keys** | **Connect an agent** |
| --- | --- | --- |
| **Read-only** | Read inboxes, messages, drafts and the trash. | The same, plus read labels, lists, domains, reports and the space. |
| **Read and draft** (default) | Read-only, plus change labels and create, edit and delete drafts. It cannot send. | Read-only, plus organize messages (labels, trash, restore), create, edit and delete drafts, and create and rename labels. It cannot send. |
| **Operator** | Read and draft, plus send messages and send drafts. | The same. |
| **Custom** | The permissions you turn on one by one. | The same. |

`message_reply` (reply only) is in no preset. Turn it on under **Custom**.

If you turn every permission off, the key gets the default agent set: the 11 permissions of the webmail key above, which include sending.

### What **Connect an agent** can grant

The access has scope `pod` and lasts 1 hour. It can hold up to 19 permissions: the 11 of the webmail key, plus `label_read`, `label_create`, `label_write`, `label_delete`, `list_entry_read`, `domain_read`, `metrics_read` and `pod_read`. It does not offer `inbox_create`, `domain_create` or `domain_update`.

### Never granted to an agent

These 19 permissions are not offered on either screen:

| Permission | Why |
| --- | --- |
| `label_spam_read`, `label_blocked_read`, `label_unauthenticated_read` | Quarantined mail stays out of reach of automation. |
| `message_delete` | Permanent delete cannot be undone. An agent moves mail to the trash. |
| `inbox_delete` | It erases the inbox, and the address is never reused. |
| `api_key_read`, `api_key_create`, `api_key_update`, `api_key_delete` | A key made by an agent could outlive the agent's own key. |
| `webhook_read`, `webhook_create`, `webhook_update`, `webhook_delete` | A webhook keeps sending the space's mail to a URL after the key is revoked. |
| `pod_create`, `pod_delete` | Creating or erasing a whole space is not mailbox work. |
| `list_entry_create`, `list_entry_delete` | An `allow` entry, or a removed `block` entry, changes what every key of the inbox can send and receive, and stays after the key is revoked. |
| `inbox_update` | It sets the inbox's retention, and `retention_days: 0` erases the inbox's mail. |
| `domain_delete` | Removing a domain stops its sending and revokes every key of the domain. |

## Permissions

There are 41 permissions. The names are the ones the API uses.

| Family | Permission | Allows | Webmail key | Connect an agent |
| --- | --- | --- | --- | --- |
| Inboxes | `inbox_read` | View inboxes. | Yes | Yes |
| | `inbox_create` | Create inboxes. | No | No |
| | `inbox_update` | Rename and edit inboxes. | No | No |
| | `inbox_delete` | Close inboxes. The address is never reused. | No | No |
| Messages | `message_read` | Read messages, threads and attachments. | Yes | Yes |
| | `message_update` | Organize: labels, trash, restore. | Yes | Yes |
| | `message_send` | Send emails directly. Also allows replying. | Yes | Yes |
| | `message_reply` | Only reply to received emails. | Yes | Yes |
| | `message_delete` | Permanently delete messages. | No | No |
| Drafts | `draft_read` | View drafts. | Yes | Yes |
| | `draft_create` | Create drafts. | Yes | Yes |
| | `draft_update` | Edit drafts. | Yes | Yes |
| | `draft_delete` | Delete drafts. | Yes | Yes |
| | `draft_send` | Send a draft. Also needed to schedule one. | Yes | Yes |
| Labels | `label_read` | View the labels of the space. | No | Yes |
| | `label_create` | Create labels. | No | Yes |
| | `label_write` | Rename and edit labels. | No | Yes |
| | `label_delete` | Delete labels. | No | Yes |
| | `label_spam_read` | See what is in spam. | No | No |
| | `label_blocked_read` | See what is blocked. | No | No |
| | `label_unauthenticated_read` | See what failed authentication. | No | No |
| | `label_trash_read` | See the trash. | Yes | Yes |
| Allow/block lists | `list_entry_read` | View list entries. | No | Yes |
| | `list_entry_create` | Add entries. | No | No |
| | `list_entry_delete` | Remove entries. | No | No |
| Reports | `metrics_read` | Read sending and delivery metrics. | No | Yes |
| Domains | `domain_read` | View domains. | No | Yes |
| | `domain_create` | Add domains. | No | No |
| | `domain_update` | Edit and verify domains. | No | No |
| | `domain_delete` | Remove domains. | No | No |
| Spaces | `pod_read` | View spaces. | No | Yes |
| | `pod_create` | Create spaces. | No | No |
| | `pod_delete` | Delete spaces. | No | No |
| API keys | `api_key_read` | View keys. Secrets are never returned. | No | No |
| | `api_key_create` | Create keys. | No | No |
| | `api_key_update` | Turn on the allow-list-only mode of a key. | No | No |
| | `api_key_delete` | Revoke keys. | No | No |
| Webhooks | `webhook_read` | View webhooks. | No | No |
| | `webhook_create` | Register webhooks. | No | No |
| | `webhook_update` | Edit and test webhooks. | No | No |
| | `webhook_delete` | Delete webhooks. | No | No |

A key with `message_reply` and without `message_send` can only answer the sender of a received message. It cannot name other recipients, and it cannot reply to all.

A route that has no permission assigned refuses every key that has a permission set.

In the MCP server, a tool appears only when the key holds its permission and the key's scope reaches it. See [MCP tools](mcp-tools.md).

## Allow-list-only mode

A key in this mode can send only to recipients on the send allow list. Turn it on per key in the webmail under **Lists**, with **Deny by default, per key**. See [Send and reply](send.md).

## Expiration

An expired key stops working at the instant in `expires_at`. Requests answer 401, the same as a wrong key.

## Revoke

In the webmail: **Settings › API keys**, then **Revoke** on the key. The agent loses access at once, and a revoked key stays revoked.

An open WebSocket connection checks its key every 30 seconds and closes when the key is revoked or expired.
