Graph API Version

WhatsApp Message Template

Represents a specific message template. Make the API call to the message template ID.

To find a message template ID, call https://graph.facebook.com/v17.0/{whatsapp-business-account-ID}/message_templates.

For more information on how to use the API, see WhatsApp Business Management API.

Reading

Retrieves information about the message template

Example

Requirements

  • whatsapp_business_management permission

  • whatsapp_business_messaging permission

  • public_profile permission

  • WHATSAPP MESSAGE TEMPLATE ID

  • USER ACCESS TOKEN

Request

curl -i -X GET \
 "https://graph.facebook.com/LATEST-VERSION/WHATS-APP-MESSAGE-TEMPLATE-ID?access_token=USER-ACCESS-TOKEN"
GraphRequest request = GraphRequest.newGraphPathRequest(
  accessToken,
  "/WHATS-APP-MESSAGE-TEMPLATE-ID",
  new GraphRequest.Callback() {
    @Override
    public void onCompleted(GraphResponse response) {
      // Insert your code here
    }
});

request.executeAsync();
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
    initWithGraphPath:@"/WHATS-APP-MESSAGE-TEMPLATE-ID"
           parameters:nil
           HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    // Insert your code here
}];

Response

{
  "name": "shiptest",
  "components": [
    {
      "type": "BODY",
      "text": "testing"
    }
  ],
  "language": "en_US",
  "status": "REJECTED",
  "category": "TRANSACTIONAL",
  "id": "WHATS-APP-MESSAGE-TEMPLATE-ID"
}

Parameters

This endpoint doesn't have any parameters.

Fields

FieldDescription
id
numeric string

ID

category
enum

The category type of the message template

components
list<WhatsAppBusinessHSMWhatsAppHSMComponentGet>

An array of JSON objects describing the message template components.

language
string

The language (and locale) of the element translation

message_send_ttl_seconds
integer

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

The message template name

previous_category
enum

Previous category of the template. See Template Categories.

quality_score

Quality score of the HSM

rejected_reason
enum

The reason the message template was rejected

enum {ABUSIVE_CONTENT, INVALID_FORMAT, NONE, PROMOTIONAL, TAG_CONTENT_MISMATCH, SCAM}

status
enum

The status of the message template

enum {APPROVED, IN_APPEAL, PENDING, REJECTED, PENDING_DELETION, DELETED, DISABLED, PAUSED, LIMIT_EXCEEDED}

Edges

EdgeDescription

compare

Error Codes

ErrorDescription
100Invalid parameter
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.

Creating

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

Parameters

ParameterDescription
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 your template from being rejected for miscategorization. See Template Categories.

category
enum {UTILITY, MARKETING, AUTHENTICATION}

Template category. See Template Categories.

Required
components
array<JSON object>

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


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

Required
type
enum {HEADER, BODY, FOOTER, BUTTONS}

Component type.

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

Button type.

Required
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

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

Required
name
string

Template name.

Required

Return Type

This endpoint supports read-after-write and will read the node to which you POSTed.
Struct {
id: numeric string,
status: enum,
category: enum,
}

Error Codes

ErrorDescription
100Invalid parameter
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.
192Invalid phone number
200Permissions error
200002HSM Template creation failed

Updating

Example

Requirements

  • whatsapp_business_management permission

  • whatsapp_business_messaging permission

  • public_profile permission

  • WHATSAPP MESSAGE TEMPLATE ID

  • USER ACCESS TOKEN

Request

Formatted for readability.

curl -i -X POST \
 "https://graph.facebook.com/LATEST-VERSION/WHATS-APP-MESSAGE-TEMPLATE-ID?components=typeBODYtextYourpackagehasbeenshipped.Itwillbedeliveredin1businessdays.&
access_token=USER-ACCESS-TOKEN"
GraphRequest request = GraphRequest.newPostRequest(
  accessToken,
  "/WHATS-APP-MESSAGE-TEMPLATE-ID",
  new JSONObject("{\"components\": \"[\\n  {\\n    \\\"type\\\": \\\"BODY\\\",\\n    \\\"text\\\": \\\"Your package has been shipped. It will be delivered in {{1}} business days.\\\"\\n  }\\n]\"}"),
  new GraphRequest.Callback() {
    @Override
    public void onCompleted(GraphResponse response) {
      // Insert your code here
    }
});
request.executeAsync();
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
    initWithGraphPath:@"/WHATS-APP-MESSAGE-TEMPLATE-ID"
           parameters:@{ @"components": @"[
  {
    "type": "BODY",
    "text": "Your package has been shipped. It will be shipped in {{1}} business days."
  },
  {
    "type": "FOOTER",
    "text": "This message is from an unverified business."
  }
]",}
           HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    // Insert your code here
}];

Response

{
  "success": true
}
You can't perform this operation on this endpoint.

Deleting

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

Parameters

ParameterDescription
hsm_id
whatsapp business hsm ID

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

name
string

Name of template to be deleted.

Required

Return Type

Struct {
success: bool,
}

Error Codes

ErrorDescription
100Invalid parameter
200Permissions error