Cloud API only.
Messages webhooks are sent to the callback URL set on your app, but you can override this by setting an alternate callback URL on your WhatsApp Business Account (WABA) or business phone number.
When a messages webhook is triggered, we will first check if the business phone number associated with the message has an alternate callback URL. If it does, we will send the webhook to the alternate callback URL. If it has no alternate, we will check if the WABA associated with the phone number has an alternate callback URL and send it there. If the WABA also has no alternate, we will then fallback to the app's callback URL.
Before setting an alternate callback URL, make sure your app is subscribed to webhooks for the WABA and verify that your alternate callback endpoint can receive and process messages webhooks correctly.
Use the POST /<WABA_ID>/subscribed_apps endpoint to set an alternate callback URL on a WABA.
POST /<WABA_ID>/subscribed_apps
{ "override_callback_uri":"<WABA_ALT_CALLBACK_URL>", "verify_token":"<WABA_ALT_CALLBACK_URL_TOKEN>" }
Placeholder | Description | Example Value |
---|---|---|
| Required. Alternate callback URL where messages webhooks should be sent. Maximum 200 characters. |
|
| Required. Alternate callback URL verification token. No maximum. |
|
Upon success:
{ "success": true }
curl -X POST \
'https://graph.facebook.com/v19.0
/102290129340398/subscribed_apps' \
-H 'Authorization: Bearer EAAJi...' \
-H 'Content-Type: application/json' \
-d '
{
"override_callback_uri":"https://my-waba-alternate-callback.com/webhook",
"verify_token":"myvoiceismypassport?"
}'
{ "success": true }
Use the GET /<WABA_ID>/subscribed_apps endpoint to get a list of all apps subscribed to webhooks on the WABA. The response should include an override_callback_uri
property and value.
{ "data" : [ { "whatsapp_business_api_data" : { "id" : "670843887433847", "link" : "https://www.facebook.com/games/?app_id=67084...", "name" : "Lucky Shrub" }, "override_callback_uri" : "https://my-waba-alternate-callback.com/webhook" } ] }
Use the POST /<WABA_ID>/subscribed_apps endpoint to subscribe your app to webhooks on the WABA as you normally would (i.e. without any post body parameters). This will remove the alternate endpoint's callback URL from the WABA, and messages webhooks for the WABA will once again be sent to the callback URL set in the App Dashboard.
Use the POST /<BUSINESS_PHONE_NUMBER_ID> endpoint to set an alternate callback URL on the business phone number.
POST /<BUSINESS_PHONE_NUMBER_ID>
{ "webhook_configuration": { "override_callback_uri": "<PHONE_ALT_CALLBACK_URL>", "verify_token": "<PHONE_ALT_CALLBACK_URL_TOKEN>" } }
Placeholder | Description | Example Value |
---|---|---|
| Required. Alternate callback URL where messages webhooks should be sent. Maximum 200 characters. |
|
| Required. Alternate callback URL verification token. No maximum. |
|
Upon success:
{ "success": true }
curl 'https://graph.facebook.com/v19.0
/106540352242922' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer EAAJB...' \
-d '
{
"webhook_configuration": {
"override_callback_uri": "https://my-phone-alternate-callback.com/webhook",
"verify_token": "myvoiceismypassport?"
}
}'
{ "success": true }
Use the GET /<BUSINESS_PHONE_NUMBER_ID> endpoint and request the webhook_configuration
field to verify that the business phone number has an alternate callback URL.
GET /<BUSINESS_PHONE_NUMBER_ID> ?fields=webhook_configuration
Upon success:
{ "webhook_configuration": { "phone_number": "<PHONE_ALT_CALLBACK_URL>", "whatsapp_business_account": "<WABA_ALT_CALLBACK_URL>", "application": "<APP_CALLBACK_URL>" }, "id": "106540352242922" }
Note that whatsapp_business_account
is only included if the WABA associated with the business phone number also has an alternate callback URL set.
curl 'https://graph.facebook.com/v17.0/106540352242922?fields=webhook_configuration' \ -H 'Authorization: Bearer EAAJB...'
{ "webhook_configuration": { "phone_number": "https://my-phone-alternate-callback.com/webhook", "whatsapp_business_account": "https://my-waba-alternate-callback.com/webhook", "application": "https://my-production-callback.com/webhook" }, "id": "106540352242922" }
To delete a business phone number's alternate callback URL, use the POST /<BUSINESS_PHONE_NUMBER_ID> endpoint with the override_callback_uri
property set to an empty string:
{ "webhook_configuration": { "override_callback_uri": "", } }