Send messages
Send a WhatsApp, Messenger, or Instagram message from your backend, with the target, message kinds, reply window, and idempotency rules.
Use POST /api/v1/messages to send a message from your own system. The request needs an API key with the messages.send scope. See API keys and scopes.
The route accepts the same message kinds as the Inbox composer, except email. Email is not supported through this route in this version.
Send the request to https://api.watification.com/api/v1/messages:
curl -sS -X POST \
-H 'Authorization: Bearer wtf_xxxxxxxxxxxx_REPLACE_WITH_YOUR_SECRET' \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: order-1042-shipped' \
-d '{
"conversationId": "22222222-2222-4222-8222-222222222222",
"message": { "type": "text", "text": "Your order has shipped." }
}' \
'https://api.watification.com/api/v1/messages'Choose the target
Send exactly one target. Any other combination answers 400 MESSAGE_TARGET_INVALID.
| Target | Fields | Notes |
|---|---|---|
| An existing conversation | conversationId | The message goes to the conversation's contact on its channel. |
| An existing contact on a channel | contactId and channelConnectionId | Uses the open conversation for that contact on that channel, or creates one. |
| A phone number on a WhatsApp channel | phone (E.164, with the leading +) and channelConnectionId | Finds the contact by phone, or creates it. +15555550100 and 15555550100 are the same contact. Never creates a duplicate. |
For a phone target, senderId is optional. It selects the WhatsApp phone number when the channel connection has more than one. If the connection has several numbers and you omit senderId, the route answers 400 SENDER_REQUIRED. Phone targets work for WhatsApp connections only.
Get channelConnectionId values from GET /api/v1/channel-connections. See Contacts and conversations.
Message kinds
Want a ready example? Use Examples.
Every request has one message object. Each example below is the message value only.
Text
{
"type": "text",
"text": "Thanks for your order. Reply here if you have questions."
}Template. Use a template outside the 24-hour reply window. Get templateId values from GET /api/v1/templates?channelConnectionId=.... Only approved WhatsApp templates are listed. Values for parameters follow the template's variables. A text header takes { "type": "text", "text": "..." }. A media header (and each carousel card's header) takes { "type": "media", "mediaId": "..." } from Media, or { "type": "media", "url": "https://..." } for Watification to fetch first. Each media id must be your own and no older than 24 hours, or the send fails with MEDIA_NOT_FOUND. The media kind must match the template's header format.
{
"type": "template",
"templateId": "33333333-3333-4333-8333-333333333333",
"parameters": {
"body": [{ "name": "first_name", "text": "Ana" }, { "text": "ORD-1042" }]
}
}Image, video, document, audio, and sticker. Give exactly one of mediaId (from Media) or url (an https address that Watification fetches). A fetched file counts toward your media storage; when the storage is full the send answers 413 MEDIA_STORAGE_QUOTA_EXCEEDED. caption applies to image, video, and document. filename applies to document.
{
"type": "image",
"mediaId": "44444444-4444-4444-8444-444444444444",
"caption": "Your receipt"
}{
"type": "document",
"url": "https://files.example.com/invoices/ORD-1042.pdf",
"filename": "ORD-1042.pdf"
}Use type video, audio, or sticker in the same way. audio and sticker take no caption.
Interactive buttons
{
"type": "buttons",
"bodyText": "Do you want a delivery update?",
"buttons": [
{ "id": "yes", "title": "Yes" },
{ "id": "no", "title": "No" }
]
}Interactive list
{
"type": "list",
"bodyText": "Choose a branch.",
"buttonText": "Branches",
"sections": [
{
"title": "Cairo",
"rows": [
{
"id": "nasr-city",
"title": "Nasr City",
"description": "Open 9 to 9"
}
]
}
]
}Call-to-action URL button
{
"type": "cta_url",
"bodyText": "Track your order.",
"displayText": "Track order",
"url": "https://shop.example.com/track/ORD-1042"
}Flow. Sends a WhatsApp Flow you have set up in your Meta account. Use the Flow id, name, and the first screen id.
{
"type": "flow",
"bodyText": "Book a delivery slot.",
"flowId": "1234567890",
"flowName": "Delivery slots",
"screen": "SLOT_PICKER",
"cta": "Book now"
}Product, product list, and catalog. These use the product catalog connected to your WhatsApp Business account. You send ids only. Watification reads the products from the catalog.
{
"type": "product",
"catalogId": "5555555555",
"productRetailerId": "SKU-RED-M"
}{
"type": "product_list",
"header": "Our picks",
"bodyText": "Available this week.",
"catalogId": "5555555555",
"sections": [
{ "title": "Shirts", "productRetailerIds": ["SKU-RED-M", "SKU-BLUE-L"] }
]
}{
"type": "catalog",
"bodyText": "Browse the full catalog.",
"thumbnailProductRetailerId": "SKU-RED-M"
}Location
{
"type": "location",
"latitude": 30.0444,
"longitude": 31.2357,
"name": "Head office",
"address": "1 Example Street, Cairo"
}Contacts card
{
"type": "contacts",
"contacts": [
{
"name": {
"formattedName": "Sara Example",
"firstName": "Sara",
"lastName": "Example"
},
"phones": [{ "phone": "+15555550123", "type": "Mobile" }]
}
]
}Location request. Asks the customer to share their location.
{
"type": "location_request",
"text": "Share your location so we can find the nearest branch."
}Reaction. Reacts to a message in the conversation. Use an internal message id, not a Meta id. The emoji value is one emoji. An empty string removes the reaction.
{
"type": "reaction",
"targetMessageId": "66666666-6666-4666-8666-666666666666",
"emoji": "\uD83D\uDC4D"
}Field limits follow the Inbox composer. A value over its limit answers 422 DEVELOPER_INVALID_INPUT.
The 24-hour reply window
On WhatsApp, Messenger, and Instagram, you can send a free-form message only within 24 hours of the customer's last inbound message in the conversation. A non-template message sent after that answers 422 REPLY_WINDOW_CLOSED. The message is not queued. Send an approved template instead. Meta remains the authority: if Meta refuses a send for this reason, the message ends as failed with code 131047.
Marketing opt-out
Sending a marketing template to a contact who has opted out answers 409 CONTACT_MARKETING_OPTED_OUT. Do not retry this request. Send only to contacts who have not opted out.
Idempotency
Send an Idempotency-Key header of up to 128 characters. The header is optional, but send one on every send you might retry. The rules are the same as for OTP:
- The same key with the same body returns the original
202answer. No second message is sent. - The same key with a different body answers
409 IDEMPOTENCY_KEY_REUSED.
Use a key that is unique for each intended message, such as an order id plus the event name. Retry a timed-out request with the same key and the same body.
The 202 answer
A valid request is accepted for sending:
{
"messageId": "66666666-6666-4666-8666-666666666667",
"conversationId": "22222222-2222-4222-8222-222222222222",
"contactId": "77777777-7777-4777-8777-777777777777",
"status": "queued"
}202 means Watification accepted the message, not that the customer received it. Read the status with GET /api/v1/messages/:messageId (scope read), or subscribe to message.sent, message.delivered, message.read, and message.failed in Webhook events.
Messages sent through this route carry the origin api, and the Inbox shows the API chip on them. Agents are not notified about them.
New conversations
When a send creates a conversation, the conversation starts as resolved. This keeps API sends out of the open queue. A customer's reply reopens it. Use conversation status to change it yourself.
Errors
| Code | HTTP | When |
|---|---|---|
API_KEY_SCOPE_MISSING | 403 | The key does not have messages.send. |
MESSAGE_TARGET_INVALID | 400 | The request names zero or several targets. |
SENDER_REQUIRED | 400 | A phone target on a connection with several numbers has no senderId. |
CHANNEL_CONNECTION_NOT_FOUND | 404 | The channel connection does not exist in your workspace. |
CONVERSATION_NOT_FOUND | 404 | The conversation does not exist in your workspace. |
CONTACT_NOT_FOUND | 404 | The contactId does not exist in your workspace. |
CONVERSATION_CHANNEL_FROZEN | 409 | The channel is frozen, so the conversation cannot send. |
REPLY_WINDOW_CLOSED | 422 | A non-template send is outside the 24-hour window. |
CONTACT_MARKETING_OPTED_OUT | 409 | A marketing template was sent to an opted-out contact. |
MESSAGE_RESERVED_ID | 422 | A button payload, button id or list row id starts with wtf:, which is reserved. |
IDEMPOTENCY_KEY_REUSED | 409 | The key was used with a different body. |
See the error reference for every code.