Skip to content
Codelia SMSDocs
Guides: Authentication

Authentication

API keys

Send your key in the Authorization header of every request:

Authorization: Bearer cdl_live_…
  • A key starts with cdl_live_. The portal shows the whole key once, when you create or roll it. After that it shows only the start, like cdl_live_7h2kq9wmx4ab_…, so you can tell keys apart.
  • 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 401 with the code invalid_api_key. The answer is the same whichever it is.

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/messages

GET /api-key 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_scope, and the message names the permission it needs.

PermissionWhat the key can do
messages:sendSend messages and campaigns, send them again, reschedule, resume or cancel a campaign, and create, change, pause, resume or delete recurring campaigns
messages:readList and read messages and their status, price a message or campaign, break an audience down by language, and see campaigns and recurring campaigns
contacts:readSee contacts
contacts:writeAdd, edit, import and delete contacts
contact-lists:readSee lists and who is on them
contact-lists:writeCreate, edit and delete lists, and add or remove contacts
sender-ids:readSee your sender names
sender-ids:writeRequest a new sender name
opt-outs:readSee who has opted out
opt-outs:writeAdd and remove opt-outs
webhooks:readSee webhook endpoints and their deliveries
webhooks:writeCreate, edit, test and delete webhook endpoints, and replay deliveries
billing:readSee your balance
usage:readSee how many messages were sent and delivered, by day and by country; with billing:read as well, what sending cost
activity:readSee your organization's activity log
org:readSee your organization's name and default language

The portal offers three presets:

  • Send only: messages:send and messages:read. It can send messages and campaigns, check their status, and change or cancel campaigns.
  • Read only: every :read permission 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_key_not_allowed: 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.

  • Quickstart: check a key, then price and send your first message.
  • Errors and limits: what each refusal means, including 401, 403 and 404, and each key's rate limit.