Sign inGet Started

Authentication & API keys

Workspace API keys authenticate requests to the Bird API as bearer tokens. They belong to a workspace, carry permissions you can change, and are shown in full exactly once.

For the distinction between service credentials and delegated access, see API keys and OAuth tokens.

How requests authenticate

Pass your key in the Authorization header on every request. The SDKs and the CLI take the key once and set the header for you:

import { BirdClient } from "@messagebird/sdk";

const bird = new BirdClient({ apiKey: process.env.BIRD_API_KEY! });

await bird.email.send({
  from: "hello@yourdomain.com",
  to: ["delivered@messagebird.dev"],
  subject: "Hi",
  text: "Hello.",
});

The region in the key prefix tells you which host to call: bk_us1_... keys go to https://us1.platform.bird.com, bk_eu1_... keys to https://eu1.platform.bird.com. Official Bird SDKs and the CLI read the region from the key and select the host for you. A key sent to the wrong regional host returns 421 (type misdirected_error); see Regions.

A missing or invalid key returns 401. A valid key that lacks the permission an endpoint requires returns 403. Header semantics and error responses live in the authentication reference.

Identifying a key

The full key is returned once, in the response that creates it. You cannot retrieve the plaintext later. Subsequent responses include the first 15 characters as key_prefix, for example bk_us1_Ab3xKq9m. They also include a stable 12-character fingerprint for matching a key in logs and support conversations without exposing its value.

If you lose a key, rotate it for a new secret, or revoke it and create a new one.

Creating a key

Create keys in the dashboard under Platform tools > API keys. A key is created with a name, one or more scopes, and an optional expiry. The response that creates it is the only one that ever carries the token field (the full key): store it in your secret manager immediately.

You can also create one without a browser, with bird api-keys create. Key issuance needs the api_keys:write scope, which the read-only login baseline does not include. A login can put on a key only the scopes it holds itself, so request api_keys:write together with the key's scopes when you sign in. Run these commands in a shell where BIRD_API_KEY is not set, because the CLI uses that key in preference to the login and a key cannot issue keys:

Code example
bird auth login --scope api_keys:write --scope emails:write
bird api-keys create --body-file - <<'JSON'
{
  "name": "Email operations production key",
  "scopes": [{ "scope": "emails", "level": "write" }]
}
JSON

Run bird api-keys create --example to print a complete body to edit.

Scopes are the one thing a key cannot grant itself: api_keys:write is not available to API keys, so a key can never issue another key. Issuance runs as you, on a dashboard session or a CLI or MCP grant.

The API Keys page in the Bird dashboard, listing keys with their masked prefix, scopes, and last-used time

