Contents

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 simplev1
TemplateDetected from the text, or the DLT template IDtmpl_…
ContentThe final message textTemplate variables as JSON
BodyJSON or HTML formJSON
API keyX-API-Key or Bearer header, or apikey fieldX-API-Key or Bearer header
NumbersUp to 100 per requestOne per request

Before you send

  1. 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.
  2. Create an API key with the sms:send scope under Developers → API keys. Start with a test key: it sends to the sandbox and is never charged.

Send an SMS

Endpoint
POST https://sms21.in/v2/sms/send
FieldTypeDescription
numberstringrequiredOne number, or up to 100 separated by commas. 9876543210, 919876543210 and +91 98765 43210 all work; duplicates are sent once.
messagestringrequiredThe final text exactly as it should arrive (up to 10 SMS parts).
senderstringoptionalYour 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.
templateidstringoptionalThe DLT template ID (e.g. 1107169876543210123). Optional: left out, SMS21 finds the approved template your text matches and returns its ID.
apikeystringoptionalYour 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

200 OK
{
  "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" }
  ]
}
  • cost is what was held from your wallet for this request; balance is what is left. Failed messages are refunded when your rate includes failure refunds.
  • Keep the id of 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 portalDear {#var#}, your OTP for {#var#} is {#var#}. Valid for 10 minutes.
Your messageDear 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:
400 Bad Request
{
  "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

HTTPCodeMeaning
400TEMPLATE_TEXT_MISMATCHLive SMS to India whose text fits none of your approved templates (or not the one named by templateid).
400INVALID_RECIPIENTOne or more numbers are not valid mobiles; all are listed.
400BULK_TOO_MANY_RECIPIENTSMore than 100 numbers; use bulk campaigns.
401AUTHENTICATION_REQUIREDNo API key in the header or body.
402INSUFFICIENT_BALANCETop up the wallet.
404NOT_FOUNDNo template with this DLT ID is registered for you.
409TEMPLATE_NOT_APPROVEDThe template, header or entity is not approved yet.

Retries without duplicates

Send an 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

Test keys may send text that fits no template. Messages go to the sandbox, follow the same magic numbers as v1 and are never charged.

Every field is also in the API reference under Simple SMS (v2).