Skip to main content

API Keys

An API key lets a script, an integration or an MCP client call the OPBX REST API without a user session. Each key carries its own list of permissions, one per resource, and those permissions are the only thing that decides what the key may do. The role of the Owner who created the key does not apply.

Purpose​

Use this module to:

  • give an integration (a CRM, a reporting tool, a provisioning script) access to the API;
  • grant read-only or read-write access per resource;
  • connect an MCP client to the MCP Server;
  • revoke access at once without touching any user account.

Prerequisites​

  • You are the Owner. No other role can see or manage API keys.

Permissions​

ActionOwnerPBX AdminPBX UserReporterSupervisor
See API Keys in the sidebar (Analytics section)YesNoNoNoNo
List, create, update and revoke keysYesNoNoNoNo

Other roles who open the page get the toast Access denied ("You do not have permission to access this page.") and 403 from the API. An API key can never manage API keys, whatever its permissions: the API key endpoints are not grantable and answer 403.

How a key's access works​

Each permission pairs a resource with a level:

LevelAllows
ReadGET and HEAD requests to that resource
WriteEvery method (Write includes Read)
No AccessThe resource is not granted (no permission row)

A request authenticated with a key is checked like this:

  1. The endpoint must belong to a grantable resource. Endpoints outside the list (API key management, user password changes, extension password resets, embed tokens, organization settings, platform management and so on) answer 403 "This API key is not permitted to access this endpoint."
  2. The key must have a permission for that resource, otherwise 403 "This API key is not permitted to access resource."
  3. A Read permission used with POST, PUT, PATCH or DELETE answers 403 "This API key has read-only access to resource."

A key always acts inside the organization it was created in.

Live calls (session-updates) are split on purpose: a key with Write can disconnect a call, but POST /v1/session-updates/{sessionId}/coach-target (spy, whisper, barge) always answers API keys with 403. Coaching is dialed from a signed-in Owner's or Supervisor's own Web Phone extension, which a key does not have. See Live Calls.

Grantable resources​

users, extensions, conference-rooms, ai-assistants, ai-assistant-providers, ring-groups, call-queues, queue-calls, ai-assistant-load-balancers, ivr-menus, business-hours, phone-numbers, outbound-whitelist, inbound-blacklist, call-detail-records, recordings, supervisors, auto-dialer-campaigns, distribution-lists, session-updates, call-notifications, dashboard, trunks

The live list comes from GET /v1/api-keys/grantable-resources. In the dialog the slugs are shown in title case, for example Call Detail Records.

Archived call records​

Only an API key can read the archive tier of call detail records (records 6 to 12 months old). Add archive=1 to the list, single-record, export or statistics request of call-detail-records. The flag is ignored for signed-in users, including the Owner. See Call Logs.

Workflows​

Create a key​

Who can do this: Owner.

  1. Open Analytics → API Keys in the sidebar.
  2. Click Create API Key (top right of the API Keys card, or in the middle of the page when there are no keys yet).
  3. Enter a Name (required, up to 255 characters), for example CRM Integration.
  4. Under Permissions, choose No Access, Read or Write for each resource. The buttons Disable All, Grant Read-Only All and Grant Write All set every resource at once.
  5. Click Create. The button stays disabled until there is a name and at least one permission.
  6. The toast API key created appears and the API Key Created dialog shows the key once. Click the copy button next to the key (toast Copied) and store it in a secret manager.
  7. Click I've copied it. The dialog cannot be closed by clicking outside it or pressing Escape.

The new key is listed as Active, with Never under Last used. The key starts with opbxk_ followed by 40 random characters. Only a SHA-256 hash is stored, so the key can never be shown again. If it is lost, revoke it and create a new one.

API Keys page with the REST API and MCP Server endpoint cards on top and two keys: Reporting Dashboard (call-detail-records:read, dashboard:read) and CRM Integration (extensions:write, phone-numbers:read, users:read), both Active with a last-used date
Create API Key dialog with the name CI pipeline, the Disable All, Grant Read-Only All and Grant Write All buttons and the per-resource selectors, Call Detail Records set to Read

Use a key​

Who can do this: anyone holding the key; the endpoint cards are on the Owner's API Keys page.

  1. On the API Keys page, click the copy button on the REST API card (toast REST API URL copied to clipboard) or the MCP Server card (toast MCP Server URL copied to clipboard).
  2. Send the key as a bearer token to that base URL:
curl -H "Authorization: Bearer opbxk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
https://pbx.example.com/api/v1/phone-numbers
  • REST API: the base URL for REST calls.
  • MCP Server: the URL to give MCP clients, with the same bearer key. See MCP Server.

Change a key​

Who can do this: Owner, through the API with a signed-in session (an API key cannot manage keys).

The page has no edit dialog. To rename a key or replace its permissions, use PUT /v1/api-keys/{id} with name and/or permissions. The new permission list replaces the old one completely and must contain at least one entry. Name and permissions change together or not at all.

Revoke a key​

Who can do this: Owner.

  1. Click Revoke on the key's row.
  2. The Revoke API key? dialog says that revoking the key immediately disables it and cannot be undone. Click Revoke.

The toast API key revoked appears. The key stops working immediately: requests with it answer 401 "Unauthenticated." Revoked keys stay in the list, dimmed, with the Revoked badge and no Revoke button. Revoking cannot be undone and a revoked key cannot be deleted.

Revoke API key? confirmation for Reporting Dashboard

List columns​

ColumnShows
NameThe key's name
PermissionsOne badge per permission, for example extensions:write
Last usedDate of the last request, or Never. Updated at most every 5 seconds per key (every request for users and extensions)
StatusActive or Revoked
ActionsRevoke for active keys

Common errors​

ResponseWhat it meansWhat to do
401 Unauthenticated.The key is wrong or revokedCheck the key; create a new one if it was revoked
403 This API key is not permitted to access this endpoint.The endpoint is not grantable to keysUse a user session for that action
403 This API key is not permitted to access resource.The key has no permission for that resourceGrant the resource with PUT /v1/api-keys/{id}
403 This API key has read-only access to resource.A write request with a Read permissionGrant Write
422 on createNo name, no permissions, an unknown resource or a level other than read or writeFix the request

Key data fields​

api_keys​

ColumnNotes
idPrimary key
organization_idTenant scope
nameUp to 255 characters
tokenSHA-256 hash of the key; the key itself is never stored
created_byThe Owner who created it
last_used_atTime of the last request (throttled, see above)
revoked_atSet when revoked

api_key_permissions​

ColumnNotes
api_key_idThe key
resourceA grantable resource slug
levelread or write
MethodEndpointPurpose
GET/v1/api-keysList keys, newest first
POST/v1/api-keysCreate a key. The response carries the key once in key
GET/v1/api-keys/grantable-resourcesGrantable resource slugs
GET/v1/api-keys/{id}One key
PUT/v1/api-keys/{id}Rename and/or replace permissions
DELETE/v1/api-keys/{id}Revoke

See the OPBX REST API reference for full schemas.

  • MCP Server — uses API keys for authentication
  • Users — roles for signed-in users
  • Call Logs — the archive tier readable with a key