CreateSmsTemplate
An SMS template defines the content that recipients receive, including variables and template body. You can apply for verification code, notification, or promotional SMS templates based on your business needs. SMS messages can be sent only after the template is approved.
Operation description
-
For details about the changes between the new and original operations, see Announcement on updating signature and template operations for Short Message Service.
-
When applying for SMS templates through the API, allow at least 30 seconds between consecutive requests.
-
Templates applied through the API are synchronized to the Short Message Service console in synchronization. For console-based operations on templates, see SMS templates. For related operations on templates in the console, see SMS templates.
-
After you submit a template application, you can call the GetSmsTemplate operation to query the template review status and details. You can also configure receipt messages and use TemplateSmsReport to obtain the template review status.
-
China mainland SMS templates and international/Hong Kong (China), Macao (China), and Taiwan (China) SMS templates are not interchangeable. Apply for templates based on your business scenarios.
-
Only users that have completed verify your identity - Enterprise account can apply for promotional SMS and international/Hong Kong (China), Macao (China), and Taiwan (China) messages. For differences between individual and enterprise user privileges, see Usage notes.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
dysms:CreateSmsTemplate |
none |
*All Resource
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| TemplateName |
string |
Yes |
The template name. The name can be up to 30 characters in length. |
Verification code |
| TemplateContent |
string |
Yes |
The template content. The content can be up to 500 characters in length. The template content and variable content must comply with the SMS template specifications. Otherwise, the template will fail the review. You can also view common template examples on the Apply for template page. Using example templates can improve the review efficiency and approval rate. For variable specifications, see TemplateContent parameter variable specifications. |
You are registering a mobile phone number. The verification code is ${code}, valid for 5 minutes |
| Remark |
string |
No |
Describe your SMS business scenario or provide an online link to the business scenario, and provide a complete SMS example with variable values filled in. Complete information helps improve the template approval rate. Failure to follow the specifications or leaving this field empty may affect the template review result. |
Apply for verification code SMS |
| TemplateType |
integer |
Yes |
The SMS type. Valid values:
Note
Only users that have completed enterprise identity authentication can apply for promotional SMS and international/Hong Kong (China), Macao (China), and Taiwan (China) messages. For details about the differences between individual and enterprise user privileges, see Usage notes. Valid values:
|
0 |
| RelatedSignName |
string |
No |
The signature name to associate with the template. The associated SMS signature must be an approved signature. Important
|
Verification code signature |
| TemplateRule |
string |
No |
The template variable rules. For how to fill in variable rules, see the example documentation. Note
|
{"code":"characterWithNumber2"} |
| MoreData |
array |
No |
Additional materials. You can upload business proof files or business screenshots to help reviewers understand your business details. If you are applying for a promotional SMS template (TemplateType is 2), upload user authorization proof materials. For specifications, see User authorization proof material upload specifications. |
|
|
string |
No |
The file information uploaded to OSS. For file upload operations, see Upload files to OSS. |
10098689758*****/1234qwe.png |
|
| ApplySceneContent |
string |
No |
The business scenario.
|
http://www.aliyun.com/ |
| IntlType |
integer |
No |
The international/Hong Kong (China), Macao (China), and Taiwan (China) template type. This parameter is required when the TemplateType parameter is set to 3. Valid values:
|
0 |
| TrafficDriving |
string |
No |
Warning
To manage SMS content security, SMS content that contains traffic-driving information such as phone numbers and links may be blocked by carriers, resulting in delivery failures. Avoid including such information in SMS templates to reduce the risk of delivery failures. The JSON string of the traffic-driving information list. Important Pass the value as a JSON string. 1. Field description:{ "trafficDrivingType":"Traffic-driving type", "trafficDrivingContent":"Traffic-driving content", "variableName":"Variable name", "companyName":"Enterprise or public institution name", "organizationCode":"Unified social credit code", "icpNo":"ICP filing/license number", "icpPicOssKey":"ICP filing screenshot OssKey", "companyDifferentFromSignQuaReason":"Reason why the enterprise name differs from the signature qualification" } 2. Precautions:
3. Enumerated values for trafficDrivingType:Warning Due to regulatory requirements, mobile phone numbers are not supported.
|
[{"trafficDrivingType":"DOMAIN","trafficDrivingContent":"aliyun.com","companyName":"Alibaba Cloud Computing Co., Ltd.","organizationCode":"91330****73959654P","icpNo":"ZheB2-20****01-4","icpPicOssKey":"db7784d8-cb0c-498f-****-295f1ad6d665_mf29l7nf.png", "companyDifferentFromSignQuaReason":"This is an explanation"},{"trafficDrivingType":"1_PHONE","trafficDrivingContent":"1**86","variableName":"my1Phone","companyName":"Alibaba Cloud Computing Co., Ltd.","organizationCode":"91330****73959654P","companyDifferentFromSignQuaReason":"This is an explanation"}] |
| SaleSkuCode |
string |
No |
The Short Message Service specification code. Only verification code type templates support selecting an SMS service specification. |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| RequestId |
string |
The request ID. It is a unique identifier generated by Alibaba Cloud for the request and can be used for troubleshooting. |
F655A8D5-B967-440B-8683-DAD6FF8DE991 |
| Code |
string |
The request status code. Valid values:
|
OK |
| Message |
string |
The description of the status code. |
successful |
| TemplateName |
string |
The SMS template name. |
Verification code template |
| TemplateCode |
string |
The SMS template code. After submitting a template application, you can use the SMS template code to call the GetSmsTemplate operation to query the template review details. You can also configure receipt messages and use TemplateSmsReport to obtain the template review status. |
SMS_10000**** |
| OrderId |
string |
The ticket ID. Reviewers use this parameter when querying reviews. Provide this ticket ID if you need to expedite the review. |
2005020**** |
Examples
Success response
JSON format
{
"RequestId": "F655A8D5-B967-440B-8683-DAD6FF8DE991",
"Code": "OK",
"Message": "successful",
"TemplateName": "Verification code template",
"TemplateCode": "SMS_10000****",
"OrderId": "2005020****"
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | ForbiddenAction | Access to the account is denied. Please contact the administrator. | |
| 400 | AssocSignUnapproved | Associated signature must be approved. | The associated signature needs to use the approved signature. |
| 400 | InvalidTemplateRule.Format | The parameter TemplateRule format must be JSON. | Template variable rules must be filled with JSON-formatted data. |
| 400 | InvalidMoreData | Specified parameter MoreData is not valid. | The uploaded more information is invalid. |
| 400 | TemplateVarLimitExceeded | The verification code template only supports one variable. | The verification code template only supports one variable. |
| 400 | InvalidTemplateContent.Format | Invalid template content format. | The template content is not in the correct format. |
| 400 | InvalidTemplateRule | The template variable format is non-standard. Please refer to the variable format specifications in the help documentation. | The template variable does not meet the specifications. Please check the SMS template specification document and pass in the template variable that meets the requirements. |
| 400 | ServiceNotOpened | This product service is not opened. | Product service not activated |
| 404 | MissingTemplateName | The template name cannot be empty. | Template name cannot be empty. |
| 404 | SmsSignatureNotFound | The associated SMS signature does not exist. | The associated SMS signature does not exist. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.