CreateSmsTemplate
A message template defines the content of an SMS message. This content includes the message text and any variables. You can create templates for various business needs, such as sending verification codes, notifications, or promotional messages. A template must be approved before you can use it to send messages.
Operation description
-
For details on the API changes for signatures and templates, see the Announcement on Signature and Template API Updates for Short Message Service.
-
Wait at least 30 seconds between API calls when applying for a message template.
-
Message templates you apply for via the API are synchronized to the Short Message Service console. For details on how to manage message templates in the console, see Message templates.
-
After you submit a template for review, you can call the GetSmsTemplate API to query the template's review status and details. You can also configure status reports to receive the template's review status through TemplateSmsReport.
-
Message templates for Chinese mainland messages and international messages are not interchangeable. Apply for message templates based on your use case.
-
Only enterprise-verified users can apply for message templates for promotional messages and international messages. For details on the permission differences between individual and enterprise users, 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 must be 30 characters or less. |
验证码 |
| TemplateContent |
string |
Yes |
The template content. The content must be 500 characters or less. The template content and variables must comply with the SMS Template Specifications. Templates that do not comply may be rejected. You can find common template examples on the Apply for Template page. Using these examples can speed up the review process and increase the approval rate. For variable specifications, see Variable Specifications for the TemplateContent Parameter. |
您正在申请手机注册,验证码为:${code},5分钟内有效! |
| Remark |
string |
No |
Describe the business scenario for the SMS messages, or provide a URL for online scenarios. You must also provide a complete SMS example with actual values for any variables. Complete information increases the chance of template approval. Templates that do not provide this information as specified may be rejected. |
申请验证码短信 |
| TemplateType |
integer |
Yes |
The SMS type. Valid values:
Note
Only enterprise-verified users can apply for promotional messages or international/Hong Kong, Macao, and Taiwan messages. For more information about the differences in privileges between individual and enterprise users, see Usage Notes. |
0 |
| RelatedSignName |
string |
No |
The name of the signature to associate with the template. The signature must be an approved signature. Important
|
验证码签名 |
| TemplateRule |
string |
No |
The rules for variables in the template. For instructions on how to define these rules, see Sample Document. Note
|
{"code":"characterWithNumber2"} |
| MoreData |
array |
No |
Additional information. You can upload supporting documents or business screenshots to help reviewers better understand your business scenario. If you are applying for a promotional message template (where |
|
|
string |
No |
The OSS object key for the uploaded file. For instructions on how to upload a file, see Upload a file to OSS. |
10098689758*****/1234qwe.png |
|
| ApplySceneContent |
string |
No |
The business scenario.
|
http://www.aliyun.com/ |
| IntlType |
integer |
No |
The type of the template for international/Hong Kong, Macao, and Taiwan messages. This parameter is required when TemplateType is set to 3. Valid values:
|
0 |
| TrafficDriving |
string |
No |
Warning To control the security of SMS content, messages that contain traffic-driving information, such as phone numbers and links, may be blocked by carriers, which can lead to delivery failures. To reduce this risk, we recommend that you avoid including such information in message templates. A JSON string that contains a list of traffic-driving information. Important The value must be a JSON array serialized into a string. 1. Fields{ "trafficDrivingType":"traffic driving type", "trafficDrivingContent":"traffic driving content", "variableName":"variable name", "companyName":"organization name", "organizationCode":"unified social credit code", "icpNo":"ICP filing or license number", "icpPicOssKey":"OSS key of the ICP filing screenshot", "companyDifferentFromSignQuaReason":"Reason for the discrepancy between the organization name and the signature qualification" } 2. Notes
3. trafficDrivingType enum valuesWarning Due to regulatory requirements, mobile phone numbers are not supported.
|
[{"trafficDrivingType":"DOMAIN","trafficDrivingContent":"aliyun.com","companyName":"阿里云计算有限公司","organizationCode":"91330****73959654P","icpNo":"浙B2-20****01-4","icpPicOssKey":"db7784d8-cb0c-498f-****-295f1ad6d665_mf29l7nf.png", "companyDifferentFromSignQuaReason":"这是一段说明文字"},{"trafficDrivingType":"1_PHONE","trafficDrivingContent":"1**86","variableName":"my1Phone","companyName":"阿里云计算有限公司","organizationCode":"91330****73959654P","companyDifferentFromSignQuaReason":"这是一段说明文字"}] |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| RequestId |
string |
The ID of the request. Alibaba Cloud generates a unique ID for each request. You can use this ID to troubleshoot issues. |
F655A8D5-B967-440B-8683-DAD6FF8DE991 |
| Code |
string |
The status code of the request. Valid values:
|
OK |
| Message |
string |
The description of the status code. |
successful |
| TemplateName |
string |
The name of the message template. |
验证码模板 |
| TemplateCode |
string |
The code of the message template. After you submit a template application, you can use the template code to call the GetSmsTemplate operation and query the review details of the template. You can also configure delivery receipts to receive the review status of the template in the TemplateSmsReport message. |
SMS_10000**** |
| OrderId |
string |
The ticket ID. Reviewers use this ID to check the review status. You must provide this ID when you request an expedited review. |
2005020**** |
Examples
Success response
JSON format
{
"RequestId": "F655A8D5-B967-440B-8683-DAD6FF8DE991",
"Code": "OK",
"Message": "successful",
"TemplateName": "验证码模板",
"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.