SMS engineering
SMS API Integration Checklist for Engineering Teams
A go-live checklist for integrating an SMS API: number handling, templates, sending architecture, retries, webhooks, fraud limits, monitoring, testing, and compliance.
Sending your first SMS through an API takes ten minutes. Running SMS reliably in production takes a bit more thought. Use this checklist before you go live, or to audit an integration that has grown over time.
Numbers and input
- Store every number in E.164. Normalize input, convert non-Latin digits, strip trunk zeros. See E.164 validation.
- Validate mobile numbers for the countries you serve, so you never pay to send to a landline.
- Default the country code from the user's context, and let them change it.
Templates and content
- Keep templates in one place, versioned, with a language per template.
- Check encoding and segment count with realistic variable values. See SMS character limits.
- Tag each template as transactional or promotional. See transactional vs promotional SMS.
- Register sender IDs in every country that requires it. See alphanumeric sender IDs.
Sending architecture
- Send asynchronously. Put messages on a queue; do not call the SMS API inside a user's HTTP request, except for OTPs where the user is waiting.
- Prioritise transactional traffic over campaigns, with separate queues if volumes are large.
- Respect throughput limits. Spread bulk sends, and handle
429responses with backoff. - Use idempotency keys if your provider supports them, so a retried request does not send twice.
- Retry only safe failures. Retry network errors and
5xxresponses with backoff; do not retry validation errors.
Delivery tracking
- Store the provider's message ID with your own record of the message.
- Receive delivery webhooks, verify signatures, process idempotently, and handle out-of-order events. See handling SMS webhooks.
- Define a timeout after which an undelivered OTP triggers fallback. See SMS to WhatsApp failover.
Security and abuse
- Rate-limit OTP and any user-triggered SMS per number, IP, and device.
- Restrict destinations to countries you serve, and set spending alerts. See SMS pumping prevention.
- Keep API keys in a secret manager, rotate them, and use separate keys per environment.
Monitoring
- Dashboards and alerts for: send volume, delivery rate, delivery time, OTP conversion, and spend, each by country and network.
Testing and compliance
- Test on real devices in your main countries, with real sender IDs and templates, before launch and after any provider change.
And for promotional traffic: consent records, opt-out handling, and sending-hour rules. See opt-out handling, GDPR and SMS marketing, and TCPA basics.
A minimal send function
async function sendSms({ to, templateId, vars, priority = 'transactional' }) {
const phone = normalizeToE164(to)
if (!phone) throw new Error('Invalid phone number')
const message = await db.messages.create({ phone, templateId, vars, priority, status: 'queued' })
await queue.publish(priority, { messageId: message.id })
return message.id
}
The worker then renders the template, calls the provider with an idempotency key, stores the provider's message ID, and lets webhooks update the status.