You can manage a key after creating it:

  • Scopes are editable. Editing replaces the permission set and keeps the same secret. You can grant scopes your own account holds. If the key was created before it could support a permission such as voice, rotate it to add that permission. Revoked keys and keys already replaced by rotation cannot be edited.
  • Expiry is fixed. Set expires_at when a key should stop working at a known time (a contractor's engagement, a migration window). Past that moment the key returns 401; a key without an expiry lives until revoked.
  • Key management stays with people. Creating, editing, and revoking keys requires the api_keys:write permission, held by the workspace admin and developer roles (see Users, teams & roles) and never grantable to an API key itself. A leaked key cannot mint more keys.

The API keys page lists every key with its key_prefix, scopes, and last_used_on date (day precision), so you can spot stale keys at a glance. Revoked keys stay out of the listing unless you choose to show them.

Scopes & levels

Each scope on a key is a {scope, level} pair, where level is read or write (write includes read). API keys hold these scopes:

Scopereadwrite
access_restrictionsRead workspace IP allowlists and mTLS settingsManage workspace IP allowlists and mTLS settings
emailsRead sent messages and delivery statusSend email
email_managementRead suppressions, email configuration, templates, and reusable blocksManage suppressions, email configuration, templates, and reusable blocks
email_marketingRead contacts, audiences, and broadcastsManage contacts, audiences, and broadcasts
inbox_insightsRead Inbox Insights placement and reputation dataConfigure Inbox Insights
competitiveRead Competitive Insights watchlists and sender intelligenceManage Competitive Insights watchlists
domainsRead sending domains and their DNS recordsAdd, verify, and manage sending domains
smsRead sent SMS and delivery statusSend SMS
sms_managementRead senders, registrations, suppressions, keyword replies, destinations, and templatesManage senders, registrations, suppressions, keyword replies, destinations, and templates
whatsappRead sent WhatsApp messages and statusSend WhatsApp messages
whatsapp_managementRead WhatsApp templates and settingsManage WhatsApp templates and settings
ambRead Apple Messages conversations, messages, and statisticsSend Apple Messages for Business
amb_managementRead Apple Messages business records, routing rules, and suppressionsManage Apple Messages business records, routing rules, and suppressions
verifyRead verification statusSend and check verification codes
realtimeRead Realtime apps, channels, and channel membersCreate apps and publish events
voiceRead call logs, leg logs, and call statisticsPlace outbound calls, authenticate SIP calls, and create session credentials
voice_managementRead trunks, gateways, numbers, caller IDs, and destinationsManage trunks, gateways, numbers, caller IDs, and destinations
mailboxRead mailboxes, threads, and messagesSend and reply to mailbox messages
mailbox_managementRead receive rules and mailbox configurationCreate, update, and delete mailboxes and receive rules
assetsRead assets and foldersUpload, update, and delete assets and folders
esimRead eSIMs, orders, and plansCreate eSIM orders and manage eSIMs
esim_credentialsRead eSIM installation credentialsManage eSIM installation credentials
numbersSearch available numbers and read workspace phone numbersBuy, configure, and release phone numbers
ratesRead the rates your organization pays, per productNot available
preferencesRead cross-channel consent grants and opt-out recordsRecord and delete cross-channel messaging preferences
complianceRead compliance requirements, submissions, attachments, and business identitiesFile and correct registration paperwork, and upload and delete attachments
workspaceRead the workspace's name, organization ID, and settingsNot available
webhooksRead webhook subscriptions and their delivery attemptsCreate, update, delete, test, replay, and rotate the secret of a webhook
lookupNot availableLook up phone numbers, email addresses, and identity matches

Changing workspace settings, managing members, issuing keys, and managing IP pools are deliberately not grantable to API keys, so they run as a person rather than as a key: through the dashboard, or through the CLI or MCP server on a grant that holds the scope. Grant the narrowest set that works: a key that only sends email should hold emails:write and nothing else.

lookup has no read-level operations: every lookup endpoint, including fetching an existing result, requires write.

Limiting a key to specific resources

A scope covers every resource of its kind in the workspace unless you limit it. The sms scope can be limited to the messaging profiles you name, so a key issued to one team or program reaches that team's profiles and leaves the rest of the workspace's SMS traffic out of reach. The mailbox scope can be limited to the mailboxes you name in mailbox_ids in the same way. A key can name up to 100 IDs across all its limits, and each must exist in the workspace when you set the limit.

In the dashboard, select Limit to specific messaging profiles under the sms permission, or Limit to specific mailboxes under mailbox, when you create or edit a key, and tick the ones the key may use in the panel that opens. On the API and CLI, add resources to the scope when you create the key:

Code example
bird api-keys create --body-file - <<'JSON'
{
  "name": "Alerts program production key",
  "scopes": [
    {
      "scope": "sms",
      "level": "write",
      "resources": { "messaging_profile_ids": ["mpr_01jqx4m8n2k5v7p9r3t6w8y0za"] }
    }
  ]
}
JSON

A limited key sends through its profiles and reads the messages sent or received under them. Each send has to name one of the key's profiles in messaging_profile_id and use one of that profile's senders. A built-in template send names one of the key's profiles and leaves out from: it goes out from Bird's own sender, whatever senders the profile lists. A request outside the limit is refused with 403.

A key limited to mailboxes reads, sends from and changes only the conversations of its mailboxes, and a list returns only those. A mailbox outside the limit is refused with 403. The key can apply labels the workspace already has, and creating or editing a label needs a key without a mailbox limit.

Change a limit by editing the key in the dashboard. A permission that has a limit shows it as a Limited to line: select that line, change the ticks, select Done, then Save on the key's page to store the change. Unticking every resource removes the limit.

The API and the CLI set a limit when the key is created and have no way to change it afterwards. The responses that create and rotate a key include its limit, and rotating carries the limit over to the replacement. To check or change a limit later, open the key in the dashboard. You do not need a new key for that.

Removing a limited permission from a key removes its limit too. Granting that permission to the same key again gives it without a limit, across the whole workspace. To bring limited access back, set the limit again in the dashboard or create a new key with the limit.

An Idempotency-Key is remembered together with the limit of the key that sent the request. A retry sent with a key whose limit differs is processed as a new request and can send a second time, so finish or reconcile the requests you are still retrying before you change a key's limit or move traffic to a key with another limit.

Before you rely on a limit, check what it leaves open:

  • A limit applies to the scope that carries it. sms_management and webhooks reach every messaging profile in the workspace. Leave them off a key that holds a limited sms scope. mailbox_management reaches every mailbox in the same way, emails reads the mail received by every mailbox, and webhooks can subscribe to the events of every mailbox, so leave all three off a key that holds a limited mailbox scope. The key's other scopes, such as emails over SMTP or voice over SIP, work as they do without a limit.
  • Deleting a messaging profile does not end a key's access to its messages. The messages already stored under the profile stay readable with the key. To end that access, limit the key to other profiles or revoke the key. Unticking a key's only profile removes the limit, which opens every profile in the workspace to the key.
  • Some operations cannot apply a limit. SMS statistics answer a limited key with 403. Use a separate key without a limit for those.

Revoking a key

Revoke a key from its row under Platform tools > API keys. Revocation is permanent: a revoked key cannot be reactivated, and its record is preserved for audit with revoked_at set.

Revocation usually takes effect almost immediately, though a short delay is possible. Once it takes effect, requests using the key return 401.

Rotating a key

Rotating issues a replacement for a key you already have and returns its token once, in that response. The replacement carries the source key's name and source IP restrictions, and keeps its scopes when you omit --scope (or scopes in the API body). Passing any --scope flag or scopes list replaces the whole permission set rather than adding to it. It starts with no expiry. Rotate a key from its row under Platform tools > API keys, or without a browser with bird api-keys rotate and the api_keys_rotate MCP tool:

Code example
# keep the source key's existing scopes
bird auth login --scope api_keys:write --scope emails:write
bird api-keys rotate key_01hqz8kp3v9x2m --yes

To replace the key's permission set during rotation, log in with every permission the replacement needs and pass each one with --scope:

Code example
# replace the scope set — include every permission the replacement needs
bird auth login --scope api_keys:write --scope emails:write --scope brands:read
bird api-keys rotate key_01hqz8kp3v9x2m --scope emails:write --scope brands:read --yes

Rotation cannot grant permissions the caller does not hold, so request each scope the rotated key needs when logging in.

The previous key keeps working for a grace period, 24 hours by default, so you can deploy the new token before the old one stops. If the key is exposed, pass grace_period: 0 (--grace-period 0 on the CLI) to revoke it without a grace period. A key already set to expire sooner than the grace period keeps its own expiry, because rotating never extends a key's life.

Before you automate key rotation, note two constraints. A rotation never carries an expiry over, so the replacement for a key that expired at a known time lives until revoked; re-issue with create when the expiry matters. And a key can be rotated only once: a second rotation of the same key returns 409, so send an Idempotency-Key and a retry replays the original response. Without one, a rotation whose reply you never received has minted a live key whose token you cannot read back.

Overlapping two keys by hand is still the safer path when you cannot predict how long the switchover takes, because the grace period is fixed when you rotate and cannot be extended afterwards:

  1. Create a new key with the same scopes. --scope cannot carry a resource limit, so for a limited key pass the scopes with their resources in a body file, as in Limiting a key to specific resources. A key created from --scope flags alone has no limit.
  2. Deploy the new key to your services.
  3. Watch the old key's last_used_on until traffic has moved.
  4. Revoke the old key.

Keys belong to the workspace

An API key is bound to your workspace and authenticates with that workspace's authority. The creator's personal permissions do not affect it. That has two practical consequences:

  • Keys survive departures. When an employee leaves and their user account is removed, the keys they created keep working. You never have a production outage because the person who clicked "create" left the company. (Their departure is still a good prompt to rotate keys they had access to.)
  • The key's reach stops at the workspace. It can never perform organization-level operations: billing, org members, org settings.

Because the key pins the workspace, requests with a key need no extra context; see Workspace for how the workspace and the organization above it divide up what you can reach. Agent controls shows how a scoped key combines with the default-deny SMS country list, daily SMS spend limits and the prepaid wallet to bound an agent, and which of them the key cannot change.

The delegated path: OAuth tokens for the CLI and MCP server

API keys are for services. The Bird CLI and Bird MCP server use OAuth when a person signs in. You log in through the browser, choose a workspace, and grant a subset of your permissions. The tool then receives a short-lived bt_{region}_... user token.

Each token is limited to permissions you hold. You can revoke access for each tool under Profile > Connected apps. The tools manage these tokens for you, so do not copy them or store them in a secret manager. Use API keys for server workloads.

Next steps

For integrations that manage several workspaces in one organization, see Organization master keys. This feature is available on request. Contact your Bird representative to enable it for your organization.