Simple SMS API (v2)
Send with number, message, header and DLT template ID — JSON or a form post, from any language.
The quickest way to send SMS from any language, script or tool: post the number, the final message, your DLT header and the DLT template ID — the same fields other Indian SMS gateways use. It runs on exactly the same platform as /v1/sms/send (routing, billing, delivery reports and webhooks), just with a simpler request.
| v2 simple | v1 | |
|---|---|---|
| Template | Detected from the text, or the DLT template ID | tmpl_… |
| Content | The final message text | Template variables as JSON |
| Body | JSON or HTML form | JSON |
| API key | X-API-Key or Bearer header, or apikey field | X-API-Key or Bearer header |
| Numbers | Up to 100 per request | One per request |
Before you send
- Register your DLT entity, header and templates under DLT & templates in the dashboard, with the same DLT template ID the operator portal gave you. They must be approved for live traffic.
- Create an API key with the
sms:sendscope under Developers → API keys. Start with a test key: it sends to the sandbox and is never charged.
Send an SMS
POST https://sms21.in/v2/sms/send| Field | Type | Description | |
|---|---|---|---|
number | string | required | One number, or up to 100 separated by commas. 9876543210, 919876543210 and +91 98765 43210 all work; duplicates are sent once. |
message | string | required | The final text exactly as it should arrive (up to 10 SMS parts). |
sender | string | optional | Your DLT header, e.g. ACMEIN. header works too. It must be the matched template’s header; you may leave it out when your text fits templates of one header only. |
templateid | string | optional | The DLT template ID (e.g. 1107169876543210123). Optional: left out, SMS21 finds the approved template your text matches and returns its ID. |
apikey | string | optional | Your key, if you cannot send it in the X-API-Key or Authorization: Bearer header. Never put it in the URL. |
curl -X POST https://sms21.in/v2/sms/send \
-H "X-API-Key: $SMS21_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"number": "9876543210",
"message": "Dear Asha, your OTP for Acme is 482913. Valid for 10 minutes.",
"sender": "ACMEIN"
}'Response
{
"success": true,
"status": "queued",
"environment": "live",
"count": 1,
"parts": 1,
"encoding": "gsm7",
"sender": "ACMEIN",
"templateid": "1107169876543210123",
"cost": "0.1500",
"currency": "INR",
"balance": "1249.8500",
"messages": [
{ "id": "msg_01j9…", "number": "919876543210", "status": "queued" }
]
}costis what was held from your wallet for this request;balanceis what is left. Failed messages are refunded when your rate includes failure refunds.- Keep the
idof each message to check its status, or receive delivery reports by webhook. - A request with several numbers is all-or-nothing: if any number is invalid or the wallet cannot cover them all, nothing is sent.
How the DLT template is matched
You send the final text; SMS21 finds your registered template with that DLT ID and checks the text fits it, with each {#var#} filled in. The operators scrub messages the same way, so a message that passes here is one they will accept.
| Text | |
|---|---|
| Registered on the DLT portal | Dear {#var#}, your OTP for {#var#} is {#var#}. Valid for 10 minutes. |
| Your message | Dear Asha, your OTP for Acme is 482913. Valid for 10 minutes. |
- Everything outside the variables must match exactly — spelling, spaces, punctuation.
- Each variable value is at most 30 characters and cannot contain line breaks (the DLT rules).
- If the text does not fit, the error shows the registered text so you can see the difference:
{
"success": false,
"error": {
"code": "TEMPLATE_TEXT_MISMATCH",
"message": "The message does not match the DLT template",
"details": [{
"field": "message",
"message": "must match the registered text exactly, with each {#var#} replaced by a value of at most 30 characters: Dear {#var#}, your OTP for {#var#} is {#var#}. Valid for 10 minutes."
}]
}
}Check status and balance
curl "https://sms21.in/v2/sms/status?id=msg_01j9…,msg_01j8…" \
-H "X-API-Key: $SMS21_API_KEY"
# or POST with the key in the body
curl -X POST https://sms21.in/v2/sms/status -d apikey="$SMS21_API_KEY" -d id=msg_01j9…Status returns each message’s status (queued, submitted, delivered, failed, rejected, expired) with sentAt and deliveredAt; IDs that are not yours report not_found.
Errors
| HTTP | Code | Meaning |
|---|---|---|
| 400 | TEMPLATE_TEXT_MISMATCH | Live SMS to India whose text fits none of your approved templates (or not the one named by templateid). |
| 400 | INVALID_RECIPIENT | One or more numbers are not valid mobiles; all are listed. |
| 400 | BULK_TOO_MANY_RECIPIENTS | More than 100 numbers; use bulk campaigns. |
| 401 | AUTHENTICATION_REQUIRED | No API key in the header or body. |
| 402 | INSUFFICIENT_BALANCE | Top up the wallet. |
| 404 | NOT_FOUND | No template with this DLT ID is registered for you. |
| 409 | TEMPLATE_NOT_APPROVED | The template, header or entity is not approved yet. |
Retries without duplicates
Idempotency-Key header (up to 120 characters) with each request. Retrying with the same key returns the original messages instead of sending again.Test keys
Every field is also in the API reference under Simple SMS (v2).