Examples for the TemplateRule&TemplateContent parameters

更新时间:
复制 MD 格式

When you call the CreateSmsTemplate API to request an SMS template, refer to this topic to set the TemplateRule and TemplateContent parameters. The variable property names and variable content must comply with the variable specifications.

Captcha

If you call the CreateSmsTemplate API to request a Captcha template, set the TemplateRule and TemplateContent parameters as shown in the following table. The variable property names and variable content must comply with the variable specifications.

Note

Example:

Suppose the template you request is You are applying for mobile registration. Your verification code is: ${code}. It is valid for 5 minutes!, and its variable property is numbers only.

The TemplateRule parameter is set to: {"code": "numberCaptcha"}

The actual value passed for ${code} in the TemplateContent parameter must comply with the variable specifications.

Variable property

Example of the TemplateRule parameter

Variable specifications for the TemplateContent parameter

Numbers only

{"code": "numberCaptcha"}

Single variable, 4 to 6 digits long.

A combination of numbers and letters, or letters only

{"code": "characterWithNumber2"}

Single variable, 4 to 6 characters long.

In addition to the preceding variable specifications, you must also comply with the content specifications for Captcha templates when you call the API to request a Captcha template. For example, the content of a Captcha template for the Chinese mainland must contain one of the following terms: "verification code", "registration code", "check code", or "dynamic code (dynamic password)". For more information about the specifications for Captcha templates, see Captcha template specifications.

Notification messages

If you call the CreateSmsTemplate API to request a notification message template, set the TemplateRule and TemplateContent parameters as shown in the following table. The variable property names and variable content must comply with the variable specifications.

Note

Example:

Suppose you request the template Dear ${username}, your order ${order} requires payment soon.

The TemplateRule parameter is set to: {"username": "name","order": "other_number2"}

The actual values passed for ${username} and ${order} in the TemplateContent parameter must comply with the variable specifications.

Variable property

Example of the TemplateRule parameter

Variable specifications for the TemplateContent parameter

Phone number

{"code": "phone_number2"}

  • Standard landline numbers in the Chinese mainland. Supports a combination of 5 to 13 digits and hyphens. The maximum length is 15 characters.

  • A template can contain a maximum of two contact methods, and their variable values must be fixed.

  • You must fill in the number type and number fields based on your company's actual qualifications. Otherwise, the review will fail.

Examples: 0571-82123***, 400-123-1234, 10086, 95679

Time

{"code": "time"}

  • Must conform to standard system date and time formats. Dates must use the Gregorian calendar. Special symbols, such as underscores, are not supported.

  • Date examples: YYYYMMDD, YYYY-MM-DD, YYYY/MM/DD

  • Time examples: hh:mm:ss, hh:mm

  • Date and interval examples: morning, afternoon, evening

  • Date and time combination examples: YYYYMMDDhh:mm:ss

Note

Passing parameters in JSON array format is not supported.

Amount

{"code": "money"}

  • Supports combinations of numbers and decimal points.

  • Does not support currency symbols such as ¥, $, CNY, or USD.

  • Does not support common quantity units, such as 'items' or 'minutes'.

User nickname

{"code": "user_nick"}

  • Maximum length: 20 characters.

  • Only English, numbers, and simplified Chinese are supported.

  • Common half-width English characters are supported, such as ()@#!$%^&*-_=+{}[];:<'>,./?".

  • All full-width Chinese characters and spaces are not supported.

  • Special characters and emoji are not supported.

  • QQ numbers and WeChat IDs are not supported.

Personal name

{"code": "name"}

Length: 2 to 5 simplified Chinese characters.

Company or organization name

{"code": "unit_name"}

  • Maximum length: 20 characters.

  • Only Chinese and Chinese parentheses are supported.

  • English is not supported.

Address

{"code": "address"}

  • Only simplified Chinese, numbers, English, and common characters (characters found on a standard keyboard) are supported.

  • QQ numbers and WeChat IDs are not supported.

  • Maximum length: 30 characters.

License plate number

{"code": "license_plate_number"}

  • Abbreviation for a province, municipality, or autonomous region, or a military identifier (KA, WJ).

  • Supports a combination of 4 to 6 digits and English letters, and 1 to 2 Chinese characters for special vehicle identifiers, such as Police or Emergency. The maximum length is 10 characters. English letters must be uppercase.

  • QQ numbers and WeChat IDs are not supported.

