SMS & DLT
Transactional SMS with DLT templates, encoding and segments.
POST /sms/send queues one SMS and returns 202 with the message. Delivery happens asynchronously; follow it with webhooks or GET /messages/{messageId}.
DLT templates (India)
Indian regulations (TRAI DLT) require commercial SMS to use a registered entity, sender ID (header) and content template. Register them under DLT in the dashboard exactly as approved on your DLT portal; SMS21 fills in the variables, attaches the registered IDs and refuses content that does not match.
Free text is refused for live SMS to India
templateId to DLT countries (400 TEMPLATE_REQUIRED otherwise). Test keys and destinations without DLT rules may send text.Send
| Field | Type | Description | |
|---|---|---|---|
to | string | required | Recipient in international format. |
templateId | string | optional | Approved SMS template (tmpl_…). The sender ID comes from the template. |
variables | object | optional | Values for the template’s {{variables}} (only with templateId). |
text | string | optional | Free text, 1–1600 characters (test keys and non-DLT destinations). |
senderId | string | optional | With text only: 3–11 letters/digits, or a phone number. |
Send exactly one of templateId or text.
curl -X POST https://sms21.in/v1/sms/send \
-H "X-API-Key: $SMS21_API_KEY" -H "Content-Type: application/json" \
-H "Idempotency-Key: order-1042-shipped" \
-d '{"to":"919876543210","templateId":"tmpl_…","variables":{"order":"1042"}}'Never send twice
Send an Idempotency-Key derived from your own record. If a request times out, repeat it with the same key: SMS21 returns the original message (header Idempotent-Replayed: true) instead of sending again. The Node.js SDK does this automatically for its own retries.
Encoding and segments
| Encoding | Single SMS | Per segment when longer |
|---|---|---|
| GSM-7 (Latin letters, digits, common symbols) | 160 characters | 153 characters |
| UCS-2 (any other character: Hindi, emoji, curly quotes…) | 70 characters | 67 characters |
- SMS is billed per segment; the response reports
segmentsandencoding. - Messages longer than 10 segments are refused (
400 MESSAGE_TOO_LONG). - A single non-GSM character switches the whole message to UCS-2 — watch for pasted curly quotes.
Common errors
| Code | Fix |
|---|---|
TEMPLATE_REQUIRED | Use an approved DLT template for this destination. |
TEMPLATE_VARIABLES_INVALID | Send every variable, within the length limit (30 characters by default). |
TEMPLATE_NOT_APPROVED | Wait for approval, or use another template. Also DLT_ENTITY_NOT_APPROVED / SENDER_ID_NOT_APPROVED. |
INSUFFICIENT_BALANCE | Add funds to the wallet (live keys only). |
DESTINATION_BLOCKED | The destination is blocked by risk controls; contact SMS21. |