Buni.aiDocs

Authentication

Create a project API token, choose its scopes, send it with each request, and rotate or revoke it.

Every call to the public API carries a token. A token belongs to one project, starts with bai_ext_, and can only call the endpoints its scopes allow.

Create a token

Open the API Access tab

Open the project and go to Settings › API Access. The tab appears for chatbot and automation projects.

The API Access tab of a chatbot project, showing Your API Keys and Your Trigger Endpoints

Start a new key

Under Your API Keys, select New key (or Create API Key in Getting Started with Your API). The Create External API Token dialog opens.

Fill in the token details

FieldWhat to enter
NameRequired. A name you will recognise later, for example CRM production.
Owner noteOptional. Who owns the integration or what it is for.
Expires at (optional)A date after which the token stops working. Leave empty for a token that does not expire.
ScopesThe endpoints the token may call. See Scopes.
The Create External API Token dialog with name, owner note, expiry and scope checkboxes

Copy the token

Select Create token. The value appears once under New token (shown once). Select Copy token and store it in your secrets manager. Buni.ai keeps only a hash, so the full value cannot be shown again; the list shows only its prefix.

Scopes

Pick the smallest set your integration needs.

ScopeLabel in the appLets the token callOffered for
bot:invokeBot invoke/bots/{projectId}/message, /bots/{projectId}/invokeChatbot projects (selected by default)
flow:triggerFlow trigger/flows/{projectId}/trigger, /trigger-async, /polling, /dead-lettersChatbot projects
automation:triggerAutomation trigger/automations/{projectId}/trigger, /trigger-asyncAutomation projects (selected by default)

To read or change a run with /external-invocations/{invocationId}, use the same token that started the run. It needs the scope that matches the run: bot:invoke, flow:trigger or automation:trigger. A different token returns 403 Token does not match invocation, even if it has the right scope.

Reserved scopes

The app also offers Template manage (template:manage), and the platform defines voice:trigger. No public endpoint checks either scope today: the workflow template library is managed in the app, and voice:trigger cannot be added to a token. Treat both as reserved.

Send the token

Use either header. If both are present, Authorization wins.

# Authorization header
curl -X POST "https://www.buni.ai/api/v1/orgs/$ORG_ID/automations/$PROJECT_ID/trigger" \
  -H "Authorization: Bearer $BUNI_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"event": "order.paid", "payload": {"orderId": "ORD-10442"}}'

# x-api-key header
curl -X POST "https://www.buni.ai/api/v1/orgs/$ORG_ID/automations/$PROJECT_ID/trigger" \
  -H "x-api-key: $BUNI_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"event": "order.paid", "payload": {"orderId": "ORD-10442"}}'

Keep tokens on your server. Never put one in a mobile app, a browser bundle or a public repository: anyone holding it can trigger the project.

What can go wrong

StatusBodyCause
401Missing API tokenNo Authorization: Bearer or x-api-key header.
401Invalid API tokenUnknown, revoked or expired token, or a token from a different project.
403Insufficient token scopeThe token lacks the scope for this endpoint.
403External API access is disabled for this projectEnable External API is off in Advanced Settings.
403Token does not match invocationYou read or changed a run that another token started.

Rotate a token

Tokens cannot be edited or regenerated. To rotate one:

  1. Create a new token with the same scopes.
  2. Deploy it to your integration.
  3. Check that the old token's Last used time stops changing.
  4. Revoke the old token.

Revoke a token

Under Your API Keys, select Revoke next to the token, then Revoke token. The token stops working immediately and the action cannot be undone.

To block every token for a project at once without revoking them, switch off Enable External API. See Project API settings.

Last reviewed 24 September 2026

On this page