Webhooks for WhatsApp Business Accounts

WhatsApp Business 계정을 구독하면 WhatsApp Business 계정(WABA)에 변경 사항이 있는 경우 실시간 알림을 받을 수 있습니다. WhatsApp Business 계정에 대한 Webhooks 설정 방법은 다음과 같습니다.

  1. 엔드포인트를 설정하고 Webhooks를 구성합니다. 이 단계는 Facebook 페이지용 Webhooks를 설정할 때와 동일합니다.
  2. WhatsApp Business 계정으로 앱을 구독합니다. 비즈니스에서 소유한 앱을 구독해야 합니다. 비즈니스와 공유된 앱은 Webhooks 알림을 받을 수 없습니다.
  3. 앱이 앱 검수를 완료하고 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

사용 가능한 구독 필드

필드 이름 설명

account_review_update

WhatsApp Business 계정이 검토되면 알림을 전송합니다.

account_update

WhatsApp Business 계정에 대한 변경 사항이 발생하면 알림을 전송합니다. 이 변경 사항에는 전화번호 업데이트, 정책 위반, WhatsApp Business 계정 차단 등이 포함될 수 있습니다.

business_capability_update

기능이 업데이트되면 알림을 전송합니다. 여기에는 WABA에 등록할 수 있는 최대 전화번호 개수 또는 전화번호당 대화 건수가 포함될 수 있습니다.

message_template_status_update

메시지 템플릿이 승인 또는 거부되거나 비활성화되면 알림을 전송합니다.

messages

비즈니스가 고객으로부터 메시지를 받은 경우, 고객에게 메시지를 보내는 경우, 고객에게 메시지가 전달되는 경우, 그리고 고객이 메시지를 읽은 경우 비즈니스에 알림이 전송됩니다.

phone_number_name_update

전화번호와 연결된 이름이 승인 또는 거부되면 알림을 전송합니다.

phone_number_quality_update

전화번호의 품질 관련 상태에 업데이트가 있으면 알림을 전송합니다.

security

다음과 같은 경우에 알림을 전송합니다.

  • 2단계 인증 코드 비활성화 요청
  • 2단계 인증 코드가 비활성화됨
  • 2단계 인증 코드가 업데이트됨
  • 각 페이로드 필드에 대한 자세한 내용은 WhatsApp Business 계정 Webhooks 참고 자료 를 참조하고, 수신할 수 있는 다양한 유형의 messages 알림에 대한 자세한 내용은 WhatsApp 클라우드 API Webhooks 참고 자료 를 참조하세요.

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