Tracking number

{"code": "tracking_number"}

  • Supports 8 to 16 digits.

  • Supports a combination of 1 to 3 English letters and 5 to 16 digits.

  • QQ numbers and WeChat IDs are not supported.

Pickup code

{"code": "pick_up_code"}

Supports a combination of 4 to 8 digits, hyphens, and underscores.

Other numbers

{"code": "other_number2"}

  • Supports combinations of numbers and letters. The maximum length is 35 characters. Examples include verification codes, passwords, and order IDs.

  • QQ numbers and WeChat IDs are not supported.

Link parameter

{"code": "link_param"}

  • A template can contain a maximum of one link.

  • Variables cannot contain IP addresses or links.

  • Supports a combination of English letters and numbers. The maximum length is 8 characters.

  • A combination of a shortened link and a variable is not supported. A combination of a top-level domain or official website link and a variable is supported.

    Correct example: aliyun.com/${code}
  • Fully variable links are not supported.

  • QQ numbers and WeChat IDs are not supported.

  • Links to documents are not supported.

Email address

{"code": "email_address"}

  • A standard email address used to send and receive information on the Internet. It consists of a username, the @ symbol, and a domain name.

  • Must start with an English letter or a number. It supports combinations of English letters, numbers, and underscores, and must contain the @ symbol.

  • Length: 7 to 30 characters.

Other (such as name, account, or address)

{"code": "others"}

  • Prohibited content includes QQ numbers, WeChat IDs (Official Accounts), mobile numbers, URLs, landline numbers, miniapps, apps, and links.

  • Maximum length: 35 characters.

For more information about the specifications for notification message templates, see Notification message template specifications.

Promotional messages

If you call the CreateSmsTemplate API to request a promotional message template, set the TemplateRule and TemplateContent parameters as shown in the following table. The variable property names and variable content must comply with the variable specifications.

Note

Example:

Suppose you request the template ${username}, your exclusive ${money} CNY coupon is about to expire. Use it now. To unsubscribe, reply with R.

The TemplateRule parameter is set to: {"username": "name","money": "money"}

The actual values passed for ${username} and ${money} in the TemplateContent parameter must comply with the variable specifications.

Variable property

Example of the TemplateRule parameter

Variable specifications for the TemplateContent parameter

User nickname

{"code": "user_nick"}

  • Maximum length: 20 characters.

  • Only English, numbers, and simplified Chinese are supported.

  • Common half-width English characters are supported, such as ()@#!$%^&*-_=+{}[];:<'>,./?".

  • All full-width Chinese characters and spaces are not supported.

  • Special characters and emoji are not supported.

  • QQ numbers and WeChat IDs are not supported.

Personal name

{"code": "name"}

Length: 2 to 5 simplified Chinese characters.

Quantity/Amount

{"code": "money"}

  • Supports combinations of numbers and decimal points.

  • Does not include currency unit symbols such as ¥, $, CNY, or USD.

  • Common units that represent counts or durations, such as item and minute.

Date/Time

{"code": "time"}

  • Must conform to the standard system date and time format. Dates use the Gregorian calendar. Special symbols such as underscores are not supported.

  • Date format. For example: YYYYMMDD, YYYY-MM-DD, or YYYY/MM/DD

  • Time, such as hh:mm:ss or hh:mm

  • Date and interval examples: morning, afternoon, evening

  • Date and time combination example: YYYYMMDDhh:mm:ss

Note

Passing parameters in JSON array format is not supported.

Link parameter

{"code": "link_param"}

  • A template can contain a maximum of one link.

  • Variables cannot contain IP addresses or links.

  • Supports a combination of English letters and numbers. The maximum length is 8 characters.

  • A combination of a shortened link and a variable is not supported. A combination of a top-level domain or official website link and a variable is supported.

    Correct example: aliyun.com/${code}
  • Fully variable links are not supported.

  • QQ numbers and WeChat IDs are not supported.

  • Links to documents are not supported.

In addition to the preceding variable specifications, you must also comply with the content specifications for promotional message templates when you call the API to request a promotional message template. For example, a promotional message template must end with To unsubscribe, reply with R. For more information about the specifications for promotional message templates, see Promotional message template specifications.