This documentation describes how to setup webhooks for the WhatsApp Business API.
Webhooks are one of a few ways web applications can communicate with each other. It allows you to send real-time data from one application to another whenever a given event occurs. You can use the webhook to determine to which endpoint we should forward the real-time data (or also known as Notifications).
Whenever that trigger event occurs, the WhatsApp Business API client sees the event, collects the data, and immediately sends a notification (user-defined HTTP callbacks) to the webhook URL specified in the application settings. Some example events are:
- updating the status of sent messages
- indicating when you receive a message
Only HTTPS webhook URLs on port 443 are valid.
It is important that your webhook returns an HTTPS 200 OK response to any notifications. Otherwise we consider that notification as failed and try again after a short delay.
Never process incoming messages and notifications in the callback handler!
Only use asynchronous handling of callbacks - acknowledge immediately after receiving the callback, then process.
All incoming messages will automatically shown as delivered (two grey ticks).
To make them appear as read (two colored ticks), you have to mark the messages as read.
1. Set Webhook URL
The webhook URL is a URL where the WhatsApp Business API sends the notifications to, triggered by specific events.
The webhook URL can either be:
- the URL from your own application
- or the partner
submit an entity to the specified resource.
Example setting webhook with Basic Auth:
If the webhook URL needs to be authorized by user, USER and PASS should be provided in the header Authorization that contains Basic base64(USER:PASS).
Request body example for USER=testuser and PASS=testpass
2. Get Webhook URL
If the webhook URL is already set up as described above, you can send a GET request to get the URL.
requests a representation of the specified resource.