Authentication
API keys
Send your key in the Authorization header of every request:
Authorization: Bearer cdl_live_…- A key starts with
cdl_. The portal shows the whole key once, when you create or roll it. After that it shows only the start, likelive_ cdl_, so you can tell keys apart.live_ 7h2kq9wmx4ab_ … - A key belongs to your organization, not to the person who created it. It keeps working after they leave, so roll it if they kept a copy.
- A new key expires after 90 days unless you choose another date or no expiry.
- A key that is wrong, disabled, expired or revoked gets
401with the codeinvalid_. The answer is the same whichever it is.api_ key
Your account ID
Every path for your organization's data includes your account ID: org_ followed by 10 letters and digits.
GET /organizations/org_7h2kq9wmx4/messagesGET / is the one call without it, and it answers with your account ID.
A key works only for its own organization. A path with another organization's account ID answers 404, exactly as one that doesn't exist does, so nobody can use the API to find out whether an organization exists. If you get a 404 on every call, check the account ID in your paths.
Permissions
You choose what each key can do when you create it, and you can change it later. You can only give a key permissions you hold yourself. A request the key isn't allowed to make gets 403 with the code insufficient_, and the message names the permission it needs.
| Permission | What the key can do |
|---|---|
messages:send | Send messages and campaigns, send them again, reschedule, resume or cancel a campaign, and create, change, pause, resume or delete recurring campaigns |
messages:read | List and read messages and their status, price a message or campaign, break an audience down by language, and see campaigns and recurring campaigns |
contacts:read | See contacts |
contacts:write | Add, edit, import and delete contacts |
contact-lists:read | See lists and who is on them |
contact-lists:write | Create, edit and delete lists, and add or remove contacts |
sender-ids:read | See your sender names |
sender-ids:write | Request a new sender name |
opt-outs:read | See who has opted out |
opt-outs:write | Add and remove opt-outs |
webhooks:read | See webhook endpoints and their deliveries |
webhooks:write | Create, edit, test and delete webhook endpoints, and replay deliveries |
billing:read | See your balance |
usage:read | See how many messages were sent and delivered, by day and by country; with billing:read as well, what sending cost |
activity:read | See your organization's activity log |
org:read | See your organization's name and default language |
The portal offers three presets:
- Send only:
messages:sendandmessages:read. It can send messages and campaigns, check their status, and change or cancel campaigns. - Read only: every
:readpermission above. It can see messages, contacts, lists, sender names, opt-outs, webhooks, balance, usage, activity and organization details, and can't change anything. - Full access: every permission above.
A key can never manage members, billing or other keys. Those endpoints answer a key with 403 and the code api_: sign in to the portal to use them.
Roll or revoke a key
All three are on the API keys screen. Disabling and revoking take effect on the key's next request; a rolled key keeps working for the time you choose.
- Roll a key to replace its secret. You get a new key with the same name and permissions, and the old one keeps working for the time you choose: not at all, 1 hour, 24 hours or 7 days. A disabled or expired key gets no extra time. Switch your software over within that time.
- Disable a key to refuse its requests until you enable it again.
- Revoke a key to stop it for good. This can't be undone.
Keep keys out of the browser
Call the API from your server
Anyone who can read a key can send messages with it and spend your credit. Never put a key in a web page or a mobile app. Keep it in your server's environment variables or a secrets manager. The API doesn't accept calls from web pages on other sites, so a key in a browser won't work anyway.
If a key leaks, roll it with no time for the old one, or revoke it.
Related
- Quickstart: check a key, then price and send your first message.
- Errors and limits: what each refusal means, including
401,403and404, and each key's rate limit.