Rookery
Developer docsKeys and scopes
Basics

Keys and scopes

What an API key looks like, what it can see and do, how scopes work, and why someone's private inbox answers 404.

Updated View as Markdown

Every request needs an API key, sent in the Authorization header:

Authorization: Bearer $ROOKERY_API_KEY

Owners and admins make keys in Settings → Developers → API keys. A key is shown once, when you make it. Only a keyed hash of it is kept, so nobody can show it to you again; if you lose it, make a new one. Keep it in your secret manager or in an environment variable, ROOKERY_API_KEY, which every example in these docs reads.

What a key looks like

rookery_live_c7Hq2a_4fTz9KxQ0bWm…Lp3sV2
  • rookery_live_ or rookery_test_: whose key it is, and whether it works on real mail or the sandbox.
  • 6 characters after it name the Rookery server the key was made on. They're not secret.
  • 49 letters and digits after the next _: 256 random bits, then a 6-character checksum (CRC-32 of everything before it, in base 62).

That's 69 characters in all. The checksum means a key with a typo, a missing character or extra text pasted onto it is turned away straight away with 401 unauthorized, the same answer as any wrong key.

For secret scanners

To find Rookery keys in code, logs or chat, use these regular expressions. Check the checksum to tell a real key from a lookalike.

KeyRegular expression
Live key\brookery_live_[0-9A-Za-z]{6}_[0-9A-Za-z]{49}\b
Test key\brookery_test_[0-9A-Za-z]{6}_[0-9A-Za-z]{49}\b

Keys in the old format

Keys made before October 2026 start with rk_live_ or rk_test_ followed by 48 hexadecimal characters (the very first keys start with just rk_ and work as live keys). They keep working. Settings → Developers → API keys marks them Old format: when you can, make a new key for the app and revoke the old one. rk_ is also the prefix of Stripe's restricted keys, so scanners may label an old Rookery key as a Stripe key.

Live keys and test keys

  • A live key (rookery_live_…, or an old rk_live_…) works on your real mail.
  • A test key (rookery_test_…, or an old rk_test_…) works only on the sandbox: its own inbox, where nothing is ever sent. It can't see your real mail, and live keys can't see the sandbox.

Choose under Works on when you make the key. Build and run your tests with a test key, then switch to a live key with the same scopes.

A key is a teammate

Each key joins your team as its own agent, named after the key. Its notes, tags, drafts and other changes show up under that name in conversations and in the audit log, next to Rook's. In the API, what it did shows as { "type": "app", "id": "agt_…", "name": "…" }. You can assign conversations to it, too.

A key acts for the person who made it, so it works only while they're on the team. Removing someone from the team revokes the keys they made.

Scopes: what a key may do

You choose a key's scopes when you make it. They can't be changed later: make a new key and revoke the old one.

ScopeIn SettingsLets the key
readReadList and read conversations, notes, tags, inboxes and documents
writeWork on conversationsAdd notes, change status, tag and assign
draftDraft repliesWrite replies and document requests that wait for a person's yes
sendSend repliesSend them, after a 10-minute undo window
recordRecord app mailTell Rookery what your app sent with record_sent, so replies arrive linked to your records. It reads no mail
approveApprove draftsSay yes to a helper's draft as the person who made the key
  • write, draft, send and approve bring read with them: each starts with reading the conversation.
  • record stands alone. A key with only record can call record_sent and get_me, and nothing else: every other call answers 403 missing_scope, its MCP tool list holds only record_sent, and conversation_id in the answer stays null. Give your app's sending service a key like that, so a leak there can't read mail.
  • Keys made up to 19 October 2026 with record got read too. Those with exactly read and record now have record alone; if your app also needs to read, make a new key with both. A key with write, draft, send or approve as well keeps its read.
  • Any key may call GET /me, whatever its scopes: it shows only the key itself, so it's the way to check a key works.
  • A call without the scope it needs gets 403 with the code missing_scope, and the message names the scope. See Errors.
  • reply and request_documents need draft, or send when you pass send: true.
  • Approve drafts is off unless you choose it, and it's separate from Send replies. Approve a draft gives the person's yes, with the checks they'd get in Rookery. It never approves a draft the key or that person wrote, never on a conversation marked confidential, never one that suggests times from someone's calendar (a person approves those in Rookery), and only in an inbox that lets replies go out without a person in Rookery. It needs the draft's version from Read a conversation, passed on as it is, so you approve the words you read: without it the call answers 400, and if the draft changed since, 409 conflict; either way nothing is sent. A draft too long to return whole has no version; approve that one in Rookery.
  • For trying things, and for most agents, start with Read alone, or Read and Draft replies. See Draft, don't send.

What a key can see

A test key sees only the sandbox. A live key sees what the person who made it sees:

  • every team inbox, and
  • that person's own private inboxes.

Someone else's private inbox doesn't exist for the key. Asking for one of its conversations answers 404, the same as an id that was never there, whatever the key's scopes. So a key can't tell whether a private conversation exists.

Lists only include what the key can see, and so do the open counts on inboxes and tags.

Keep keys safe

  • Give each app or agent its own key, with only the scopes it needs.
  • Keep keys on a server or in an environment variable. Never put one in a web page, a mobile app or a repository.
  • Read the key from an environment variable in commands, as the examples here do ($ROOKERY_API_KEY), so it doesn't land in your shell history.
  • Settings → Developers → API keys shows when each key was last used, and each key's start and last 4 characters, so you can tell which one is which.
  • Click Revoke to stop a key straight away. Everything it did stays in the audit log.