All Products
Search
Document Center

Chat App Message Service:Create a WhatsApp message template

Last Updated:Feb 26, 2025

Description

QPS limit

You can call this operation up to 50 times per second per account. Requests that exceed this limit are dropped and you will experience service interruptions. We recommend that you take note of this limit when you call this operation.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Authorization

The following table shows the authorization information corresponding to the API operation. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation.

  • Operation: the value that you can use in the Action element to specify the operation on a resource.

  • Access level: the access level of each operation. The levels are read, write, and list.

  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation.

  • The required resource types are highlighted.

  • If the permissions cannot be granted at the resource level, "All resources" is used in the Resource type column of the operation.

  • Condition key: the condition keys that are defined by the Alibaba Cloud service.

  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.

Operation

Access level

Resource type

Condition key

Associated operation

cams:CreateChatappTemplate

Write

  • All Resources*

None

None

Request parameters

Parameter

Type

Required

Description

Example

Category

String

Yes

The category of the message template. Valid values:

  • UTILITY

  • MARKETING

  • AUTHENTICATION

UTILITY

Components

Object

Yes

The components of the message template.

Note

When Category is set to AUTHENTICATION, Components cannot be set to HEADER. When Type is set to BODY or FOOTER, the text content must be empty.

-

Type

String

Yes

The component type. Valid values:

  • BODY

  • HEADER

  • FOOTER

  • BUTTONS

  • CAROUSEL

  • LIMITED_TIME_OFFER

Note

In a WhatsApp message template, a BODY component cannot exceed 1,024 characters in length. A HEADER or FOOTER component cannot exceed 60 characters in length.

BODY

Text

String

No

The text of the message that you want to send.

Note

If Category is set to AUTHENTICATION, this parameter must be empty.

hello

Format

String

No

The type of the media resource. Valid values:

  • TEXT

  • IMAGE

  • DOCUMENT

  • VIDEO

TEXT

Url

String

No

The URL of the media resource.

Note

The size of the media resource must meet the requirements. For more information about parameters, see the "Supported media types and size limits" section of the Parameters of a message template topic.

https://image.developer.aliyundoc.com

Caption

String

No

The description of the document.

This is a video.

FileName

String

No

The name of the document.

Package video

Buttons

Object

No

The buttons. You can specify this parameter only if you set Type to BUTTONS.

Note

Limits on the number of buttons in a WhatsApp message template

  • A marketing or utility WhatsApp message template can contain up to 10 buttons.

  • A WhatsApp message template can contain only one Call button.

  • A WhatsApp message template can contain up to two URL buttons.

  • In a WhatsApp message template, an Auto-reply button cannot be used together with a Call button or a URL button.

Type

String

Yes

The button type. Valid values:

  • PHONE_NUMBER: Call button

  • URL: URL button

  • QUICK_REPLY: Auto-reply button

  • COPY_CODE: Copy button

  • ONE_TAP: Auto-fill button

  • CATALOG: Catalog button

  • MPM: MPM button

  • Flow: WhatsApp Flow button

  • ZERO_TAP: Zero-tap button

Note

If you set Category to AUTHENTICATION for a WhatsApp message template, only one button is allowed and the type of the button must be COPY_CODE or ONE_TAP. If you set Category to COPY_CODE, Text is required. If you set Type to ONE_TAP, Text is required, as well as SignatureHash, PackageName, and AutofillText. The value of Text is displayed if the desired app is not installed on the device. The value of Text indicates that you must manually copy the verification code.

PHONE_NUMBER

Text

String

No

The display name of the button.

Call Me

PhoneNumber

String

No

The phone number. This parameter is valid only if the button type is PHONE_NUMBER.

+861368897****

Url

String

No

The URL to be accessed when the URL button is tapped.

https://example.com

UrlType

String

No

The URL type. Valid values:

  • static

  • dynamic

static

SignatureHash

String

No

The app signing key hash that WhatsApp uses to load your app. This parameter is required if Category is set to AUTHENTICATION and Type is set to ONE_TAP for a WhatsApp message template.

wi299382

PackageName

String

No

The app package name that WhatsApp uses to load your app. This parameter is required if Category is set to AUTHENTICATION and Type is set to ONE_TAP for a WhatsApp message template.

com.demo

AutofillText

String

No

The text of the Auto-fill button. This parameter is required if Category is set to AUTHENTICATION and Type is set to ONE_TAP for a WhatsApp message template.

Autofill

IsOptOut

Boolean

No

The Unsubscribe button. This parameter is valid if Category is set to MARKETING and the button type is QUICK_REPLY. Marketing messages are not sent to customers if message sending control is configured in the Chat App Message Service console and the customers tap this button.

