CreateSmsTemplate

Updated at:

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

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

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:

  • 0: Verification code.

  • 1: SMS notification.

  • 2: Promotional SMS.

  • 3: International/Hong Kong (China), Macao (China), and Taiwan (China) message.

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 :

    Verification code.

  • 1 :

    SMS notification.

  • 2 :

    Promotional SMS.

  • 3 :

    International/Hong Kong (China), Macao (China), and Taiwan (China) message.

0

RelatedSignName

string

No

The signature name to associate with the template. The associated SMS signature must be an approved signature.

Important
  • This parameter is required when the TemplateType parameter is set to 0, 1, or 2.

  • Associating a signature can improve the review efficiency. The signature associated here is not related to the signature selected when sending SMS messages.

Verification code signature

TemplateRule

string

No

The template variable rules. For how to fill in variable rules, see the example documentation.

Note
  • This field is required if the SMS template contains variables.

{"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.

  • If the scenarios of the SMS signature associated with the template is "Online app", ApplySceneContent must be an app link starting with http:// or https://.

  • If the scenarios of the SMS signature associated with the template is "Registered trademark name" or "Enterprise or public institution name", ApplySceneContent is required.

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: SMS notification.

  • 1: Promotional SMS.

  • 2: Verification code.

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:

  • If the content is not a variable, do not pass variableName.

  • If the enterprise or public institution name differs from the enterprise name in the signature qualification, pass companyDifferentFromSignQuaReason.

  • If trafficDrivingType=DOMAIN, pass all parameters.

  • If trafficDrivingType is set to other values, pass trafficDrivingType, trafficDrivingContent, variableName (as needed), companyName, organizationCode, and companyDifferentFromSignQuaReason (as needed).

3. Enumerated values for trafficDrivingType:

Warning Due to regulatory requirements, mobile phone numbers are not supported.
  • DOMAIN: domain name link.

  • FIXED_PHONE: landline phone number.

  • 400_PHONE: phone number starting with 400.

  • 800_PHONE: phone number starting with 800.

  • 95_PHONE: phone number starting with 95.

  • 96_PHONE: phone number starting with 96.

  • 1_PHONE: phone number starting with 1, 3 to 8 digits.

  • OTHER_PHONE: other phone number.

[{"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: The request was successful.

  • For other error codes, see the Error codes section of this topic or API error codes.

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.