API keys and scopes
API keys (they start with bm_) authenticate agents over REST and MCP. A key can be limited to some permissions (scopes) and to some inboxes. Keys are created by a signed-in person: in the webmail under Settings, API keys & MCP, Create key, or with POST /api/v1/keys from a webmail session. A key can't create other keys.
Scopes
| Scope | Allows |
|---|---|
mail:read | List, read, search and wait for mail; attachments and original source; labels and drafts. Reading a message marks it read. |
mail:write | Mark read, star, archive, trash and delete mail; labels, snooze, filters and contacts. |
mail:send | Send, reply, forward and send drafts. |
drafts:write | Create, edit and delete drafts. |
inboxes:manage | Create, rename and delete inboxes; custom domains. |
webhooks:manage | Create and manage webhooks. |
admin | Everything above. This is the default when you don't pass scopes, so keys created before scopes existed keep full access. |
The scope each REST endpoint and MCP tool needs is shown on the REST API and MCP tools pages. GET /api/v1/scopes lists the valid names, and GET /api/v1/me shows the scopes and inbox_ids of the key you are using.
Restricting to inboxes
inbox_ids limits a key to some inboxes (ids or full addresses). For such a key, other inboxes and their messages, threads, drafts and search results look nonexistent (404). Account-wide features are refused with 403: creating inboxes, webhooks, filters, contacts, custom domains and suppressions, and renaming or deleting labels. Creating and applying labels still works.
Create a key
curl -X POST "https://mailforbots.com/api/v1/keys" \
-H "Authorization: Bearer $SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "name": "support agent", "scopes": ["mail:read", "mail:send"], "inbox_ids": ["support@mailforbots.com"] }'scopes must be a non-empty array of the names above (otherwise 400); omit it for ["admin"]. inbox_ids must be a non-empty array, or omitted or null for all inboxes. The response contains the full key exactly once, next to its id, prefix, scopes and inbox_ids. At most 10 keys can be created per hour. Created while acting in a team, the key belongs to the team (see Teams).
When a key isn't allowed
A missing scope returns 403 over REST, and an error result over MCP:
HTTP/1.1 403 Forbidden
{ "error": "This API key lacks the mail:send scope" }Error: This API key lacks the mail:send scopeInbox-restricted keys get messages such as Inbox-restricted API keys can't manage webhooks. Other credentials problems are in Errors.