Send a message
Send one SMS, or one WhatsApp message from your own connected WhatsApp Business number (channel whatsapp: templates, text, media by id or link, interactive list/button/flow/cta_url/location_request_message, reactions, contact cards, locations, stickers, and a reply context on any of them). WhatsApp rule: a message that is not a template may only be sent to a contact who wrote to your number in the last 24 hours; otherwise it is refused with 400 OUT_OF_24H_WINDOW before anything is charged. Reactions are not billed. To show a typing indicator while you prepare a reply, see POST /messages/typing. Without a connected number, WhatsApp OTPs are available via /verify/send with channel whatsapp. Sending one-time codes? /verify/send manages the full OTP lifecycle (generation, delivery, validation, expiry) and is the recommended path; if you generate codes yourself and send them here, tag the request with metadata purpose: "otp" to enable the automatic one-shot re-send over an alternate SMS route on delivery failure (see the sms_otp example).
Request
- Base URL: https://api.envoisms.ma/v1
- URL: https://api.envoisms.ma/v1/messages
- Auth: HTTP bearer
Headers
Unique string (max 255 chars, e.g. a UUID) making this send safe to retry: the same key replays the original response instead of sending and billing again. See the Idempotency section above.
Request body
Example request
{
"to": "+212612345678",
"message": "Bonjour! Votre commande #1234 est confirmée.",
"from": "MonApp",
"metadata": {
"order_id": "ORD-12345",
"customer_ref": "C-789"
},
"buttons": [
{
"type": "copy",
"text": "Copier le code",
"copy_code": "123456",
"url": "https://example.com",
"phone_number": "+212612345678"
}
],
"template": {
"name": "order_update",
"language": "fr"
},
"image": {
"link": "https://example.com/brochure.pdf"
},
"video": {
"link": "https://example.com/brochure.pdf"
},
"audio": {
"link": "https://example.com/brochure.pdf"
},
"document": {
"link": "https://example.com/brochure.pdf"
},
"sticker": {
"link": "https://example.com/brochure.pdf"
},
"reaction": {
"message_id": "wamid.HBgLMjEyNjEyMzQ1Njc4FQIAEhgg",
"emoji": "👍"
},
"contacts": [
{
"name": {
"formatted_name": "Service client"
},
"phones": [
{
"phone": "+212522000000",
"type": "WORK"
}
]
}
],
"location": {
"latitude": 33.5731,
"longitude": -7.5898,
"name": "Agence Casablanca",
"address": "Bd Zerktouni, Casablanca"
},
"context": {
"message_id": "wamid.HBgLMjEyNjEyMzQ1Njc4FQIAEhgg"
}
}Response
Message queued
Example response
{
"id": "msg_8f2da1b2c3d4e5f6a7b8c9d0",
"to": "+212612345678",
"status": "queued",
"cost": {
"eur": 0.072,
"mad": 0.79
},
"segments": 1,
"simulated_cost": {
"eur": 0.072,
"mad": 0.79
},
"warnings": [
{
"code": "OUT_OF_24H_WINDOW"
}
]
}Changes
No recorded changes to this operation across all 1 revision of this API.