Quick answer
Node.js 18 and later have fetch built in, so sending an SMS needs no npm package. POST JSON to https://whitelabled.securesmsc.com/api/v2/sms/send with the header Authorization: Bearer YOUR_API_KEY and three fields: sender_id (your approved DLT header), recipient (an Indian mobile number) and message (text that matches one of your approved DLT templates). A 200 reply with "success": true and a message_id means the SMS is queued; delivery is reported afterwards. An SMS costs ₹0.15–₹0.20 plus GST, billed per delivered message.
What you need before the first SMS
- An account and an API keySign up at whitelabled.securesmsc.com/register, then create a key under API & Integrations → API Management in the dashboard. Keep it in an environment variable or a secrets manager, never in browser or mobile-app code.
- An approved sender ID and templateIndian rules (DLT) need a registered business, a 6-character header such as
ACMEINand a registered template for every message. We help with DLT registration at no extra charge; see the DLT registration guide. Approval usually takes 2–7 business days. - Node.js 18 or laterThe samples were run on Node.js 24 LTS.
node --env-fileneeds Node 20.6 or later; Express is only needed for the server example.
Check two key settings before you write code.
IP lock. The first IP address that uses a key successfully is added to that key's allowed list automatically. Calls from any other address then get HTTP 403 "IP address not allowed". So if you test from your laptop first, your production server is locked out. Add every server IP, or an IPv4 CIDR range, under API Management → IP Whitelisting before the first call, and use a separate key for each server or integration. Serverless functions and autoscaling groups change IPs: send through a fixed outbound IP (a NAT gateway, for example) and whitelist that.
GET is off for new keys. The status, balance, sender-ID and template calls use GET, and return 403 "GET method is not allowed for this API key" until GET is enabled for the key with the Allow GET Method setting under API Management; if you can't switch it on for your account, ask support. Sending (POST) works without it.
Get a free API key + 100 test SMS. Create an account and generate an API key straight away. Verified businesses also get 100 free test SMS once KYC and DLT mapping are done. No setup fee, no minimum top-up, and credits never expire.
Send your first SMS with fetch
Put the key in a .env file next to your script (and add .env to .gitignore):
SMS_API_KEY=paste-your-api-key-here
SMS_SENDER_ID=ACMEINThen send one SMS. Replace ACMEIN with your own header (without the -S or -T suffix, which operators add) and the text with one of your approved templates, with the variable filled in:
// send-sms.mjs: Node.js 18+ (fetch is built in, nothing to install)
// Run: node --env-file=.env send-sms.mjs
const res = await fetch('https://whitelabled.securesmsc.com/api/v2/sms/send', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.SMS_API_KEY}`,
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
sender_id: 'ACMEIN', // your approved DLT header
recipient: '9876543210', // or "+919876543210"
message: '482910 is your OTP to log in to Acme. Valid for 10 minutes. Do not share it. -Acme',
}),
signal: AbortSignal.timeout(15_000),
});
const body = await res.json().catch(() => ({}));
if (!res.ok || !body.success) {
// Read error_code first (e.g. TEMPLATE_MISMATCH), then error, then message
const code = body.error_code ?? body.error ?? body.message ?? 'Unknown error';
console.error(`HTTP ${res.status} ${code}: ${body.message ?? ''}`, body.errors ?? '');
process.exit(1);
}
console.log('Queued. message_id =', body.data.message_id);$ node --env-file=.env send-sms.mjs
Queued. message_id = 9001
# The same script with a wrong key:
HTTP 401 Unauthorized: Invalid API keyrecipient takes 10 digits or +91 and 10 digits. The message_id is the number to save with your order or login record: you need it to check the delivery status later. "Queued" means the platform accepted the SMS; whether the phone received it comes later, from the status call or the delivery-report webhook. When something goes wrong the API returns "success": false with an error, a message and sometimes an error_code (such as TEMPLATE_MISMATCH) or a list of errors. Read error_code first, then error, then message.
A reusable client: timeouts, retries and HTTP 429
For a real application, put the HTTP details in one place. oss-sms.mjs below is a single file with no dependencies; copy it into your project. It gives you send, sendBulk, status and balance, and handles the cases that cause trouble in production:
- Timeouts. Each call is cancelled after 15 seconds with an
AbortController, so a slow network can't hang your request handler. - Rate limits. Each key allows 60 requests a minute and 10,000 a day by default. Above that the API answers HTTP 429 with a
Retry-Afterheader (60 seconds for the per-minute limit). The client waits and tries again when the wait is no longer thanrateLimitWaitMs(60 seconds by default; set 0 where a user is waiting). A daily-limit 429 is reported, not waited out. - Safe retries. Reads (status, balance) are retried twice with backoff on network errors and 5xx answers. A send is resent only when the API cannot have accepted it: HTTP 429, HTTP 503, or a connection that never opened. A send that timed out or got a 500, 502 or 504 may already be queued, so it is reported instead of resent. That avoids duplicate OTPs and double charges.
- One error type. Every failure is an
SmsApiErrorwithstatus,code(fromerror_code, elseerror, elsemessage),details, the fullbodyand, for 429,retryAfter.
// oss-sms.mjs: a small client for the OnlineSMSService SMS API.
// Node.js 18+, no dependencies. Copy this file into your project.
const BASE_URL = 'https://whitelabled.securesmsc.com/api/v2';
// Connection failures where the request never reached the API, so a POST is safe to resend.
const NOT_SENT = new Set(['ECONNREFUSED', 'ENOTFOUND', 'EAI_AGAIN', 'UND_ERR_CONNECT_TIMEOUT']);
export class SmsApiError extends Error {
constructor(message, { status = 0, code = null, details = null, body = null, retryAfter = null } = {}) {
super(message);
this.name = 'SmsApiError';
this.status = status; // HTTP status; 0 = no response (network error or timeout)
this.code = code; // error_code, else error, else message: "TEMPLATE_MISMATCH", "Unauthorized", "TIMEOUT"...
this.details = details; // field errors (422) or dispatch errors (400) from the API
this.body = body; // the full JSON response, if there was one
this.retryAfter = retryAfter; // seconds to wait, on HTTP 429
}
}
export function createSmsClient({
apiKey = process.env.SMS_API_KEY,
senderId = process.env.SMS_SENDER_ID,
timeoutMs = 15_000,
retries = 2,
rateLimitWaitMs = 60_000, // longest Retry-After to wait out on HTTP 429; 0 = never wait
} = {}) {
if (!apiKey) throw new Error('SMS_API_KEY is not set');
async function request(method, path, payload) {
for (let attempt = 0; ; attempt++) {
const controller = new AbortController();
const timer = setTimeout(() => controller.abort(), timeoutMs);
let res = null, body = null, failure = null;
try {
res = await fetch(BASE_URL + path, {
method,
headers: {
Authorization: `Bearer ${apiKey}`,
Accept: 'application/json',
...(payload && { 'Content-Type': 'application/json' }),
},
body: payload && JSON.stringify(payload),
signal: controller.signal,
});
body = await res.json().catch(() => null);
} catch (err) {
failure = err; // DNS, refused or reset connection, TLS error, or our timeout
} finally {
clearTimeout(timer);
}
const status = res?.status ?? 0;
if (!failure && status < 400 && body?.success) return body.data;
// When to try again. 429: the API refused the call before running it, so resending
// is safe; wait Retry-After seconds (60 for the per-minute limit; a daily-limit 429
// is not worth waiting for). GET: any network error or 5xx. POST: only when the
// request cannot have been accepted (503, or the connection never opened). A POST
// that timed out or got a 500/502/504 may already be queued, so it is not resent.
let wait = 500 * 2 ** attempt + Math.random() * 250;
let retry;
const retryAfter = status === 429 ? Number(res.headers.get('retry-after') ?? body?.retry_after) || 60 : null;
if (status === 429) {
wait = retryAfter * 1000;
retry = wait <= rateLimitWaitMs;
} else if (method === 'GET') {
retry = Boolean(failure) || status >= 500;
} else {
retry = failure ? NOT_SENT.has(failure.cause?.code) : status === 503;
}
if (retry && attempt < retries) {
await new Promise((r) => setTimeout(r, wait));
continue;
}
throw toError(status, body, failure, timeoutMs, retryAfter);
}
}
return {
// One SMS -> { message_id, queue_id, status, estimated_delivery }
send: ({ to, message, ...options }) =>
request('POST', '/sms/send', { sender_id: senderId, recipient: to, message, ...options }),
// One message to 1-1,000 numbers -> { broadcast_id, total_recipients, successful, failed, results }
sendBulk: ({ to, message, ...options }) =>
request('POST', '/sms/send-bulk', { sender_id: senderId, recipients: to, message, ...options }),
// GET calls: new keys get HTTP 403 "GET method is not allowed for this API key" until GET
// is enabled for the key ("Allow GET Method" under API Management; or ask support).
// Status of a message_id (or broadcast_id).
status: (messageId) => request('GET', `/sms/status/${encodeURIComponent(messageId)}`),
// { balance, currency, last_updated }
balance: () => request('GET', '/balance'),
};
}
function toError(status, body, failure, timeoutMs, retryAfter) {
if (failure) {
const timedOut = failure.name === 'AbortError';
return new SmsApiError(
timedOut ? `No response within ${timeoutMs} ms` : `Network error: ${failure.cause?.code ?? failure.message}`,
{ code: timedOut ? 'TIMEOUT' : 'NETWORK' },
);
}
// Error bodies: { success: false, error, message, error_code?, errors?, details?, retry_after? }
const details = body?.errors ?? body?.details ?? null;
const extra = body?.errors ? Object.values(body.errors).flat().join(' ') : '';
const text = [body?.error ?? `HTTP ${status}`, body?.message, extra].filter(Boolean).join(': ');
const code = body?.error_code ?? body?.error ?? body?.message ?? `HTTP ${status}`;
return new SmsApiError(text, { status, code, details, body, retryAfter });
}Using it:
import { createSmsClient, SmsApiError } from './oss-sms.mjs';
const sms = createSmsClient(); // reads SMS_API_KEY and SMS_SENDER_ID
try {
const { message_id } = await sms.send({
to: '9876543210',
message: '482910 is your OTP to log in to Acme. Valid for 10 minutes. Do not share it. -Acme',
});
console.log('Queued', message_id); // save it with your order or login record
} catch (err) {
if (!(err instanceof SmsApiError)) throw err;
console.error(err.status, err.code, err.message);
// e.g. 401 Unauthorized Unauthorized: Invalid API key
// 422 TEMPLATE_MISMATCH Template Verification Failed: ...
// 429 Rate limit exceeded ... (err.retryAfter = seconds to wait)
}OTP login with Express
This Express 5 server has three routes: POST /otp sends a 6-digit code, POST /otp/verify checks it, and GET /sms/dlr receives delivery reports (next section). It accepts numbers in any common format, stores only a SHA-256 hash of the code, expires it after 10 minutes, allows one new code per number every 30 seconds and five attempts per code, and compares codes in constant time. Keep the codes in Redis or your database in production, and also limit requests per IP address.
// server.mjs: POST /otp sends an OTP, POST /otp/verify checks it,
// GET /sms/dlr receives delivery reports. npm install express
import express from 'express';
import { randomInt, createHash, timingSafeEqual } from 'node:crypto';
import { createSmsClient } from './oss-sms.mjs';
// Reads SMS_API_KEY and SMS_SENDER_ID. A user is waiting, so don't sit out a 429.
const sms = createSmsClient({ timeoutMs: 10_000, rateLimitWaitMs: 0 });
const app = express();
app.use(express.json());
// phone -> { hash, expires, sentAt, tries }. Use Redis or your database in production.
const otps = new Map();
const sha256 = (s) => createHash('sha256').update(s).digest();
// "098765 43210", "+91 98765-43210", "919876543210" -> "+919876543210"
function indianMobile(input) {
let d = String(input ?? '').replace(/\D/g, '');
if (d.length === 12 && d.startsWith('91')) d = d.slice(2);
else if (d.length === 11 && d.startsWith('0')) d = d.slice(1);
return /^[6-9]\d{9}$/.test(d) ? '+91' + d : null;
}
app.post('/otp', async (req, res) => {
const phone = indianMobile(req.body?.phone);
if (!phone) return res.status(400).json({ ok: false, error: 'Enter a 10-digit Indian mobile number' });
if (Date.now() - (otps.get(phone)?.sentAt ?? 0) < 30_000) {
return res.status(429).json({ ok: false, error: 'Please wait 30 seconds before asking again' });
}
const otp = String(randomInt(0, 1_000_000)).padStart(6, '0');
try {
// Must match your approved template, e.g.
// "{#num#} is your OTP to log in to Acme. Valid for 10 minutes. Do not share it. -Acme"
const { message_id } = await sms.send({
to: phone,
message: `${otp} is your OTP to log in to Acme. Valid for 10 minutes. Do not share it. -Acme`,
});
otps.set(phone, { hash: sha256(otp), expires: Date.now() + 600_000, sentAt: Date.now(), tries: 0 });
res.json({ ok: true, message_id });
} catch (err) {
console.error('OTP SMS failed:', err.status, err.code, err.message); // log the detail, show a plain message
if (err.status === 429) res.set('Retry-After', String(err.retryAfter ?? 60));
res.status(err.status === 429 ? 503 : 502).json({ ok: false, error: 'Could not send the OTP. Please try again in a minute.' });
}
});
app.post('/otp/verify', (req, res) => {
const phone = indianMobile(req.body?.phone);
const entry = phone && otps.get(phone);
if (!entry || Date.now() > entry.expires || entry.tries >= 5) {
return res.status(400).json({ ok: false, error: 'OTP expired. Please ask for a new one.' });
}
entry.tries++;
const code = String(req.body?.otp ?? '');
if (!/^\d{6}$/.test(code) || !timingSafeEqual(sha256(code), entry.hash)) {
return res.status(400).json({ ok: false, error: 'Wrong OTP' });
}
otps.delete(phone);
res.json({ ok: true });
});
// Delivery reports: the platform makes an HTTP GET to your push URL when a message reaches
// its final status. Set the URL in the dashboard (Webhooks / Push DLR), with your own secret:
// https://your-domain.in/sms/dlr?key=A_LONG_RANDOM_STRING
// It waits 10 seconds for a 2xx and tries once more after 60 seconds, so answer fast and
// make the update safe to repeat.
app.get('/sms/dlr', (req, res) => {
if (!process.env.DLR_KEY || req.query.key !== process.env.DLR_KEY) return res.sendStatus(403);
const { messageid, status, number, date } = req.query; // messageid = the broadcast ID; date is IST
console.log('DLR', { messageid, status, number, date }); // update your database here
res.sendStatus(200);
});
const port = process.env.PORT ?? 3000;
app.listen(port, (err) => {
if (err) throw err; // Express 5 passes listen errors here
console.log('Listening on', port);
});Testing it with curl (the code came from the test SMS):
$ SMS_API_KEY=... SMS_SENDER_ID=ACMEIN DLR_KEY=A_LONG_RANDOM_STRING node server.mjs
Listening on 3000
$ curl -X POST localhost:3000/otp -H 'Content-Type: application/json' -d '{"phone":"+91 98765-43212"}'
{"ok":true,"message_id":9009}
$ curl -X POST localhost:3000/otp/verify -H 'Content-Type: application/json' -d '{"phone":"09876543212","otp":"182152"}'
{"ok":true}Since TRAI's amendment of 18 September 2026, OTPs for log-in, password reset and two-factor authentication are in the Service category, so register your OTP template as Service; it reaches numbers on DND and arrives with -S after your header. More on OTP design in our OTP SMS guide and on the suffixes in what -P, -S, -T and -G mean.
Delivery reports by webhook
Instead of polling, the platform can call your server when each message reaches its final status. Set your push URL in the dashboard under Webhooks (Push DLR); delivery-report push is included on the Business and Enterprise plans. The call is an HTTP GET with four query parameters:
Push URL you enter in the dashboard (Webhooks / Push DLR):
https://your-domain.in/sms/dlr?key=A_LONG_RANDOM_STRING
What the platform calls when a message reaches its final status (HTTP GET):
https://your-domain.in/sms/dlr?key=A_LONG_RANDOM_STRING&messageid=<broadcast ID>&status=delivered&number=<recipient>&date=2026-11-07+10%3A00%3A05messageidis the broadcast ID of the send (a bulk send returns it asbroadcast_id),statusthe final status such asdelivered,failedorrejected,numberthe recipient anddatethe send time in India time.- Only final statuses are pushed. The platform waits 10 seconds for a 2xx answer and tries once more after 60 seconds, so reply at once and make your database update safe to run twice.
- The URL is public, so add your own long random
keyto it and check it, as the/sms/dlrroute inserver.mjsdoes.
Send bulk SMS (1,000 numbers per request)
To send the same text to many numbers, use sendBulk: one request carries 1 to 1,000 numbers and counts once against the rate limit. Split longer lists into batches:
// bulk.mjs: one message to many numbers, 1,000 per request
import { createSmsClient } from './oss-sms.mjs';
const sms = createSmsClient();
const numbers = ['9876543210', '9876543211', '+919876543212' /* ... */];
const message = 'Our Gandhipuram store is closed on 9 November for maintenance. Online orders ship as usual. -Acme Store';
for (let i = 0; i < numbers.length; i += 1000) {
const batch = numbers.slice(i, i + 1000);
const r = await sms.sendBulk({ to: batch, message }); // add route: 'promotional' for marketing (9 AM-9 PM)
console.log(`Batch ${i / 1000 + 1}: ${r.successful} queued, ${r.failed} failed, broadcast ${r.broadcast_id}`);
for (const x of r.results) {
if (x.status === 'failed') console.warn('Not sent:', x.recipient, x.error);
}
// The balance must cover the whole batch. If it doesn't, the API still answers 200 but
// every number is "failed" (e.g. "Insufficient credits ..."): stop and top up.
if (r.successful === 0 && r.failed > 0) break;
}The answer lists each number as queued or failed. Your balance must cover the whole batch: if it doesn't, the API still answers 200 but every number comes back failed (for example "Insufficient credits. Required: 1000, Available: 250"), so check the per-number results, not just the HTTP status. Marketing messages need route: 'promotional', a Promotional template and the 9 AM–9 PM window. For a different text per number, call send for each one and stay within your key's rate limit.
Check delivery status and balance
Both are GET calls, so GET must be enabled for the key first (Allow GET Method). status takes the message_id from a send (a broadcast ID also works) and returns 404 "Message not found" for an unknown ID. Poll gently; for high volumes use the webhook.
// status.mjs: balance, then the delivery status of a message.
// Both are GET calls: enable "Allow GET Method" for the key first, or they return 403.
import { createSmsClient } from './oss-sms.mjs';
const sms = createSmsClient();
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
const { balance, currency } = await sms.balance();
console.log(`Balance: ${balance} ${currency}`);
const { message_id } = await sms.send({
to: '9876543210',
message: '482910 is your OTP to log in to Acme. Valid for 10 minutes. Do not share it. -Acme',
});
// Poll a few times; for high volumes use the delivery-report webhook instead.
async function finalStatus(id, { tries = 5, everyMs = 20_000 } = {}) {
for (let i = 0; i < tries; i++) {
const { status } = await sms.status(id);
if (!/^(queued|processing|sent|submitted to smsc)$/i.test(status)) return status;
await sleep(everyMs);
}
return 'still pending';
}
console.log(message_id, await finalStatus(message_id));Tamil, Hindi and message length
An English SMS (GSM-7) holds 160 characters, or 153 per part when longer. Tamil, Hindi and other Indian scripts use Unicode: 70 characters, or 67 per part. The platform switches to Unicode by itself when the text has any non-ASCII character, so the unicode flag is optional. Watch for curly quotes, the ₹ sign or a pasted emoji in an English template: one such character makes the whole SMS Unicode and can double the number of parts you pay for. Check a text with the SMS character counter.
import { createSmsClient } from './oss-sms.mjs';
const sms = createSmsClient();
// Tamil, Hindi and other Indian scripts: 70 characters per SMS, 67 per part.
// Any non-ASCII character makes the whole SMS Unicode, so `unicode: true` is optional.
const { message_id } = await sms.send({
to: '9876543210',
message: '482910 என்பது உங்கள் Acme உள்நுழைவு OTP. இதை யாருடனும் பகிர வேண்டாம். -Acme',
});
console.log('Queued', message_id);A Tamil or Hindi message must match a template registered in that language.
DLT entity and template IDs
Every SMS must match an approved template, with only the variable parts changed. Under TRAI's direction of 18 November 2025 each variable is tagged with its type, written {#num#}, {#alp#}, {#urg#} and so on on the Vi and BSNL portals. See DLT template variables and test a text against its template with the DLT template checker.
The DLT IDs are optional in the API. Without them, the entity ID saved on your sender ID or account is used and the platform matches your text to your approved templates. If you send both dlt_entity_id and dlt_template_id, the platform skips its own matching and passes the IDs on; the operator still checks the text against that DLT template, so a wrong ID can make the message fail.
import { createSmsClient } from './oss-sms.mjs';
const sms = createSmsClient();
const { message_id } = await sms.send({
to: '+919876543210',
message: 'Your Acme order 48213 has been shipped. Track it at https://acme.in/t/48213 -Acme',
route: 'transactional', // the default; 'promotional' only for marketing
// Optional. With both IDs the platform skips its own template matching and passes
// them on; the operator still checks the text against your DLT template.
dlt_entity_id: '1201000000000000001', // your entity ID from the DLT portal
dlt_template_id: '1207000000000000001', // the DLT ID of the template this text matches
});
console.log('Queued', message_id);TypeScript
Save these types next to oss-sms.mjs and TypeScript picks them up for every import. They were checked with tsc --strict (TypeScript 7.0). Node.js 24 runs .mts files directly; on older versions, compile them with tsc first.
// oss-sms.d.mts: types for oss-sms.mjs (save it next to that file)
export interface SendOptions {
to: string; // "9876543210" or "+919876543210"
message: string; // must match an approved DLT template, max 1,600 characters
sender_id?: string; // overrides SMS_SENDER_ID
route?: 'transactional' | 'promotional';
dlt_entity_id?: string;
dlt_template_id?: string;
unicode?: boolean; // optional: non-ASCII text is sent as Unicode anyway
flash?: boolean;
schedule_at?: string; // a future date and time, e.g. "2026-11-20 10:00:00"
timezone?: string; // default "Asia/Kolkata"
}
export interface BulkOptions extends Omit<SendOptions, 'to'> {
to: string[]; // 1 to 1,000 numbers
}
export interface SendResult {
message_id: number;
queue_id: number;
status: 'queued';
estimated_delivery: string;
}
export interface BulkResult {
broadcast_id: string | null;
total_recipients: number;
successful: number;
failed: number;
results: Array<
| { recipient: string; message_id: number; queue_id: number; status: 'queued' | 'held' }
| { recipient: string; status: 'failed'; error: string }
>;
}
export interface StatusResult {
message_id: number | string;
status: string; // e.g. "queued", "sent", "delivered", "failed"
recipient: string;
sender_id: string;
message: string;
cost: number | string;
created_at: string;
}
export interface BalanceResult {
balance: number;
currency: 'INR';
last_updated: string;
}
export interface ClientOptions {
apiKey?: string;
senderId?: string;
timeoutMs?: number; // default 15,000
retries?: number; // default 2
rateLimitWaitMs?: number; // longest Retry-After to wait out on 429; default 60,000
}
export interface SmsClient {
send(options: SendOptions): Promise<SendResult>;
sendBulk(options: BulkOptions): Promise<BulkResult>;
status(messageId: string | number): Promise<StatusResult>;
balance(): Promise<BalanceResult>;
}
export declare class SmsApiError extends Error {
status: number;
code: string | null;
details: unknown;
body: unknown;
retryAfter: number | null; // seconds, on HTTP 429
}
export declare function createSmsClient(options?: ClientOptions): SmsClient;// otp.mts
import { createSmsClient, SmsApiError, type SendResult } from './oss-sms.mjs';
const sms = createSmsClient({ timeoutMs: 10_000, rateLimitWaitMs: 0 });
export async function sendOtp(phone: string, otp: string): Promise<SendResult | null> {
try {
return await sms.send({
to: phone,
message: `${otp} is your OTP to log in to Acme. Valid for 10 minutes. Do not share it. -Acme`,
});
} catch (err) {
if (!(err instanceof SmsApiError)) throw err;
console.error(err.status, err.code, err.message, err.retryAfter ?? '');
return null;
}
}
console.log(await sendOtp('9876543210', '482910'));Errors and what to do
| HTTP | error / error_code | Meaning and fix | Resent by the client? |
|---|---|---|---|
| 401 | Unauthorized | "API key is required", "Invalid API key", "API key is disabled", "API key has expired" or "Account is not active". Check the key and the account. | No |
| 403 | Forbidden | "IP address not allowed": add the server's IP under IP Whitelisting. "GET method is not allowed for this API key": enable Allow GET Method for the key, or ask support. | No |
| 400 | Invalid sender ID | The header isn't approved on your account. Use it exactly as approved, without the suffix. | No |
| 400 | SMS dispatch failed | See errors. "Template verification failed: Message does not match any approved template" (often with the closest match): fix the text. "Insufficient credits. Required: 1, Available: 0": top up. | No |
| 422 | Validation failed | A field is missing or wrong; errors lists them by field (number format, text over 1,600 characters, a past schedule_at). | No |
| 422 | TEMPLATE_MISMATCH | The same template problem in another form. Compare the text with the template word for word, including spaces and punctuation. | No |
| 404 | Message not found | Status call with an unknown ID, or one from another account. | No |
| 429 | Rate limit exceeded | Too many requests for this key. Wait retry_after seconds (also in the Retry-After header). | Yes, if the wait is within rateLimitWaitMs |
| 500, 502, 504 | Server or gateway error | A send may already be queued: check its status or delivery report before sending again. | Reads only |
| 503 / no connection | Unavailable | The API did not receive the request. | Yes, twice with backoff |
| None | TIMEOUT | No answer in 15 seconds. A send may still be queued: check before resending. | Reads only |
Get a free API key + 100 test SMS. Your key works as soon as you create it; verified businesses get 100 free test SMS after KYC and DLT mapping, so you can try these samples on real phones.
Production checklist
- The API key lives in an environment variable or secrets manager, on the server only.
- One key per server or integration, with its IPs whitelisted before the first call.
- GET is enabled only on keys that need status or balance.
- You save the
message_id(orbroadcast_id) with your own record. - Request handlers send one SMS at a time; campaigns run in a background job queue.
- Your OTP endpoint limits requests per number and per IP address.
- Promotional messages go only between 9 AM and 9 PM, on Promotional templates.
- You log
err.codeanderr.messageand show users a plain message. - Delivery reports update your records, and your handler replies within 10 seconds.
- You watch your balance, so a bulk send isn't refused for lack of credit.
What it costs
One rate covers OTP, transactional and promotional SMS: ₹0.20 per SMS on Starter (up to 10,000 SMS a month) and ₹0.15 on Business (up to 1,00,000 a month), plus 18% GST, with custom pricing above that. You pay per delivered message, with no setup fee, no monthly fee and no minimum top-up, and credits never expire.
Worked example at list prices, not a case study: an app that sends 30,000 one-part OTPs a month is on the Business rate: 30,000 × ₹0.15 = ₹4,500, plus ₹810 GST = ₹5,310 a month. A message that runs to two parts counts as two SMS. See pricing for plan details.