Este documento se ha actualizado.
La traducción en Español (España) no está disponible todavía.
Actualización del documento en inglés: 14 nov.
Actualización del documento en Español (España): 29 nov. 2023

We are making changes to the WhatsApp Business Platform pricing model. See Pricing Updates on the WhatsApp Business Platform.

Sending Authentication Templates

This document explains how to send approved authentication templates with one-time password buttons.

Request

Use the WhatsApp Business Phone Number > Messages endpoint to send an authentication template message with a one-time password button.

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": [
      {
        "type": "body",
        "parameters": [
          {
            "type": "text",
            "text": "<ONE-TIME PASSWORD>"
          }
        ]
      },
      {
        "type": "button",
        "sub_type": "url",
        "index": "0",
        "parameters": [
          {
            "type": "text",
            "text": "<ONE-TIME PASSWORD>"
          }
        ]
      }
    ]
  }
}

Body Properties

PlaceholderDescriptionSample Value

<CUSTOMER_PHONE_NUMBER>

The customer's WhatsApp phone number.

12015553931

<ONE-TIME PASSWORD>

The one-time password or verification code to be delivered to the customer.


Note that this value must appear twice in the payload.


Maximum 15 characters.

J$FpnYnP

<TEMPLATE_LANGUAGE_CODE>

The template's language and locale code.

en_US

<TEMPLATE_NAME>

The template's name.

verification_code

Response

Upon success, the API will respond with:

{
  "messaging_product": "whatsapp",
  "contacts": [
    {
      "input": "<INPUT>",
      "wa_id": "<WA_ID>"
    }
  ],
  "messages": [
    {
      "id": "<ID>"
    }
  ]
}

Response Contents

PlaceholderDescriptionSample Value

<INPUT>

String

The customer phone number that the message was sent to. This may not match wa_id.

+16315551234

<WA_ID>

String

WhatsApp ID of the customer who the message was sent to. This may not match input.

+16315551234

<ID>

String

WhatsApp message ID. You can use the ID listed after "wamid." to track your message status.

wamid.HBgLMTY1MDM4Nzk0MzkVAgARGBI3N0EyQUJDMjFEQzZCQUMzODMA

Example

Example Request

curl -L 'https://graph.facebook.com/v21.0/105954558954427/messages' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer EAAJB...' \
-d '{
      "messaging_product": "whatsapp",
      "recipient_type": "individual",
      "to": "12015553931",
      "type": "template",
      "template": {
        "name": "verification_code",
        "language": {
          "code": "en_US"
      },
      "components": [
        {
          "type": "body",
          "parameters": [
            {
              "type": "text",
              "text": "J$FpnYnP"
            }
          ]
        },
        {
          "type": "button",
          "sub_type": "url",
          "index": "0",
          "parameters": [
            {
              "type": "text",
              "text": "J$FpnYnP"
            }
          ]
        }
      ]
    }
  }'

Example Response

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