One endpoint for SMS and WhatsApp
Already sending SMS? WhatsApp is the same call with one more field: POST https://api.envoisms.ma/v1/messages, header Authorization: Bearer <API key>, and channel: "whatsapp". The message leaves from your own WhatsApp Business number, connected in the dashboard. With no number connected, the API answers 403 WHATSAPP_NOT_CONNECTED and nothing is charged.
- The same channel parameter in the official Node.js, PHP, Python and Go SDKs
- An Idempotency-Key header makes every send safe to retry: a retry after a timeout never bills twice
- JSON errors with a stable code (error.code) to branch on
Meta templates and the 24-hour window
A Meta-approved template can open a conversation at any time: it is exempt from the service window and priced by the category registered on your account. A free-form message (text, media, list…) is accepted only if the contact wrote to you on WhatsApp in the last 24 hours; otherwise the API answers 400 OUT_OF_24H_WINDOW before anything is charged.
- template: { name, language, components } to start a conversation
- 400 OUT_OF_24H_WINDOW carries window_expired and window_expires_at
- Reactions are not billed
Rich messages: media, lists, buttons
The same endpoint carries every WhatsApp message type: text, media by id or by link, interactive messages (list, buttons, flow, URL button, location request), reactions, contact cards, locations and stickers, with a reply context to quote the customer's message.
- interactive: list, button, flow, cta_url, location_request_message
- Media by id (already uploaded) or by link
- A reply context on any message type
Conversations, webhooks and OTP codes
GET /v1/conversations lists your threads with the expiry time of their 24-hour window, and POST /v1/messages/typing shows a typing indicator while you prepare the reply. Message statuses reach your webhooks signed with HMAC-SHA256 in the X-EnvoiSMS-Signature-256 header. For a one-time code on WhatsApp, POST /v1/verify/send with channel whatsapp goes through EnvoiSMS's shared sender: no number to connect.
- Events message.sent, message.delivered, message.failed, message.undeliverable
- Signature t=<timestamp>,v1=<hex>: reject any delivery older than 5 minutes
- env_test_ sandbox keys: the whole path simulated, nothing delivered or debited