Versione API Graph

Whats App Business Account Message Templates

Represents a collection of templates on a WhatsApp Business Account. See Templates.

Lettura

Get a list of templates on a WhatsApp Business Account.

Requirements

TypeDescription

Access Tokens

User or System User

Permissions

whatsapp_business_management

Request Syntax

GET /<WHATSAPP_BUSINESS_ACCOUNT_ID>/message_templates
  ?category=<CATEGORY>,
  &content=<CONTENT>,
  &language=<LANGUAGE>,
  &name=<NAME>,
  &name_or_content=<NAME_OR_CONTENT>,
  &quality_score=<QUALITY_SCORE>,
  &status=<STATUS>

Path Parameters

PlaceholderValue

<WHATSAPP_BUSINESS_ACCOUNT_ID>

WhatsApp Business Account ID.

Response

A list of WhatsApp Message Template nodes.

Sample Request

curl 'https://graph.facebook.com/v16.0/102290129340398/message_templates?category=utility' \
-H 'Authorization: Bearer EAAJB...'

Sample Response

{
  "data": [
    {
      "name": "order_delivery_update",
      "components": [
        {
          "type": "HEADER",
          "format": "LOCATION"
        },
        {
          "type": "BODY",
          "text": "Good news {{1}}! Your order #{{2}} is on its way to the location above. Thank you for your order!",
          "example": {
            "body_text": [
              [
                "Mark",
                "566701"
              ]
            ]
          }
        },
        {
          "type": "FOOTER",
          "text": "To stop receiving delivery updates, tap the button below."
        },
        {
          "type": "BUTTONS",
          "buttons": [
            {
              "type": "QUICK_REPLY",
              "text": "Stop Delivery Updates"
            }
          ]
        }
      ],
      "language": "en_US",
      "status": "APPROVED",
      "category": "UTILITY",
      "id": "1667192013751005"
    },
    ...
  ],
  "paging": {
    "cursors": {
      "before": "MAZDZD",
      "after": "MjQZD"
    }
  }
}

Parametri

ParametroDescrizione
category
array<enum {ACCOUNT_UPDATE, PAYMENT_UPDATE, PERSONAL_FINANCE_UPDATE, SHIPPING_UPDATE, RESERVATION_UPDATE, ISSUE_RESOLUTION, APPOINTMENT_UPDATE, TRANSPORTATION_UPDATE, TICKET_UPDATE, ALERT_UPDATE, AUTO_REPLY, TRANSACTIONAL, OTP, UTILITY, MARKETING, AUTHENTICATION}>

The category for a template

content
string

The content for a template

language
array<string>

A list of supported languages that are available for each template

name
string

The name for a message template

name_or_content
string

Returns a list of message templates where the value for name or content match this value

quality_score
array<enum {GREEN, YELLOW, RED, UNKNOWN}>

The quality score for a template

status
array<enum {APPROVED, IN_APPEAL, PENDING, REJECTED, PENDING_DELETION, DELETED, DISABLED, PAUSED, LIMIT_EXCEEDED, ARCHIVED}>

The review status for a template

Campi

La lettura da questo segmento fornirà un risultato formattato JSON:

{ "data": [], "paging": {}, "summary": {} }

data

Una lista di nodi WhatsAppMessageTemplate.

paging

Per ulteriori dettagli sulla paginazione, consulta la Guida su API Graph.

summary

Informazioni aggregate sul segmento, ad esempio i numeri. Specifica i campi per recuperare il parametro del riepilogo (come riepilogo=total_count).

CampoDescrizione
total_count
unsigned int32

The total number of message templates that belong to a WhatsApp Business Account

message_template_count
int32

The current number of message templates that belong to the WhatsApp Business Account

message_template_limit
int32

The maximum number of message templates that can belong to a WhatsApp Business Account

are_translations_complete
bool

The status for template translations

Error Codes

