Receive real-time events via Server-Sent Events (SSE)
Available Events:
connection: Changes in connection statehistory: Receiving message historymessages: New messages receivedmessages_update: Updates to existing messagescall: VoIP call eventscontacts: Contact list updatespresence: Presence status changesgroups: Group modificationslabels: Label managementchats: Chat eventschat_labels: Chat label changesblocks: Blocks/unblocksleads: Lead updatesEstablishes a persistent connection to receive real-time events. This endpoint:
Requires authentication via token
Keeps an HTTP connection open with the client
Sends events as they occur on the server
Supports different event types
Usage example:
const eventSource = new
EventSource('/sse?token=YOUR_TOKEN&events=chats,messages');
eventSource.onmessage = function(event) {
const data = JSON.parse(event.data);
console.log('New event:', data);
};
eventSource.onerror = function(error) {
console.error('Error in SSE connection:', error);
};
Event structure:
{
"type": "message",
"data": {
"id": "3EB0538DA65A59F6D8A251",
"from": "5511999999999@s.whatsapp.net",
"to": "5511888888888@s.whatsapp.net",
"text": "Hello!",
"timestamp": 1672531200000
}
}