false

CouponCode

String

No

The promo code. It can contain only letters and digits. You can set this parameter to a variable such as $(couponCode). Specify the value of couponCode when you send a message.

120293

FlowId

String

No

The Flow ID.

479884093605183

FlowAction

String

No

The Flow action.

Valid values:

  • DATA_EXCHANGE

  • NAVIGATE

NAVIGATE

NavigateScreen

String

No

The destination screen. This parameter is required if FlowAction is set to NAVIGATE.

DETAILS

CodeExpirationMinutes

Integer

No

The validity period of the verification code in the WhatsApp message template. Unit: minutes. This parameter is valid only if Category is set to AUTHENTICATION and Type is set to FOOTER. The validity period of the verification code is displayed in the footer.

5

AddSecretRecommendation

Boolean

No

The note indicating that customers do not share verification codes with others. The note is displayed in the message body. This parameter is valid only if Category is set to AUTHENTICATION and Type is set to BODY.

true

HasExpiration

Boolean

No

Specifies whether the promo code has an expiration time. Specify this parameter if Type is set to LIMITED_TIME_OFFER.

true

Cards

Object

No

The carousel cards of the carousel template.

CardComponents

Object

Yes

The components of the carousel card.

Type

String

Yes

The component type. Valid values:

  • BODY

  • HEADER

  • BUTTONS

BODY

Format

String

No

The type of the media resource. This parameter is valid if Type is set to HEADER. Valid values:

  • IMAGE

  • VIDEO

IMAGE

Text

String

No

The body content of the carousel card.

Who is the very powerful team

Url

String

No

The URL of the media resource.

https://alibaba.com/img.png

Buttons

Object

No

The buttons. Specify this parameter only if you set Type to BUTTONS. A carousel card can contain up to two buttons.

Text

String

No

The button text.

Call me

Type

String

Yes

The button type. Valid values:

  • PHONE_NUMBER: Call button

  • URL: URL button

  • QUICK_REPLY: Auto-reply button

PHONE_NUMBER

Url

String

No

The URL to be accessed when the URL button is tapped.

https://alibaba.com/xx

UrlType

String

No

The URL type. Valid values:

  • static

  • dynamic

static

PhoneNumber

String

No

The phone number.

+8613800

Name

String

Yes

The name of the message template.

hello_whatsapp

Language

String

Yes

The language that is used in the message template. For more information, see Language codes.

en

Example

Object

No

The template example.

String

No

The sample variables.

This parameter is passed in by converting its original JSON structure into a String.

{"textVariable":"text"}

TemplateType

String

Yes

The type of the message template.

WHATSAPP

WHATSAPP

CustSpaceId

String

No

The space ID of the user within the independent software vendor (ISV) account.

293483938849493

AllowCategoryChange

Boolean

No

Specifies whether to allow Facebook to automatically change the directory of the template. If you set this parameter to true, the review success rate of the template is improved.

true

MessageSendTtlSeconds

Integer

No

The validity period of the message sent by an authentication template in WhatsApp.

Note

You must provide the WhatsApp Business account (WABA) in advance so that Alibaba Cloud operations staff can add it to the whitelist. Otherwise, the message template fails to be submitted for review.

120

Response parameters

Parameter

Type

Description

Example

-

Object

The returned result.

-

RequestId

String

The request ID.

90E63D28-E31D-1EB2-8939-A94866411B2D

Code

String

The response code.

  • The value OK indicates that the request was successful.

  • Other values indicate that the request failed. For more information, see Error codes.

OK

Message

String

The error message.

User not authorized to operate on the specified resource.

Data

Object

The returned result.

-

TemplateCode

String

The template code.

SMS_232907****

TemplateName

String

The name of the message template.

hello_world

AccessDeniedDetail

String

The details about the access denial.

-

Examples

Sample success response

JSON format

{
  "RequestId": "90E63D28-E31D-1EB2-8939-A94866******",
  "Code": "OK",
  "Message": "User not authorized to operate on the specified resource.",
  "Data": {
    "TemplateCode": "MSG_232907****",
    "TemplateName": "hello_world"
  },
  "AccessDeniedDetail": "None"
}

Error codes

HTTP status code

Error code

Description

400

Product.Unsubscript

You have not subscribed to the specified product.

400

Ram.PermissionDeny

You are not authorized to perform the operation.

400

System.LimitControl

The system is under flow control.

400

Unknown.ResourceOwnerId

The resource does not belong to the current user.

For a list of error codes, see Service error codes.