Send SMS (simple)
/v2/sms/send Scopesms:send
The simplest way to send: number, message and sender. JSON or an HTML form post; the key in X-API-Key, Authorization: Bearer or an apikey field.
- Send the final text. SMS21 finds the approved DLT template it matches (or checks it against the one named by
templateid) and recovers the variable values, so you never handle{#var#}or template IDs of ours. - Up to 100 numbers per request, all-or-nothing: every number is validated and every message funded in one step, or nothing is sent.
- Same routing, DLT enforcement, billing, delivery reports and webhooks as
/v1/sms/send. - Test keys may send text that fits no template; messages go to the sandbox and are never charged.
Parameters1
Idempotency-KeyheaderstringMakes the request safe to retry: repeating it with the same key and body returns the original result (with
Idempotent-Replayed: true) instead of sending again. Use one key per logical message, e.g. derived from your order or login-attempt ID. Reusing a key with a different body is409 IDEMPOTENCY_KEY_REUSED.
Body · JSON or form6
apikeystringYour API key, for tools that cannot set the X-API-Key or Authorization header. Never put it in the URL.
numberstring | string[]requiredOne mobile number, several separated by commas (at most 100), or an array. 10-digit Indian numbers may omit 91; spaces, dashes and + are ignored.
messagestringrequiredThe final text, exactly as it should arrive. For live SMS to India it must match one of your approved DLT templates (the one named by
templateid, if sent), each {#var#} filled in.senderstringDLT header (sender ID), e.g. ACMEIN. It must be the matched template’s header; optional when the text fits templates of one header only.
headerstringAlias of
sender.templateidstringThe DLT template ID from the operator DLT portal. Optional: when left out, SMS21 finds the approved template your text matches (the most specific one) and returns its ID in the response.
Responses
- 200
Accepted and queued.
- 400
Invalid numbers, or the text does not fit the DLT template.
Example
Response 400{ "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." } ] }, "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d" } - 401
The API key is missing, malformed, unknown, revoked or expired.
Example
Response 401{ "success": false, "error": { "code": "AUTHENTICATION_REQUIRED", "message": "An API key is required; send it in the X-API-Key header or as \"Authorization: Bearer <key>\"" }, "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d" } - 402
Live keys only: the wallet cannot cover the message. Add funds; retrying will not help.
Example
Response 402{ "success": false, "error": { "code": "INSUFFICIENT_BALANCE", "message": "Insufficient wallet balance" }, "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d" } - 403
The key may not do this: missing scope, IP not on the allow-list, company, project or key suspended by SMS21, project archived, wallet suspended or destination blocked.
Example
Response 403{ "success": false, "error": { "code": "INSUFFICIENT_SCOPE", "message": "This API key does not have the required scope", "details": [ { "message": "requires scope sms:send" } ] }, "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d" } - 404
No template with this DLT template ID is registered.
Example
Response 404{ "success": false, "error": { "code": "NOT_FOUND", "message": "DLT template not found" }, "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d" } - 409
The Idempotency-Key was used for a different request.
Example
Response 409{ "success": false, "error": { "code": "IDEMPOTENCY_KEY_REUSED", "message": "This Idempotency-Key was already used with a different request" }, "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d" } - 429
Rate limited. Wait
Retry-Afterseconds, then retry with the same Idempotency-Key.Example
Response 429{ "success": false, "error": { "code": "RATE_LIMITED", "message": "Rate limit exceeded for this API key" }, "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d" } - 503
Temporarily unavailable, or live sending paused by SMS21. Retry later with the same Idempotency-Key.
Example
Response 503{ "success": false, "error": { "code": "SERVICE_UNAVAILABLE", "message": "Service temporarily unavailable" }, "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d" }
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"}'{
"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_01k55q8y4m3d9v7x2c6b0n1r8t",
"number": "919876543210",
"status": "queued"
}
]
}