Security best practices
An API key can send SMS on your account and spend your balance. Treat it like a password to your bank account.
Keys
- Keep keys on your servers. Never in a web page, a mobile app, a public repository, a support ticket or a chat message. The API refuses browser requests (
browser_requests_not_allowed) to protect you. - Store keys as secrets: environment variables or your platform's secret manager. Don't commit
.envfiles. - One key per server or service, with a clear label. If one leaks, you revoke one key, not your whole system.
- The smallest scopes that work. A server that only sends codes needs
messages:sendand nothing else. - Add an IP allowlist to live keys on servers with fixed addresses. A stolen key is then useless anywhere else.
- Give temporary keys an expiry, for contractors and one-off jobs.
- Roll keys from time to time, and whenever someone with access leaves. Rolling keeps the old key working for the time you choose, so nothing breaks.
If a key leaks
- Roll it with "Now" (or revoke it) in Developer, API keys. It stops working at once.
- Put the new key in place.
- Check the key's request log in Developer for anything you don't recognise.
- Tell us at [email protected] if messages were sent that you didn't send.
Owners get an email whenever a key is created or revoked, so a key no one expected is noticed.
Webhooks
- Verify every signature, including the timestamp, before you trust a webhook. See Verify signatures.
- Use HTTPS for your endpoint.
- Keep the secret secret: it's as sensitive as an API key.
- Separate test and live endpoints, each with its own secret.
Your team
- Turn on two-factor authentication for everyone in your organisation. Creating and revoking keys needs a two-factor code.
- Only owners and admins can manage keys. Give people the member role unless they need more.
Your customers' numbers
Phone numbers and message texts are personal data. Kenya's Data Protection Act applies to them, in your systems as in ours.
- Send only to people who expect to hear from you, and respect opt-outs. SemaLink blocks numbers that opted out (
opted_out); remove them on your side too. - Don't log full message texts or numbers where you don't need them.
- Don't put personal data in idempotency keys or references.
Report a security issue
Found a weakness in SemaLink? Email [email protected] with "Security" in the subject. Please give us time to fix it before you share it with anyone else.