Webhooks for WhatsApp Business Accounts

Du kannst Benachrichtigungen über Änderungen an deinem WhatsApp Business Account (WABA) in Echtzeit erhalten, indem du Abos auf der Ebene des WhatsApp Business Accounts abschließt. So richtest du Webhooks für WhatsApp Business Accounts ein:

  1. Richte deinen Endpunkt ein und konfiguriere die Webhooks. Diese Schritte sind dieselben wie beim Einrichten von Webhooks für Facebook-Seiten.
  2. Abonniere deine App unter deinem WhatsApp Business Account. Du musst eine App, die im Besitz deines Unternehmens ist, abonnieren – Apps, die mit deinem Unternehmen geteilt werden, können keine Webhook-Benachrichtigungen empfangen.
  3. Stelle sicher, dass deine App den App Review abgeschlossen und die whatsapp_business_management-Berechtigung angefordert hat.

GET, POST, and DELETE calls to /{whats-app-business-account-id}/subscribed_apps are now subject to Business Use Case Rate Limits.

Set up Your Endpoint and Webhooks

Follow our Webhooks Getting Started guide to create your endpoint and configure your webhook endpoint. When you configure your endpoint, make sure to choose WhatsApp Business Account and subscribe to individual WhatsApp Business Account (WABA) fields.

Available Subscription Fields

Verfügbare Abonnementfelder

Name des Feldes Beschreibung

account_review_update

Wenn ein WhatsApp Business-Konto überprüft wurde, erhältst du eine Benachrichtigung.

account_update

Wenn bei deinem WhatsApp Business-Konto eine Änderung vorgenommen wurde, erhältst du eine Benachrichtigung. Diese Änderung kann beispielsweise eine Aktualisierung der Telefonnummer, ein Richtlinienverstoß, die Sperrung eines WhatsApp Business-Kontos sein und mehr.

business_capability_update

Wenn eine Funktion aktualisiert wurde, erhältst du eine Benachrichtigung. Das kann eine Änderung bei der maximal zulässigen Anzahl von Telefonnummern, über die ein WhatsApp Business-Konto verfügen kann, oder von Unterhaltungen pro Telefonnummer sein.

message_template_status_update

Wenn die Nachrichtenvorlage genehmigt bzw. abgelehnt oder deaktiviert wurde, erhältst du eine Benachrichtigung.

messages

Du erhältst eine Benachrichtigung, wenn dein Unternehmen eine Nachricht von einem*einer Kund*in erhalten hat, wenn du eine Nachricht an eine*n Kund*in sendest, wenn eine Nachricht an eine*n Kund*in zugestellt wird und wenn deine Nachricht von einem*einer Kund*in gelesen wurde.

phone_number_name_update

Wenn der mit einer Telefonnummer verknüpfte Name genehmigt oder abgelehnt wurde, erhältst du eine Benachrichtigung.

phone_number_quality_update

Wenn der Qualitätsstatus einer Telefonnummer aktualisiert wurde, erhältst du eine Benachrichtigung.

security

Eine Benachrichtigung wird an dich gesendet, wenn:

  • du beantragst, dass die Verifizierung in zwei Schritten deaktiviert wird
  • die Verifizierung in zwei Schritten deaktiviert ist
  • die Verifizierung in zwei Schritten aktualisiert wird
  • In der Referenz zu Webhooks für WhatsApp Business-Konten findest du weitere Informationen zu den einzelnen Payload-Feldern. In der Referenz zu Webhooks für WhatsApp Cloud API findest du weitere Informationen zu den verschiedenen Arten von messages-Benachrichtigungen, die du erhalten kannst.

    Subscribe Your App

    You need to subscribe your app to webhooks on a given WABA. We only send notifications if your webhooks-configured app is subscribed to webhooks on a given WABA, and only if the app has permission to edit that WABA.

    Create a Subscription

    Request

    To subscribe your app to webhooks on a WABA, send a POST request to the WABA > Subscribed Apps endpoint.

    curl -X POST 'https://graph.facebook.com/<API_VERSION>/<WHATSAPP_BUSINESS_ACCOUNT_ID>/subscribed_apps' \
    -H 'Authorization: Bearer <ACCESS_TOKEN>'

    Response

    Upon success:

    {
      "success": "true"
    }
    

    Get Subscribed Apps

    To get a list of apps subscribed to webhooks on a WABA, send a GET request to the WABA > Subscribed Apps endpoint.

    Request

    curl 'https://graph.facebook.com/<API_VERSION>/<WHATSAPP_BUSINESS_ACCOUNT_ID>/subscribed_apps' \
    -H 'Authorization: Bearer <ACCESS_TOKEN>'

    Response

    A successful response will list the subscribed apps:

    {
      "data": [
        {
          "whatsapp_business_api_data": {
            "link": "<APP_1_URL>",
            "name": "<APP_1_NAME>",
            "id": "<APP_1_ID>"
          }
        },
        {
          "whatsapp_business_api_data": {
            "link": "<APP_2_URL>",
            "name": "<APP_2_NAME>",
            "id": "<APP_2_ID>"
          }
        },
        ...
      ]
    }

    Delete a subscription

    To unsubscribe your app from webhooks on a WABA, send a DELETE request to the subscribed_apps endpoint.

    Request

    curl -X DELETE 'https://graph.facebook.com/<AP_VERSION>/<WHATSAPP_BUSINESS_ACCOUNT_ID>/subscribed_apps' \
    -H 'Authorization: Bearer <ACCESS_TOKEN>'

    Response

    A successful response will read:

    {
      "success": "true"
    }
    

    Subscribe with Graph API Explorer

    If you don't want to subscribe your app with direct API calls, you can easily do it with Graph API Explorer.

    Replace the me?fields=id,name query with <WHATSAPP_BUSINESS_ACCT_ID>/subscribed_apps. It will subscribe the app you use to send the POST request in Graph Explorer.

    Your app must have permission to edit the WhatsApp business account in order to successfully subscribe.

    Example Webhook payload:

    [
      {
        "object": "whatsapp_business_account",
        "entry": [
          {
            "id": "0",
            "time": 1602782939,
            "changes": [
              {
                "field": "phone_number_name_update",
                "value": {
                  "display_phone_number": "16505551111",
                  "decision": "APPROVED",
                  "requested_verified_name": "WhatsApp",
                  "rejection_reason": null
                }
              }
            ]
          }
        ]
      }
    ]