Send a unified message
Single send path for all channels: local/international SMS, official WhatsApp, WhatsApp Web (including native groups and images), Telegram bots, and email. `to` is a string for one recipient or an array of up to 100 (official batch). Official WhatsApp template headers accept a file or URL in the same request. HTTP 200 when every item succeeds, 207 on partial batch failure. Use Idempotency-Key for safe retries.
When to use it. Any operational send from your system. For OTP send/resend/verify lifecycle use /api/v2/verification/*.
Code example
Correct: Long local SMS with logical sections
curl --request POST 'https://raselsms.com/api/v2/messages/send' \--header 'X-API-Key: YOUR_API_KEY' \--header 'Content-Type: application/json' \--header 'Idempotency-Key: long-notice-001' \--data '{"to":"+963912345678","channel":"local_sms","messageType":"utility","content":{"text":"البند 1: تم تجهيز طلبك بنجاح، يرجى مراجعة التفاصيل والتواصل مع الدعم عند الحاجة.\n\nالبند 2: تم تجهيز طلبك بنجاح، يرجى مراجعة التفاصيل والتواصل مع الدعم عند الحاجة.\n\nالبند 3: تم تجهيز طلبك بنجاح، يرجى مراجعة التفاصيل والتواصل مع الدعم عند الحاجة.\n\nالبند 4: تم تجهيز طلبك بنجاح، يرجى مراجعة التفاصيل والتواصل مع الدعم عند الحاجة.\n\nالبند 5: تم تجهيز طلبك بنجاح، يرجى مراجعة التفاصيل والتواصل مع الدعم عند الحاجة.\n\nالبند 6: تم تجهيز طلبك بنجاح، يرجى مراجعة التفاصيل والتواصل مع الدعم عند الحاجة.\n\nالبند 7: تم تجهيز طلبك بنجاح، يرجى مراجعة التفاصيل والتواصل مع الدعم عند الحاجة.\n\nالبند 8: تم تجهيز طلبك بنجاح، يرجى مراجعة التفاصيل والتواصل مع الدعم عند الحاجة.\n\nالبند 9: تم تجهيز طلبك بنجاح، يرجى مراجعة التفاصيل والتواصل مع الدعم عند الحاجة.\n\nالبند 10: تم تجهيز طلبك بنجاح، يرجى مراجعة التفاصيل والتواصل مع الدعم عند الحاجة.\n\nالبند 11: تم تجهيز طلبك بنجاح، يرجى مراجعة التفاصيل والتواصل مع الدعم عند الحاجة.\n\nالبند 12: تم تجهيز طلبك بنجاح، يرجى مراجعة التفاصيل والتواصل مع الدعم عند الحاجة."}}'Text and variables are rendered before splitting; each numbered section uses actual SMS units and the account billing policy.
Response example
200 — Long local SMS with logical sections
{ "success": true, "requestId": "msgreq_1739012345678_abc123", "status": "sent", "resolved": { "channel": "local_sms", "provider": null, "senderSource": "account_default" }, "billing": { "estimatedCost": 0.18, "currency": "USD" }, "tracking": { "messageId": "6800msg123def4567890aaaa", "usageId": "6800use123def4567890bbbb", "queueId": null }, "smsMultipart": { "id": "sms_batch_example", "status": "sent", "totalParts": 3, "sentParts": 3, "parts": [ { "index": 1, "state": "sent", "messageDocId": "680000000000000000000001" }, { "index": 2, "state": "sent", "messageDocId": "680000000000000000000002" }, { "index": 3, "state": "sent", "messageDocId": "680000000000000000000003" } ] }}Text and variables are rendered before splitting; each numbered section uses actual SMS units and the account billing policy.
HTTP request
POST /api/v2/messages/send
Request Headers
| Header | Type | Description |
|---|---|---|
| X-API-Key | string | Your Rasel API key. Send it on every documented request except inbound webhooks. * |
| Idempotency-Key | string | Optional unique key for safe retries. Takes precedence over a body idempotencyKey. Successful and failed responses can be replayed for 24 hours when send idempotency is enabled. |
Request body
| Field | Type | Description | Example |
|---|---|---|---|
| to | string | Recipient: E.164 phone, email when channel is email, WhatsApp group JID, Telegram chat id, or a string array of up to 100 recipients for an official batch. * | |
| text | string | Convenience shortcut that maps to free_text with automatic channel selection when content.text is omitted. | |
| channel | enum | Delivery channel. For unified send prefer auto, local_sms, int_sms, official_whatsapp, WhatsApp Web sessions, telegram_bot, or email_user. For verification omit the field for automatic selection; do not send bare sms, whatsapp, or auto. | |
| messageType | enum | Message classification: otp, utility, marketing, or free_text. | |
| content | object | On unified send: message content object (text, otpCode, or email subject). On templates: SMS or message body, or email HTML/text. | |
| content.text | string | Message text. On WhatsApp media this is the caption. | |
| content.otpCode | string | Verification code when messageType is otp and you are not sending a template. | |
| content.subject | string | Email subject when the channel is email. | |
| attachment | object | Outbound media for WhatsApp Web and Telegram bots. Telegram requires a public HTTPS publicUrl. | |
| attachment.type | enum | Media kind: image, video, audio, or document. * | |
| attachment.publicUrl | string | Public HTTPS URL the provider can download. Required for Telegram bot media. | |
| attachment.base64 | string | Raw base64 without a data: prefix. WhatsApp Web only. Telegram ignores it. | |
| attachment.mimetype | string | File MIME type, for example image/png. | |
| attachment.fileName | string | File name shown to the recipient, for example sku-100.png. | |
| attachment.assetId | string | Id of a media file already uploaded for this account. | |
| conversationContext | object | Required for telegram_bot. For WhatsApp Web groups set chatId to the native group JID. accountId is the session name or Telegram bot id. | |
| conversationContext.moduleType | enum | whatsapp_web, whatsapp_official, or telegram_bot. * | |
| conversationContext.accountId | string | WhatsApp Web session name, or the Telegram bot id. * | |
| conversationContext.chatId | string | WhatsApp JID, including groupId@g.us, or the Telegram chat id of a user who started the bot. * | |
| conversationContext.contactId | string | Optional contact id in Rasel. | |
| conversationContext.conversationKey | string | Optional conversation key when you already have one. | |
| template | object | Template reference (id or key), language, variables, and optional per-send header media. | |
| template.id | string | Internal template id from the templates list. | |
| template.key | string | Template name or key, such as order_ready_notice. | |
| template.language | string | Meta template language, such as ar or en. Not used for SMS. | |
| template.variablesIndexed | string-list | Body variables in order: the first value fills {{1}}. | |
| template.buttonVariables | json | URL button suffixes, separate from body variables. index is the button position starting at 0. | |
| template.variablesNamed | json | Named variables as an object of string values. | |
| template.headerAssetId | string | Previously uploaded header media id. Prefer headerMediaUrl in the same request. | |
| template.headerMediaUrl | string | Public URL of the header image, video, or document for this send only. | |
| template.headerMediaType | enum | image, video, or document. Send it with headerMediaUrl when the type is not obvious. | |
| template.header | string | String URL alias of headerMediaUrl. Never send an object. | |
| options | object | Optional send options such as scheduleAt, idempotencyKey, and client metadata. | |
| options.priority | enum | Deprecated and ignored. Sends are already high priority. | |
| options.idempotencyKey | string | Optional retry key. Prefer the Idempotency-Key header. | |
| options.scheduleAt | string | Future ISO 8601 time. Requires a plan that allows scheduled messages. | |
| options.metadata | json | Your own key-value data stored with the message. | |
| sender | object | Optional sender override. If omitted, Rasel uses the default approved sender, then the platform sender. | |
| sender.id | string | Approved SMS sender id. Leave it out to use the default sender. | |
| sender.name | string | Approved SMS sender name. Alternative to sender.id. | |
| sender.officialId | string | Official WhatsApp sender id. Same as officialSenderId. | |
| officialSenderId | string | Official WhatsApp sender id from /api/v2/official-senders. Alias of sender.officialId. Use platform for the default Meta number when listing templates. |
Response Fields
| Field | Type | Description | Example |
|---|---|---|---|
| smsMultipart | object | Local SMS logical sections. sent means accepted for sending, not handset delivery. Resume failed sections from message history; never blindly resend an uncertain section. | |
| smsMultipart.id | string | Resource identifier. | |
| smsMultipart.status | enum | Delivery or record status. On send: sent, queued, or scheduled. On other resources it is the row status filter or value. | |
| smsMultipart.totalParts | integer | Section count after rendering and numbering, capped at 32. | |
| smsMultipart.sentParts | integer | Accepted section count; these are not repeated when failed sections resume. | |
| smsMultipart.parts | json | Each section state and record reference. A section can remain pending after an earlier failure. | |
| success | enum | True when the operation succeeded, or when at least one batch recipient succeeded. | |
| requestId | string | Server-generated request identifier for tracing and support. | |
| status | enum | Delivery or record status. On send: sent, queued, or scheduled. On other resources it is the row status filter or value. | |
| scheduledAt | string | Present when status is scheduled; the deferred delivery time. | |
| resolved | object | Resolved channel, provider, and sender source after routing. | |
| resolved.channel | string | Delivery channel. For unified send prefer auto, local_sms, int_sms, official_whatsapp, WhatsApp Web sessions, telegram_bot, or email_user. For verification omit the field for automatic selection; do not send bare sms, whatsapp, or auto. | |
| resolved.provider | string | Template provider filter or value: user_session, meta, or internal. | |
| resolved.senderSource | string | How the sender was chosen: the id you sent, the account default, or the platform sender. | |
| resolved.channels | string-list | Public channel names when send-on-all-compatible-channels fan-out succeeded on more than one channel. | |
| billing | object | Estimated cost and currency for the send. | |
| billing.estimatedCost | number | Estimated price for this send before final settlement. | |
| billing.currency | string | ISO currency code for estimatedCost, such as USD. | |
| tracking | object | Provider and internal tracking identifiers, including per-channel deliveries on fan-out. | |
| tracking.messageId | string | Rasel message id for this send. | |
| tracking.usageId | string | Usage row id for this charge. | |
| tracking.queueId | string | Queue job id when the send is queued or scheduled. | |
| tracking.deliveries | json | Per-channel tracking when fan-out is enabled. | |
| trial | object | يظهر لحسابات الخطة التجريبية. القالب يبقي {code} ولا يتضمن رمز التحقق نفسه. sent_as_is يعني أن النص المعتمد أُرسل كما هو، substituted يعني أن طلب التحقق استُبدل بهذا النص، وrejected يعني أن المحتوى المخصص لم يُرسل. | |
| trial.active | enum | الحساب على الخطة التجريبية. * | |
| trial.action | enum | ماذا فعل النظام بالنص: أرسله كما هو، أو استبدله بالنص المعتمد، أو رفض المحتوى المخصص. * | |
| trial.template | string | Template reference (id or key), language, variables, and optional per-send header media. * | |
| trial.ignored | string-list | حقول أرسلها العميل ولم تُستخدم في الرسالة التي خرجت. | |
| trial.message | string | Human-readable result message from create or upload. * | |
| trial.upgradeHref | string | مسار ترقية الخطة داخل لوحة التحكم. * | |
| trial.example | object | مثال طلب ينجح أثناء التجربة. يظهر عند الرفض فقط. | |
| trial.example.method | enum | طريقة الطلب في المثال. | |
| trial.example.path | string | مسار الطلب الذي يرسل رمز التحقق بدون نص مخصص. | |
| trial.example.body | object | WhatsApp template body with numbered placeholders. Pair with bodyParameters at create and variablesIndexed at send. | |
| trial.example.body.to | string | Recipient: E.164 phone, email when channel is email, WhatsApp group JID, Telegram chat id, or a string array of up to 100 recipients for an official batch. | |
| trial.example.body.channel | string | Delivery channel. For unified send prefer auto, local_sms, int_sms, official_whatsapp, WhatsApp Web sessions, telegram_bot, or email_user. For verification omit the field for automatic selection; do not send bare sms, whatsapp, or auto. |
Status Codes
| Status | Description |
|---|---|
| 200 | Success. |
| 202 | Accepted and queued. |
| 207 | Batch completed with mixed success and failure. |
| 400 | Invalid request, validation error, or the resource cannot be used in this state. |
| 401 | Missing or invalid API key. |
| 402 | Insufficient wallet balance or plan quota. |
| 403 | Phone not verified, missing permission, or the account cannot perform this action. |
| 409 | Conflict, such as an idempotency key reuse with a different body, or a session that is not ready. |
| 429 | Rate limit exceeded, or the maximum number of verification attempts was reached. |
| 502 | The external provider failed to process the request. |
| 503 | The provider is unavailable or timed out. |
| 413 | Request body exceeds the size limit. |
Cases to handle
- Batch max is 100 recipients. Shared fields (channel, type, content/template, sender) apply to every item.
- Deprecated compat: batchRequests[] is still accepted; document and send to[].
- List accountId and chatId from conversation-context APIs before WhatsApp Web or Telegram sends.
- For official WhatsApp template headers send the file or URL in the same /messages/send request. Template create accepts headerMedia on the same POST /api/v2/templates.
Try it
Optional unique key for safe retries. Takes precedence over a body idempotencyKey. Successful and failed responses can be replayed for 24 hours when send idempotency is enabled.
Choose the channel, the recipient, then the message or one of your templates. Sender names, numbers, and templates come from your signed-in account when the key field is empty, or from the key owner when a key is entered.
Recipient in international format, for example +963912345678. For email, enter the address.
Where the message is delivered. The fields below change with the channel.
Approved SMS sender. Leave empty to use your default sender.
Free text is a normal message. Utility and marketing use a template. OTP can send a code or a template.
The text the recipient sees. With WhatsApp media, this is the caption.
Request
{ "to": "+963912345678", "channel": "user_whatsapp_session", "messageType": "free_text", "content": { "text": "Product photo" }, "attachment": { "type": "image", "publicUrl": "https://cdn.example.com/catalog/sku-100.png", "mimetype": "image/png", "fileName": "sku-100.png" }}Response
Example response
{ "success": true, "requestId": "msgreq_1739012345678_abc123", "status": "sent", "resolved": { "channel": "local_sms", "provider": null, "senderSource": "account_default" }, "billing": { "estimatedCost": 0.18, "currency": "USD" }, "tracking": { "messageId": "6800msg123def4567890aaaa", "usageId": "6800use123def4567890bbbb", "queueId": null }, "smsMultipart": { "id": "sms_batch_example", "status": "sent", "totalParts": 3, "sentParts": 3, "parts": [ { "index": 1, "state": "sent", "messageDocId": "680000000000000000000001" }, { "index": 2, "state": "sent", "messageDocId": "680000000000000000000002" }, { "index": 3, "state": "sent", "messageDocId": "680000000000000000000003" } ] }}