Send a WhatsApp text
/v1/whatsapp/send Scopewhatsapp:send
Free-form (session) text through the WhatsApp Business Platform, optionally with an image, video or document (media, with text as the caption). WhatsApp only delivers it within 24 hours of the recipient's last message to you; outside that window the message is rejected — use a template. With the WhatsApp Official plugin active, messages are sent from your own WhatsApp Business Account, using the templates synced from it; 409 WA_ACCOUNT_NOT_CONNECTED means the plugin is on but no account is connected.
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.
Body3
tostringrequiredRecipient in international format.
textstringrequiredDelivered only within 24 hours of the recipient's last message to you; otherwise WhatsApp rejects it. With
media, it is the caption (max 1024 characters).mediaWaMediaA file sent with the message;
textbecomes its caption (max 1024 characters). SMS21 downloads it from a public https URL when the message is sent (no redirects).3 nested fields
typestringrequiredimage: JPEG, PNG or WebP · video: MP4 or 3GPP · document: any file but HTML.
imagevideodocumenturlstring (uri)requiredfilenamestringDocuments: the name the recipient sees.
Responses
- 202
Accepted and queued.
- 400
Invalid request.
Example
Response 400{ "success": false, "error": { "code": "INVALID_RECIPIENT", "message": "The recipient is not a valid mobile number", "details": [ { "field": "to", "message": "to must be a mobile number in international format, e.g. 919876543210" } ] }, "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" } - 409
Conflicting state.
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/v1/whatsapp/send" \
-H "X-API-Key: $SMS21_API_KEY" \
-H "Content-Type: application/json" \
-d '{"to":"919876543210","text":"Your table is ready."}'{
"success": true,
"messageId": "msg_01k55q8y4m3d9v7x2c6b0n1r8t",
"status": "queued",
"channel": "whatsapp",
"type": "transactional",
"environment": "live",
"to": "919876543210",
"templateId": null,
"whatsappTemplateId": null,
"segments": 1,
"encoding": "gsm7",
"failure": null,
"queuedAt": "2026-09-15T10:30:00.000Z",
"submittedAt": null,
"sentAt": null,
"deliveredAt": null,
"failedAt": null
}