Receive messages
How to receive WhatsApp messages in Wazend: read the history and receive messages in real time through webhooks.
You can receive WhatsApp messages in two ways: by reading a chat's message history and by receiving messages in real time through Events.
Read message history
Get a chat's message history:
GET /api/{session}/chats/{chatId}/messages?limit=100[
{
"id": "false_5215551234567@c.us_ABC123",
"timestamp": 1723456789,
"from": "5215551234567@c.us",
"fromMe": false,
"body": "Hello",
"hasMedia": false
}
]Get a specific message
GET /api/{session}/chats/{chatId}/messages/{messageId}?downloadMedia=trueDownload media files
Download the media content (image, audio, video, document) of a message:
Every media message includes media.url in the event: the full URL of the file on your server. Download it with a GET to that URL, sending the X-Api-Key header.
curl -H "X-Api-Key: YOUR_API_KEY" -o file "$MEDIA_URL"Receive messages in real time
To receive messages instantly, set up Events on the session. The available message events are:
message— incoming message.message.any— any message event.message.reaction— reaction to a message.message.ack— delivery/read confirmation.message.ack.group— confirmation from a participant in a group.message.waiting— queued message.message.edited— edited message.message.revoked— deleted message.
Info
See the Events page to learn how to configure the URL, the events and the payload format.