Send And Receive Messages
This page describes how to quickly send and receive WhatsApp messages using the 360dialog Messaging API.
Prerequisites
Ensure the following are available:
An approved WhatsApp Business Account (WABA)
A registered phone number
An API Key
A HTTPS webhook endpoint
Basic knowledge of REST APIs and webhooks is recommended.
Understand Customer Service Windows
WhatsApp messaging follows a conversation-based model using customer service windows.
Free-form messages can only be sent when a customer service window is open.
A customer service window opens when:
A WhatsApp user sends a message to the business phone number, or
A template message is sent and delivered to the user
If no customer service window exists, text messages sent using the API will not be delivered.
To start messaging for the first time, one of the following must occur:
The user messages the business number first, or
A template message is sent to initiate the conversation
Send a message
Option A: Send A Text Message (Customer Service Window Open)
When a customer service window is open, send a free-form text message using the API.
curl \
-X POST https://waba-v2.360dialog.io/messages \
-H "D360-API-KEY: {{api-key}}" \
-H "Content-Type: application/json" \
-d '{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "PHONE_NUMBER",
"type": "text",
"text": {
"body": "Hello from WhatsApp API"
}
}'A successful response returns a message ID confirming the request was accepted.
Option B: Send A Template Message (No Customer Service Window Open)
If no customer service window is open, a template message must be sent to initiate the conversation.
Template messages must be approved before use.
Example template message request:
curl \
-X POST https://waba-v2.360dialog.io/messages \
-H "D360-API-KEY: {{api-key}}" \
-H "Content-Type: application/json" \
-d '{
"messaging_product": "whatsapp",
"to": "PHONE_NUMBER",
"type": "template",
"template": {
"name": "hello_world",
"language": {
"code": "en_US"
}
}
}'Configure A Webhook
Webhooks deliver real-time events when messages are sent or received.
Configure a callback URL that:
Uses HTTPS
Has a valid SSL certificate
Returns HTTP status
200 OKfor all incoming requestsResponds quickly (max latency 80ms)
Webhook events include:
Incoming user messages
Message status updates (
sent,delivered,read)
If a webhook delivery fails or a non-200 status code is returned, the WhatsApp Business Platform retries delivery using exponential backoff for several days (up to 7 days) or until delivery succeeds.
There are several options to set the webhook URL using our API.
Last updated
Was this helpful?