Skip to content
Chatwise
Skip to Content
Developer docs

Authentication and scopes

Create API keys, send them with each request, and give each key only the scopes it needs.

View as Markdown

Every request needs an API key in the Authorization header:

GET /v1/conversations HTTP/1.1
Host: api.chatwise.so
Authorization: Bearer <your API key>

A key belongs to one workspace, so no request names a workspace.

Create a key

Workspace admins create keys in the dashboard, under Settings → Developer → API Keys (open it). Choose a name, the permissions and when it expires: in at most 365 days, or never.

The key is shown once. Chatwise stores only a hash of it and can't show it again.

Keep keys on your server. Don't put one in a web page, a mobile app or a repository: anyone who has it can use it.

Scopes

A key can do only what its scopes allow.

ScopeIn the dashboardWhat it allows
conversations:readRead conversationsList, find and read conversations.
messages:readRead messagesList, search and read messages. Also needed for anything that would give the key a message by webhook, see below.
messages:sendSend messagesSend approved WhatsApp templates.
templates:readRead templatesList and read WhatsApp templates.
templates:writeCreate templatesCreate WhatsApp templates and submit them to Meta.
webhooks:readRead webhook endpointsList webhook endpoints, their deliveries and the event types.
webhooks:writeManage webhook endpointsCreate, change, test and delete webhook endpoints, rotate their secrets and redeliver.

One scope doesn't include another: webhooks:write alone can't list endpoints. Each page of the API reference names the scope its route needs.

You can't change a key's scopes. Create another key and revoke the old one.

When messages:read is needed too

Webhooks carry messages, so a key must not get a message by webhook that it couldn't read through the API. With message.* events, these need messages:read as well:

What you doScopeAlso
Create an endpoint with message.* eventswebhooks:writemessages:read
Change an endpoint that has them, or add themwebhooks:writemessages:read
Rotate the secret of an endpoint that has themwebhooks:writemessages:read
Read a delivery of a message.* eventwebhooks:readmessages:read
Redeliver a message.* eventwebhooks:writemessages:read

Testing and deleting an endpoint, and listing its deliveries, don't need it: they return no messages.

Rotate a key

  1. Create a key with the same scopes.
  2. Deploy it.
  3. Make a request with it.
  4. Revoke the old key in the dashboard.

A revoked or expired key stops working right away: it answers 401.

When a key is refused

StatusMessageWhat to do
401A valid Bearer API key is requiredSend Authorization: Bearer and the key.
401Invalid or revoked API keyCheck the key. It may have been revoked, or have expired.
401Invalid API keyChatwise couldn't check the key. Try again.
403API key does not have the required scope: …Use a key with the scope the message names.
400Message events need an API key with the messages:read scope too.Subscribe with a key that also has messages:read.
403Changing an endpoint that receives message events needs an API key with the messages:read scope too.The same, for changing an endpoint or rotating its secret.
403Reading a message event's delivery needs an API key with the messages:read scope too.The same, for reading or redelivering a delivery.
429API key rate limit exceededWait, then go on.

On this page