Authentication
Base URL: https://chatsa.co/api/v1
Every call carries one credential in the Authorization header. Which one depends on who you are building for: your own workspace, an app other ChatSa customers connect, or a partner platform that creates ChatSa accounts. This page lists each credential, what it may call and how to keep it safe.
API keys (your own workspace)#
Create them in Dashboard → Developers → API keys and send them as a bearer token:
Authorization: Bearer csa_9f2c…
When you create a key you choose:
- A name, so you can tell keys apart later (for example "CRM sync").
- Scopes: what the key may do. A key with no scopes is the original read-only key for the older read endpoints.
- Chatbots: the chatbots the key may use. None ticked means every chatbot of the workspace. A key limited to exactly one chatbot may leave
chatbot_idout of WhatsApp calls.
| Scope | Allows |
|---|---|
whatsapp:read | Number status, templates, threads, media links, display name, voice settings and trained voices |
whatsapp:send | Send messages, mark read and show typing, take a conversation over from the AI |
whatsapp:manage | Create and delete message templates, change who answers (AI or Team only), voice-reply settings and the default voice, request and apply a display-name change |
whatsapp:voice | Voice previews, trained voices for voice-note replies |
sms:read | SMS credentials status, numbers, message history, consent |
sms:send | Send texts, record consent |
sms:manage | Save and remove Twilio credentials, connect and disconnect numbers, send a test text |
voice:call | Start a call from a connected number |
voice:read | Call history (with fresh recording links), number settings |
voice:manage | Forwarding, voicemail, missed-call text and AI answering per number |
The key is shown once, when it is created. ChatSa keeps only its hash. Revoke stops it at once; make a new key to replace a lost one.
Connect tokens (apps your users connect)#
An app registered in Dashboard → Developers → Apps gets a client id and a client secret. Existing ChatSa customers connect a chatbot to your app with "Connect with ChatSa"; you exchange the resulting code for an access token (csa_…), limited to that one chatbot and to the scopes the customer approved. Send it as a bearer token. It does not expire; it stops working when the customer disconnects your app or you call DELETE /connect. See Connect with ChatSa.
Partner credentials (account-creation tier)#
A partner platform holds three kinds of credential, from the same app:
| Credential | How you get it | Sent as | Used for |
|---|---|---|---|
| Client credentials | Your app's client id and secret | Authorization: Basic base64(client_id:client_secret) | Creating, reading, updating, suspending and deleting accounts (/partner/accounts/*), and /partner/capabilities |
| Account key | Returned once when an account is created (or rotated) | Authorization: Bearer csa_… | Everything for one account: WhatsApp and Facebook signup windows, its numbers, its webhook, erasures, SMS and calls, and the WhatsApp API for any of its chatbots (chatbot_id required) with the WhatsApp scopes your app may use |
| Chatbot key | Returned once by a connected WhatsApp signup | Authorization: Bearer csa_… | One number: the WhatsApp API and the Connect setup calls, exactly like a Connect token |
Client credentials only work once your app has the account-creation tier (otherwise 403 provisioning_not_allowed). See the partner API.
Which credential works where#
| Calls | API key | Connect token / chatbot key | Account key | Client credentials |
|---|---|---|---|---|
/whatsapp/* | yes, by scope and chatbot | yes, its chatbot | yes, chatbot_id required | no |
/sms/*, /voice/* | yes, by scope | no | yes | no |
/connect, /connect/webhook, /connect/context | no (403 app_token_required) | yes | no (403 app_token_required) | no |
/connect/token | no | no | no | yes, in the request body |
/partner/accounts/*, /partner/capabilities | no | no | no | yes |
/partner/whatsapp/*, /partner/facebook/*, /partner/webhook | no (403 account_key_required) | no (403 account_key_required) | yes | no |
/partner/erasures | no (403 app_key_required) | yes, its chatbot | yes, the whole account | no |
/conversations, /contacts, /analytics | yes; a key limited to chatbots reads only theirs, and not /contacts (403 workspace_key_required) | use the WhatsApp API's threads instead | use the WhatsApp API's threads instead | no |
A missing, wrong or revoked key answers 401 unauthorized. A valid key without the needed scope or chatbot answers 403 forbidden.
Keeping credentials safe#
- Use them only from your server. Never put a key or client secret in a browser, a mobile app or a URL.
- Store them encrypted, one per environment. ChatSa can't show them again, so keep them where your deploys read them.
- Give each key only the scopes and chatbots it needs.
- Rotate when someone who saw a secret leaves or a secret may have leaked:
- API key: create a new key, deploy it, revoke the old one.
- Client secret: Rotate secret on your app's page. The old secret stops working at once, so deploy the new one right away.
- Account key:
PUT /partner/accounts/{external_ref}?rotate=1returns a new key and revokes the old one. The account's webhook and numbers are kept. - Webhook signing secret: every
PUTof a Connect or partner webhook returns a new one; for dashboard endpoints, add a new endpoint and delete the old.
- Treat
401on a Connect token or chatbot key as "disconnected" and offer to connect again.