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.
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.
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"} |
Examples: 0571-82123***, 400-123-1234, 10086, 95679 |
Time | {"code": "time"} |
Note Passing parameters in JSON array format is not supported. |
Amount | {"code": "money"} |
|
User nickname | {"code": "user_nick"} |
|
Personal name | {"code": "name"} | Length: 2 to 5 simplified Chinese characters. |
Company or organization name | {"code": "unit_name"} |
|
Address | {"code": "address"} |
|
License plate number | {"code": "license_plate_number"} |
|
Tracking number | {"code": "tracking_number"} |
|
Pickup code | {"code": "pick_up_code"} | Supports a combination of 4 to 8 digits, hyphens, and underscores. |
Other numbers | {"code": "other_number2"} |
|
Link parameter | {"code": "link_param"} |
|
Email address | {"code": "email_address"} |
|
Other (such as name, account, or address) | {"code": "others"} |
|
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.
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"} |
|
Personal name | {"code": "name"} | Length: 2 to 5 simplified Chinese characters. |
Quantity/Amount | {"code": "money"} |
|
Date/Time | {"code": "time"} |
Note Passing parameters in JSON array format is not supported. |
Link parameter | {"code": "link_param"} |
|
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.