Webhooks for WhatsApp Business Accounts

Anda bisa mendapatkan notifikasi realtime ketika ada perubahan pada Akun WhatsApp Business (WABA) Anda dengan berlangganan di level akun WhatsApp Business. Untuk mengatur Webhooks untuk akun WhatsApp Business:

  1. Siapkan endpoint Anda dan atur Webhooks. Langkah-langkah ini sama dengan yang Anda lakukan untuk menyiapkan Webhooks untuk Halaman Facebook.
  2. Berlangganan aplikasi Anda di bawah akun WhatsApp Business Anda. Anda harus berlangganan aplikasi milik bisnis Anda — aplikasi yang dibagikan dengan bisnis Anda tidak dapat menerima notifikasi Webhooks.
  3. Pastikan aplikasi Anda telah menyelesaikan Tinjauan Aplikasi dan meminta izin whatsapp_business_management.

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

Kolom Langganan yang Tersedia

Nama Kolom Deskripsi

account_review_update

Notifikasi dikirimkan kepada Anda ketika Akun WhatsApp Business telah ditinjau.

account_update

Notifikasi dikirimkan kepada Anda ketika telah terjadi perubahan pada akun WhatsApp Business Anda. Perubahan ini dapat mencakup pembaruan nomor telepon, pelanggaran kebijakan, Akun WhatsApp Business telah diblokir, dan banyak lagi.

business_capability_update

Notifikasi dikirimkan kepada Anda ketika kemampuan telah diperbarui. Ini dapat mencakup perubahan untuk jumlah maksimum nomor telepon yang dapat dimiliki WABA atau jumlah percakapan per nomor telepon.

message_template_status_update

Notifikasi dikirimkan kepada Anda ketika template pesan telah disetujui atau ditolak, atau jika telah dinonaktifkan.

messages

Notifikasi dikirimkan kepada Anda ketika bisnis Anda telah menerima pesan dari pelanggan, saat Anda mengirim pesan kepada pelanggan, saat pesan disampaikan kepada pelanggan, dan saat pesan Anda dibaca oleh pelanggan.

phone_number_name_update

Notifikasi dikirimkan kepada Anda ketika nama yang terkait dengan nomor telepon telah disetujui atau ditolak.

phone_number_quality_update

Notifikasi dikirimkan kepada Anda ketika ada pembaruan status terkait kualitas untuk nomor telepon.

security

Notifikasi dikirimkan kepada Anda ketika:

  • Anda meminta untuk menonaktifkan kode verifikasi dua langkah
  • kode verifikasi dua langkah dinonaktifkan
  • kode verifikasi dua langkah diperbarui
  • Kunjungi Referensi Webhooks Akun WhatsApp Business untuk informasi selengkapnya tentang setiap kolom muatan dan Referensi Webhooks Cloud API WhatsApp untuk informasi selengkapnya tentang berbagi jenis notifikasi messages yang dapat Anda terima.

    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
                }
              }
            ]
          }
        ]
      }
    ]

    Enabling mTLS on a WhatsApp Business Account

    Enabling and disabling mTLS is not supported at the Business Phone Number or WABA level. It is only available for object Webhook subscriptions.

    You can enable Mutual TLS (mTLS) on the webhooks you receive from WhatsApp for added security.

    You must verify the callback URL before enabling mTLS. If you have more than one application accessing WhatsApp Cloud API, you will need to enable mTLS for each application.

    mTLS toggle for WhatsApp Business accounts