ErroreDescrizione
80008There have been too many calls to this WhatsApp Business account. Wait a bit and try again. For more info, please refer to https://developers.facebook.com/docs/graph-api/overview/rate-limiting.
100Invalid parameter
200Permissions error
190Invalid OAuth 2.0 Access Token

Creazione

You can make a POST request to message_templates edge from the following paths:
When posting to this edge, a WhatsAppMessageTemplate will be created.
TypeDescription

Access Tokens

User or System User

Permissions

whatsapp_business_management

Request Syntax

POST /<WHATSAPP_BUSINESS_ACCOUNT_ID>/message_templates

Path Parameters

PlaceholderValue

<WHATSAPP_BUSINESS_ACCOUNT_ID>

ID of the WhatsApp Business Account to create the template on.

Post Body

See Parameters for property descriptions.

{
  "allow_category_change": <ALLOW_CATEGORY_CHANGE>,
  "name": "<NAME>",
  "language": "<LANGUAGE>",
  "category": "<CATEGORY>",
  "components": [<COMPONENTS>]
}

Response

See Return Type.

Sample Request

curl 'https://graph.facebook.com/v21.0/102290129340398/message_templates' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer EAAJB...' \
-d '
{
  "name": "seasonal_promotion",
  "language": "en",
  "category": "MARKETING",
  "components": [
    {
      "type": "HEADER",
      "format": "TEXT",
      "text": "Our {{1}} is on!",
      "example": {
        "header_text": [
          "Summer Sale"
        ]
      }
    },
    {
      "type": "BODY",
      "text": "Shop now through {{1}} and use code {{2}} to get {{3}} off of all merchandise.",
      "example": {
        "body_text": [
          [
            "the end of August","25OFF","25%"
          ]
        ]
      }
    },
    {
      "type": "FOOTER",
      "text": "Use the buttons below to manage your marketing subscriptions"
    },
    {
      "type":"BUTTONS",
      "buttons": [
        {
          "type": "QUICK_REPLY",
          "text": "Unsubcribe from Promos"
        },
        {
          "type":"QUICK_REPLY",
          "text": "Unsubscribe from All"
        }
      ]
    }
  ]
}'

Sample Response

{
    "id": "594425479261596",
    "status": "PENDING",
    "category": "MARKETING"
}

Parametri

ParametroDescrizione
allow_category_change
boolean

Set to true to allow us to assign a category based on our template guidelines and the template's contents. This can prevent the template status from immediately being set to REJECTED upon creation due to miscategorization.


If omitted, template will not be auto-assigned a category and its status may be set to REJECTED if determined to be miscategorized.


See Template Categories.

category
enum {UTILITY, MARKETING, AUTHENTICATION}

Template category. See Template Categories.

Obbligatorio
components
array<JSON object>

Array of components that make up the template. See Template Components.


For types HEADER, BODY, FOOTER, text is required.

type
enum {GREETING, HEADER, BODY, FOOTER, BUTTONS, CAROUSEL, LIMITED_TIME_OFFER}

Component type.

Obbligatorio
format
enum {TEXT, IMAGE, DOCUMENT, VIDEO, LOCATION}

Component format.

text
string

Required for components with type HEADER,BODY, or FOOTER.


Component text.

buttons
array<JSON object>

Button components to be used in the template.

type
enum {QUICK_REPLY, URL, PHONE_NUMBER, OTP, MPM, CATALOG, FLOW, VOICE_CALL, APP, POSTBACK}

Button type.

Obbligatorio
text
string

Button text.

url
URI

url

phone_number
phone number string

phone_number

example
array<string>

example

flow_id
int64

flow_id

zero_tap_terms_accepted
boolean

zero_tap_terms_accepted

flow_action
enum {NAVIGATE, DATA_EXCHANGE}

flow_action

navigate_screen
string

navigate_screen

supported_apps
array<JSON object>

supported_apps

package_name
string

package_name

Obbligatorio
signature_hash
string

