Webhooks allows you to receive real-time HTTP notifications of changes to specific objects. For example, we could send you a notification when a user sends you a message or when a message template's status has changed. This prevents you from having to query our APIs for changes to objects that may or may not have happened, and helps you avoid reaching your rate limit.
This document provides an overview of Webhooks and they apply to the WhatsApp Business Management API, WhatsApp Business Platform Cloud API, and WhatsApp Business Platform On-Premises API.
Each API can have multiple object types so whenever you configure a Webhook you must first choose an object type. Since different objects have different fields, you must then subscribe to specific fields for that object type. Whenever there's a change to the value of any object field you have subscribed to, you will receive a notification.
Notifications are sent to you as HTTP POST requests and contain a JSON payload that describes the change.
The following table outlines the information you can receive from Webhooks.
API | Objects |
---|---|
Cloud API |
|
On-Premises API |
|
WhatsApp Business Management API |
|
The following examples represent a Webhook notification sent to you when a user has sent you a text message.
For Cloud API, the object is always whatsapp_business_account
but the field
will be indicative of the type of information being sent.
{ "object": "whatsapp_business_account", "entry": [{ "id": "WHATSAPP_BUSINESS_ACCOUNT_ID", "changes": [{ "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": PHONE_NUMBER, "phone_number_id": PHONE_NUMBER_ID }, "contacts": [{ "profile": { "name": "NAME" }, "wa_id": PHONE_NUMBER }], "messages": [{ "from": PHONE_NUMBER, "id": "wamid.ID", "timestamp": TIMESTAMP, "text": { "body": "MESSAGE_BODY" }, "type": "text" }] }, "field": "messages" }] }] }
For On-Premises API, because your client is sending the Webhook instead of Meta, the object will be contacts
and messages
, errors
, or statuses
and pricing
.
{ "contacts": [{ "profile": { "name": "NAME" }, "wa_id": "WHATSAPP_BUSINESS_ACCOUNT_ID" }], "messages":[{ "from": "PHONE_NUMBER", "id": "wamid.ID", "timestamp": "TIMESTAMP", "text": { "body": "MESSAGE_BODY" }, "type": "text" }] }
All webhooks are sent using HTTPS, so your server must be able to receive and process HTTPS requests, and it must have a valid TLS/SSL certificate installed. Self-signed certificates are not supported.
Learn more about Webhooks for a specific API.