Tài liệu này đã được cập nhật.
Bản dịch sang Tiếng Việt chưa hoàn tất.
Cập nhật bằng tiếng Anh: 1 tháng 5
Đã cập nhật bằng Tiếng Việt: 16 tháng 11, 2023

Sending Limited-Time Offer Templates

This document describes how to send an approved limited-time offer template in a template message.

Use the WhatsApp Business Phone Number > Messages endpoint to send an approved limited-time offer template in a template message.

Request Syntax

POST /<WHATSAPP_BUSINESS_PHONE_NUMBER_ID>/messages

Post Body

{
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "<CUSTOMER_PHONE_NUMBER>",
  "type": "template",
  "template": {
    "name": "<TEMPLATE_NAME>",
    "language": {
      "code": "<TEMPLATE_LANGUAGE_CODE>"
    },
    "components": [

      /* Required if template uses header, otherwise omit */
      {
        "type": "header",
        "parameters": [
          {
            "type": "<HEADER_TYPE>",
            "<HEADER_TYPE>": {
              "id": "<HEADER_ASSET_ID>"
            }
          }
        ]
      },

      /* Body and params required if templates uses body params, otherwise omit */
      {
        "type": "body",
        "parameters": [
          <BODY_VARIABLES>
        ]
      },

      /* Required if template uses offer expiration details, otherwise omit */
      {
        "type": "limited_time_offer",
        "parameters": [
          {
            "type": "limited_time_offer",
            "limited_time_offer": {
              "expiration_time_ms": <EXPIRATION_TIME>
            }
          }
        ]
      },

      /* Copy code button optional */
      {
        "type": "button",
        "sub_type": "copy_code",
        "index": 0,
        "parameters": [
          {
            "type": "coupon_code",
            "coupon_code": "<OFFER_CODE>"
          }
        ]
      },

      /* Required */
      {
        "type": "button",
        "sub_type": "url",
        "index": <URL_BUTTON_INDEX>,
        "parameters": [
          {
            "type": "text",
            "text": "<URL_VARIABLE>"
          }
        ]
      }
    ]
  }
}'

Body Properties

PlaceholderDescriptionExample Value

<BODY_VARIABLES>

Array of objects

Required if template body text uses variables.


Body text variable values. Define each variable as an individual object.

{"type":"text","text":"Pablo"},{"type":"text","text":"CARIBE25"}

<CUSTOMER_PHONE_NUMBER>

String

Required.


Phone number of customer who the template message should be sent to.

+16505555555

<EXPIRATION_TIME>

Unix timestamp

Required.


Offer code expiration time as a UNIX timestamp in milliseconds.

1698562800000

<HEADER_ASSET_ID>

Media asset ID

Required.


Uploaded media asset ID. Use the /PHONE_NUMBER_ID/media endpoint to generate an ID.

1602186516975000

<HEADER_TYPE>

String

Required.


Header type used by the template. Values can be image or video.

image

<OFFER_CODE>

String

Required if template uses a copy code button.


Offer code.


Maximum 15 characters.

CARIBE25

<TEMPLATE_LANGUAGE_CODE>

Enum

Required.


The template's language and locale code.

en_US

<TEMPLATE_NAME>

String

Required.


The template's name.

limited_time_offer_caribbean_pkg_2023

<URL_BUTTON_INDEX>

Integer

Required.


URL button index. If the template uses a copy code button, value must be 1.


If the template does not use a copy code button, the value must be 0.

1

<URL_VARIABLE>

String

Required if URL uses a variable.


URL variable value.


No maximum but value counts against URL string maximum of 2000 characters.

n3mtql

Example Request

Example request to send a limited-time offer template that uses:

  • an image header
  • body text variables
  • the offer expiration details
  • a copy code button
  • a URL button with a variable
curl 'https://graph.facebook.com/v17.0/106540352242922/messages' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer EAAJB...' \
-d '
{
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "16505555555",
  "type": "template",
  "template": {
    "name": "limited_time_offer_caribbean_pkg_2023",
    "language": {
      "code": "en_US"
    },
    "components": [
      {
        "type": "header",
        "parameters": [
          {
            "type": "image",
            "image": {
              "id": "1602186516975000"
            }
          }
        ]
      },
      {
        "type": "body",
        "parameters": [
          {
            "type": "text",
            "text": "Pablo"
          },
          {
            "type": "text",
            "text": "CARIBE25"
          }
        ]
      },
      {
        "type": "limited_time_offer",
        "parameters": [
          {
            "type": "limited_time_offer",
            "limited_time_offer": {
              "expiration_time_ms": 1209600000
            }
          }
        ]
      },
      {
        "type": "button",
        "sub_type": "copy_code",
        "index": 0,
        "parameters": [
          {
            "type": "coupon_code",
            "coupon_code": "CARIBE25"
          }
        ]
      },
      {
        "type": "button",
        "sub_type": "url",
        "index": 1,
        "parameters": [
          {
            "type": "text",
            "text": "n3mtql"
          }
        ]
      }
    ]
  }
}'

Example Response

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