signature_hash

Obbligatorio
example
JSON object

Placeholder examples. Templates will not be approved without examples.

header_text
array<string>

header_text

body_text
array<array<string>>

body_text

header_handle
array<string>

header_handle

language
string

Obbligatorio
library_template_body_inputs
JSON object

Optional data during creation of a template from a library template. These are optional fields for the body component.

add_contact_number
boolean

add_contact_number

add_learn_more_link
boolean

add_learn_more_link

add_security_recommendation
boolean

add_security_recommendation

add_track_package_link
boolean

add_track_package_link

code_expiration_minutes
int64

code_expiration_minutes

library_template_button_inputs
array<JSON object>

Optional data during creation of a template from a library template. These are optional fields for the button component.

type
enum {QUICK_REPLY, URL, PHONE_NUMBER, OTP, MPM, CATALOG, FLOW, VOICE_CALL, APP, POSTBACK}

type

Obbligatorio
phone_number
string

phone_number

url
JSON object

url

base_url
string

base_url

Obbligatorio
url_suffix_example
string

url_suffix_example

otp_type
enum {COPY_CODE, ONE_TAP, ZERO_TAP}

otp_type

zero_tap_terms_accepted
boolean

zero_tap_terms_accepted

supported_apps
array<JSON object>

supported_apps

package_name
string

package_name

Obbligatorio
signature_hash
string

signature_hash

Obbligatorio
library_template_name
string

library_template_name

message_send_ttl_seconds
int64

Time to live for message template sent. If users are offline for more than TTL duration after message template is sent, message will be dropped from message queue and will not be delivered.

Only allowed for authentication message templates.

name
string

Template name.

Obbligatorio
parameter_format
enum {NAMED, POSITIONAL}

The parameter format of the template

sub_category
enum {ORDER_DETAILS, ORDER_STATUS}

Sub category of the template

Tipo di ricavo

Questo endopoint supporta read-after-write e leggerà il nodo in cui hai effettuato una richiesta POST.
Struct {
id: numeric string,
status: enum,
category: enum,
}

Error Codes

ErroreDescrizione
100Invalid parameter
192Invalid phone number
131009Parameter value is not valid
200Permissions error
80008There have been too many calls to this WhatsApp Business account. Wait a bit and try again. For more info, please refer to https://developers.facebook.com/docs/graph-api/overview/rate-limiting.
368The action attempted has been deemed abusive or is otherwise disallowed
190Invalid OAuth 2.0 Access Token

Aggiornamento

Non puoi eseguire questa operazione in questo endpoint.

Eliminazione

You can dissociate a WhatsAppMessageTemplate from a WhatsAppBusinessAccount by making a DELETE request to /{whats_app_business_account_id}/message_templates.
TypeDescription

Access Tokens

User or System User

Permissions

whatsapp_business_management

Request Syntax

DELETE /<WHATSAPP_BUSINESS_ACCOUNT_ID>/message_templates

Path Parameters

PlaceholderValue

<WHATSAPP_BUSINESS_ACCOUNT_ID>

ID of the WhatsApp Business Account that owns the template.

Response

See Return Type.

Sample Request

curl -X DELETE 'https://graph.facebook.com/v21.0/102290129340398/message_templates?name=order_confirmation' \
-H 'Authorization: Bearer EAAJB...'

Sample Response

{
  "success": true
}

Parametri

ParametroDescrizione
hsm_id
numeric string

ID of template to be deleted. Required if deleting a template by ID.

name
string

Name of template to be deleted.

Obbligatorio

Tipo di ricavo

Struct {
success: bool,
}

Error Codes

ErroreDescrizione
100Invalid parameter
200Permissions error
190Invalid OAuth 2.0 Access Token
80008There have been too many calls to this WhatsApp Business account. Wait a bit and try again. For more info, please refer to https://developers.facebook.com/docs/graph-api/overview/rate-limiting.