Authentication
Create a key
Go to Settings, Integrations, API Access in your dashboard and click Create key. Name it after the system that will use it (Shopify sync, Billing server) so you can tell keys apart later. The full key, starting wamafy_live_, is shown once. We only store a hash of it, so it cannot be shown again; if it is lost, create a new one. A workspace can have up to 25 active keys.
Send it with every request
Put it in the Authorization header as a bearer token:
Authorization: Bearer wamafy_live_...Keep keys on your server. A key in a browser page, a mobile app or a public repository can be copied and used to message your customers in your name. If one leaks, revoke it on the same page; it stops working at once.
Scopes
Choose what a key may do when you create it. Give each integration only what it needs: a system that sends order updates needs messages:send and probably templates:read, nothing else. A call outside the key's scopes is refused with 403 API_SCOPE_MISSING, naming the scope it needed.
| Scope | Allows |
|---|---|
templates:read | List your templates. GET /templates |
templates:write | Create templates and submit them for review. POST /templates |
messages:send | Send templates and replies, check the reply window, look up message status. POST /messages, GET /messages/{messageId}, GET /window, POST /messages/text, POST /messages/interactive, POST /messages/media |
messages:read | Read a contact's conversation. GET /contacts/{phone}/messages |
contacts:read | List and look up contacts and segments. GET /contacts, GET /contacts/{phone}, GET /segments, GET /segments/{id}/contacts |
contacts:write | Create, update, opt in and opt out contacts. POST /contacts, PATCH /contacts/{phone}, POST /contacts/{phone}/opt-out, POST /contacts/{phone}/opt-in |
media:write | Upload files. POST /media |
campaigns:send | Start campaigns. POST /campaigns |
campaigns:read | See how a campaign is going. GET /campaigns/{campaignId} |
analytics:read | Read message stats. GET /analytics |
flows:trigger | Start a chatbot for a contact. POST /contacts/{phone}/trigger-flow |
Full access grants every scope, including ones added later, but only for what your workspace has: endpoints that come with an add-on answer 403 PLAN_UPGRADE_REQUIRED until the workspace has that add-on, whatever the key allows. Patient data is never part of Full access: the patient scopes of the Clinics & Hospitals add-on are health information and are granted by name only. Full access suits a key you control end to end, not one handed to a third party.
Expiry and allowed addresses
Two optional limits, set when you create the key, make a leaked key much less useful:
- Expires. After the date you choose (30 days, 90 days or a year), the key is refused with
401 API_KEY_EXPIRED. Good for a short project or a contractor. A key without one never expires. - Only allow calls from. Your server's public IP addresses or ranges, such as
203.0.113.7or203.0.113.0/24(IPv6 works too). A call from anywhere else is refused with403 API_KEY_IP_NOT_ALLOWED, and the error names the address it came from, which is the one to add if it is yours. Leave it empty to allow any address.
To change either, create a new key with the limits you want, move your systems to it, and revoke the old one.
Unusual use
Every hour Wamafy compares each key's calls with its usual rate over the past week. When the last hour is far above normal (at least 300 calls and ten times its usual hourly rate), the workspace owner gets an email and the key shows a warning in API Access. That is the usual sign of a leaked key. Nothing is blocked automatically: if you did not expect it, revoke the key and create a new one. A key is flagged at most once a day.
When a key is refused
| Status | Code | Meaning |
|---|---|---|
| 401 | API_KEY_MISSING | No Authorization header, or not in the Bearer form. |
| 401 | API_KEY_INVALID | The key is wrong or has been revoked. |
| 401 | API_KEY_EXPIRED | The key passed its expiry date. Create a new one. |
| 403 | API_KEY_IP_NOT_ALLOWED | The call came from an address the key does not allow. The error names the address. |
| 401 | WORKSPACE_SUSPENDED | The workspace is suspended. Speak to whoever runs your Wamafy account. |
| 403 | API_SCOPE_MISSING | The key works but does not have the scope this endpoint needs. |