Contents

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

Live keys must send a templateId to DLT countries (400 TEMPLATE_REQUIRED otherwise). Test keys and destinations without DLT rules may send text.

Send

FieldTypeDescription
tostringrequiredRecipient in international format.
templateIdstringoptionalApproved SMS template (tmpl_…). The sender ID comes from the template.
variablesobjectoptionalValues for the template’s {{variables}} (only with templateId).
textstringoptionalFree text, 1–1600 characters (test keys and non-DLT destinations).
senderIdstringoptionalWith 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

EncodingSingle SMSPer segment when longer
GSM-7 (Latin letters, digits, common symbols)160 characters153 characters
UCS-2 (any other character: Hindi, emoji, curly quotes…)70 characters67 characters
  • SMS is billed per segment; the response reports segments and encoding.
  • 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

CodeFix
TEMPLATE_REQUIREDUse an approved DLT template for this destination.
TEMPLATE_VARIABLES_INVALIDSend every variable, within the length limit (30 characters by default).
TEMPLATE_NOT_APPROVEDWait for approval, or use another template. Also DLT_ENTITY_NOT_APPROVED / SENDER_ID_NOT_APPROVED.
INSUFFICIENT_BALANCEAdd funds to the wallet (live keys only).
DESTINATION_BLOCKEDThe destination is blocked by risk controls; contact SMS21.