Authentication
Your API key, how to send it, and what each scope allows.
Every request carries an API key in a header:
curl https://v3.ghala.io/v1/messages?limit=1 \
-H "Authorization: Bearer $GHALA_KEY"X-API-Key: <key> works too. A key in the query string is never read: those end up in proxy logs, browser history and support tickets, so the answer is 401.
What a key looks like
ghala_live_k3x9m2q7w4z5n8b6_Qm9sZWN0aW9uIG9mIDMyIHJhbmRvbSBieXRlcyBoZXJl
│ │ │ └─ secret, 43 characters. Shown once, never stored.
│ │ └─ key id, 16 characters
│ └─ live or test
└─ the same for every channelThe first three parts are the key's prefix. It is safe to show and to log, and it is how the dashboard lists your keys. Only a hash of the secret is kept, so a lost key is replaced, not recovered.
Keys made before the ghala_ marker start gsms_. They keep working until you revoke them.
The workspace is the key's
Nothing under /v1 takes a workspace id. A key acts in the workspace that made it, so it can never reach another.
Scopes
A key can do only what its scopes allow. A key with no scopes can do nothing.
| Scope | Allows |
|---|---|
messages:send | send a message; launch, resume or retry a campaign |
messages:read | message history and the overview |
contacts:read | contacts, groups and suppressions |
contacts:write | create, import and delete contacts; manage groups and suppressions |
campaigns:read | campaigns, their runs and stats |
campaigns:write | create, edit, schedule, pause and cancel campaigns |
sender_ids:read | your sender IDs |
wallet:read | the balance and the ledger |
templates:read | a WhatsApp number's templates |
numbers:read | the WhatsApp numbers the workspace has connected |
otp:send | send and resend one-time codes, and nothing else |
otp:verify | check a one-time code; spends nothing |
products:read | the shop, its products, variants and stock |
products:write | create and change the shop, products, variants, images and files, and move stock |
orders:read | the shop's orders and sales |
orders:write | take an order and move it along its statuses |
payments:write | charge an order through the shop's payment link |
ai:read | the AI's uses and its takeover window |
- Launching a campaign needs
messages:send, notcampaigns:write: a key that may draft a campaign is not one that may message a hundred thousand people. otp:senddoes not givemessages:send. A key for your sign-in page can send codes and nothing else.- No key can create keys, start a top-up, connect a channel or change webhooks. Those are for signed-in owners and admins only.
When it fails
| Status | code | When |
|---|---|---|
401 | unauthorized | no key, a malformed or unknown key, a wrong secret, a revoked or expired key, or the key's workspace is not active |
403 | insufficient_scope | the key is valid but lacks the scope. Retrying with the same key will never help |
Every 401 for a key looks the same, on purpose: telling a caller that the prefix was right but the secret wrong would say which half to keep guessing.
{
"code": "insufficient_scope",
"message": "this api key does not have the messages:send scope",
"error": {
"type": "forbidden",
"code": "insufficient_scope",
"reason": "this api key does not have the messages:send scope",
"retryable": false,
"request_id": "8efbea679d6cf36ccc35d998ab29aec0"
}
}