Dokumen ini sudah diperbarui.
Terjemahan ke Bahasa Indonesia belum selesai.
Bahasa Inggris diperbarui: 2 Okt
Bahasa Indonesia diperbarui: 12 Mar

Sending Coupon Code Templates

This document explains how to send approved coupon code templates in a template message.

Request Syntax

Use the WhatsApp Business Phone Number > Messages endpoint to send an approved coupon template in a template message.

POST /<WHATSAPP_BUSINESS_PHONE_NUMBER_ID>/messages

Post Body

{
  "messaging_product": "whatsapp",
  "to": "<TO>",
  "type": "template",
  "template": {
    "name": "<NAME>",
    "language": {
      "code": "<CODE>"
    },
    "components": [
      ... // Additional components, if using
      {
        "type": "button",
        "sub_type": "COPY_CODE",
        "index": <INDEX>,
        "parameters": [
          {
            "type": "coupon_code",
            "coupon_code": "<COUPON_CODE>"
          }
        ]
      }
    ]
  }
}

Properties

PlaceholderDescriptionExample Value

<TO>

String

Required.


The WhatsApp ID or phone number of the customer to send the message to. See Phone Number Formats.

+16505551234

<NAME>

String

Required.


Name of the template to be sent.

coupon_code_fall2023_25off

<CODE>

String

Required.


The template's language and locale code.

en_US

<INDEX>

Integer

Required.


Indicates order in which button should appear, if the template uses multiple buttons.


Buttons are zero-indexed, so setting value to 0 will cause the button to appear first, and another button with an index of 1 will appear next, etc.

0

<COUPON_CODE>

String

Required.


The coupon code to be copied when the customer taps the button. Only accepting alphanumeric characters.

25OFF

Response Syntax

Upon success the API will respond with:

{
  "messaging_product": "whatsapp",
  "contacts": [
    {
      "input": "<WHATSAPP_USER_PHONE_NUMBER>",
      "wa_id": "<WHATSAPP_USER_ID>"
    }
  ],
  "messages": [
    {
      "id": "<WHATSAPP_MESSAGE_ID>",
      "message_status": "<PACING_STATUS>"
    }
  ]
}

Response Properties

PlaceholderDescriptionSample Value

<WHATSAPP_USER_PHONE_NUMBER>

String

WhatsApp user's WhatsApp phone number. May not match wa_id value.

+16505551234

<WHATSAPP_USER_ID>

String

WhatsApp user's WhatsApp ID. May not match input value.

16505551234

<WHATSAPP_MESSAGE_ID>

String

WhatsApp Message ID. This ID appears in associated messages webhooks, such as sent, read, and delivered webhooks.

wamid.HBgLMTY0NjcwNDM1OTUVAgARGBI4MjZGRDA0OUE2OTQ3RkEyMzcA

<PACING_STATUS>

String

Indicates template pacing status. The message_status property is only included in responses when sending a template message that uses a template that is being paced.

wamid.HBgLMTY0NjcwNDM1OTUVAgARGBI4MjZGRDA0OUE2OTQ3RkEyMzcA

Example Request

curl 'https://graph.facebook.com/v21.0/106540352242922/messages' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer EAAJB...' \
-d '
{
  "messaging_product": "whatsapp",
  "to": "16505551234",
  "type": "template",
  "template": {
    "name": "coupon_code_fall2023_25off",
    "language": {
      "code": "en_US"
    },
    "components": [
      {
        "type": "body",
        "parameters": [
          {
            "type": "text",
            "text": "25OFF"
          },
          {
            "type": "text",
            "text": "25%"
          }
        ]
      },
      {
        "type": "button",
        "sub_type": "COPY_CODE",
        "index": 1,
        "parameters": [
          {
            "type": "coupon_code",
            "coupon_code": "25OFF"
          }
        ]
      }
    ]
  }
}'

Example Response

{
  "messaging_product": "whatsapp",
  "contacts": [
    {
      "input": "16505551234",
      "wa_id": "16505551234"
    }
  ],
  "messages": [
    {
      "id": "wamid.HBgLMTY1MDM4Nzk0MzkVAgARGBIxRjk1REYzMDBERDE3RUI0RDYA"
    }
  ]
}