Bulk campaigns
Send to thousands of numbers, schedule, track and stop campaigns, and honour opt-outs.
POST /sms/bulk accepts a whole campaign and returns 202 with counts — not messages. SMS21 turns the recipient list into individual messages in the background, so a campaign can be scheduled, paced against your providers and stopped while it runs. Each created message behaves like any other: same statuses, webhooks, reports and billing.
A campaign needs the sms:bulk scope
sms:bulk (and reports:read to follow progress). Promotional templates may only be sent this way, never through POST /sms/send.Create a campaign
| Field | Type | Description | |
|---|---|---|---|
recipients | array | optional | 1 … 5 000 entries of { to, variables? }. Duplicate numbers are collapsed. Required unless listId is given. |
listId | string | optional | A saved contact list (lst_…) to send to. Mutually exclusive with recipients. |
templateId | string | optional | Approved template (tmpl_…), rendered per recipient with that recipient’s variables. |
text | string | optional | The same free text for every recipient (test keys and destinations without DLT rules). |
senderId | string | optional | With text only; template campaigns use the registered header. |
scheduledAt | string | optional | ISO 8601 send time, up to 30 days ahead. Omit to start immediately. |
name | string | optional | Label shown in reports; never sent to handsets. |
curl -X POST https://sms21.in/v1/sms/bulk \
-H "X-API-Key: $SMS21_API_KEY" -H "Content-Type: application/json" \
-H "Idempotency-Key: october-offers-2026" \
-d '{"name":"October offers","templateId":"tmpl_…",
"recipients":[{"to":"919876543210","variables":{"name":"Asha"}},
{"to":"919812345678","variables":{"name":"Ravi"}}]}'Send to a saved list
Instead of listing recipients on every call, keep an audience as a contact list and send to it withlistId. Each contact’s attributes become that recipient’s variables, so a template sayingHello {{name}} is filled from the list’s name column.
# Upload the audience once (the body is the file)
curl -X POST https://sms21.in/v1/contacts/lists/lst_…/import \
-H "X-API-Key: $SMS21_API_KEY" -H "Content-Type: text/csv" \
--data-binary $'mobile,name\n919876543210,Asha\n919812345678,Ravi\n'
# Then send campaigns to it
curl -X POST https://sms21.in/v1/sms/bulk \
-H "X-API-Key: $SMS21_API_KEY" -H "Content-Type: application/json" \
-d '{"name":"October offers","templateId":"tmpl_…","listId":"lst_…"}'Unsubscribed contacts are never recipients
Follow progress
GET /sms/bulk/{batchId} returns counts as the campaign is expanded, and GET /sms/bulk/{batchId}/recipients gives the outcome per number — the message created, or why the number was skipped. Delivery itself is reported the usual way: webhooks, or GET /messages?batchId={batchId}.
| Status | Meaning |
|---|---|
scheduled | Accepted; waiting for its send time. |
queued | Waiting for a worker. |
expanding | Messages are being created. |
sending | Every recipient became a message; those messages are in flight. |
completed | Every message reached a final status. |
cancelled | Stopped; recipients not yet expanded were cancelled. |
failed | Expansion stopped — see failure.code (for example INSUFFICIENT_BALANCE). |
Skipped recipients
One bad number never rejects a campaign. Numbers on your opt-out list, blocked destinations and countries your account is not enabled for are accepted and reported as skipped with a reason; everything else is sent. Numbers that are not valid mobile numbers are refused when the campaign is created (400 INVALID_RECIPIENT, with the offending positions).
Money and limits
- Funds are held per message during expansion, not reserved for the whole campaign up front.
- If the wallet empties mid-campaign it stops with
INSUFFICIENT_BALANCE; messages already created are still sent, the rest are cancelled. Top up and create a new campaign for the remainder. - The whole recipient list counts against your daily live-message limit when the campaign is accepted.
- Campaigns run on their own queue, so they never delay OTPs or transactional sends.
Stopping a campaign
POST /sms/bulk/{batchId}/cancel cancels recipients that have not been expanded yet. Messages already handed to a provider are not recalled — SMS21 never claims to stop what is already sent.
Opt-out list
Campaigns skip numbers on your suppression list. Add one with POST /suppressions, list them with GET /suppressions and remove one with DELETE /suppressions/{mobile}; the dashboard has the same list under Campaigns → Opt-outs. The list is checked when a campaign is accepted and again when it is sent, so a number added after scheduling is still honoured.
Transactional sends are not filtered
POST /sms/send is for order updates, alerts and OTPs, so it ignores the opt-out list. Keep marketing traffic in campaigns.Common errors
| Code | Fix |
|---|---|
BULK_TOO_MANY_RECIPIENTS | Split the audience into campaigns of at most 5 000 numbers. |
TEMPLATE_REQUIRED | Live SMS to India needs an approved DLT template. |
INVALID_RECIPIENT | Fix the numbers listed in details and resend. |
BATCH_NOT_CANCELLABLE | The campaign already finished, failed or was cancelled. |
INSUFFICIENT_BALANCE | Add funds; create a new campaign for the remaining recipients. |