Contents

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

Create an API key with sms:bulk (and reports:read to follow progress). Promotional templates may only be sent this way, never through POST /sms/send.

Create a campaign

FieldTypeDescription
recipientsarrayoptional1 … 5 000 entries of { to, variables? }. Duplicate numbers are collapsed. Required unless listId is given.
listIdstringoptionalA saved contact list (lst_…) to send to. Mutually exclusive with recipients.
templateIdstringoptionalApproved template (tmpl_…), rendered per recipient with that recipient’s variables.
textstringoptionalThe same free text for every recipient (test keys and destinations without DLT rules).
senderIdstringoptionalWith text only; template campaigns use the registered header.
scheduledAtstringoptionalISO 8601 send time, up to 30 days ahead. Omit to start immediately.
namestringoptionalLabel 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

A contact who unsubscribed from the list is left out of the campaign entirely — not counted as skipped. The company-wide opt-out list is checked separately and always wins. Re-importing a number updates its attributes but never re-subscribes it.

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}.

StatusMeaning
scheduledAccepted; waiting for its send time.
queuedWaiting for a worker.
expandingMessages are being created.
sendingEvery recipient became a message; those messages are in flight.
completedEvery message reached a final status.
cancelledStopped; recipients not yet expanded were cancelled.
failedExpansion 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

CodeFix
BULK_TOO_MANY_RECIPIENTSSplit the audience into campaigns of at most 5 000 numbers.
TEMPLATE_REQUIREDLive SMS to India needs an approved DLT template.
INVALID_RECIPIENTFix the numbers listed in details and resend.
BATCH_NOT_CANCELLABLEThe campaign already finished, failed or was cancelled.
INSUFFICIENT_BALANCEAdd funds; create a new campaign for the remaining recipients.