AddSmsTemplate

更新时间:
复制 MD 格式

An SMS template contains the content of a text message, which includes the message body and variables. You can request templates for different message types, such as verification codes, notifications, or promotional messages. You can send text messages only after the template is reviewed and approved.

Note

This API has been deprecated. We recommend migrating to Dysmsapi(2017-05-25) - CreateSmsTemplate for enhanced functionality and continued support. While the deprecated API remains temporarily accessible, no further updates or bug fixes will be provided.

Operation description

  • Alibaba Cloud has updated its template-related APIs to comply with the regulations of the Ministry of Industry and Information Technology (MIIT) and carrier requirements. To improve the efficiency and success rate of template reviews, use the new CreateSmsTemplate - Request an SMS template API.

  • You can submit up to 100 SMS template requests per day by calling this API. You must wait at least 30 seconds between each request. If you request SMS templates in the console, the number of submissions is unlimited.

  • Information about templates requested by calling the API is synchronized with the Short Message Service console. For more information about how to manage templates in the console, see SMS templates.

  • After you submit a template request, you can call the QuerySmsTemplate operation to query the review status and details of the template. You can also configure message receipts to obtain the review status from the TemplateSmsReport message.

  • Templates for text messages sent to mainland China are not interchangeable with templates for International SMS messages. Request templates based on your business scenario.

  • Only enterprise users can request templates for promotional messages and International SMS messages. For more information about the differences between individual and enterprise users, see Usage notes.

QPS limit

The queries per second (QPS) limit for a single user is 1,000 calls per second. If you exceed this limit, API calls are throttled, which may affect your business. Call this API at a reasonable rate.

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:AddSmsTemplate

create

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

TemplateType

integer

Yes

The type of the text message. Valid values:

  • 0: verification code.

  • 1: notification.

  • 2: promotional message.

  • 3: International SMS message.

Note

Only enterprise users can request templates for promotional messages and International SMS messages. For more information about the differences between individual and enterprise users, see Usage notes.

1

TemplateName

string

Yes

The name of the template. The name can be up to 30 characters in length.

Aliyun Test

TemplateContent

string

Yes

The content of the template. The content can be up to 500 characters in length.

The template content and variables must comply with the SMS template specifications. Otherwise, the template fails the review. You can also view common sample templates on the Request Template page. Using sample templates can improve the efficiency and success rate of reviews. For more information about variable specifications, see Variable specifications for the TemplateContent parameter.

You are applying for mobile registration. The verification code is: ${code}, valid for 5 minutes!

Remark

string

Yes

The description of the SMS template request. The description can be up to 100 characters in length.

This information is used for template review. A detailed description helps reviewers understand your business scenario and improves review efficiency. Follow these guidelines:

  • Provide the use case of a published service.

  • Provide a sample text message for a real-world scenario to demonstrate your business case.

  • Provide the content passed for variables. Describe your business scenario and the reason for choosing this variable property in detail.

  • Provide the URL of your business website, the domain name that has an ICP filing, or the download link for your application in an app marketplace.

  • For logon scenarios, provide a test account and password.

Apply for a template to send verification codes.

Response elements

Element

Type

Description

Example

object

Code

string

The request status code.

  • A value of OK indicates that the request was successful.

  • For more information about other error codes, see API error codes.

OK

Message

string

The description of the status code.

OK

RequestId

string

The request ID.

F655A8D5-B967-440B-8683-DAD6FF8DE990

TemplateCode

string

The code of the SMS template.

After you submit a template request, you can use the template code to call the QuerySmsTemplate operation and query the review details. You can also configure message receipts and obtain the review status of the template from the TemplateSmsReport message.

SMS_15255****

Examples

Success response

JSON format

{
  "Code": "OK",
  "Message": "OK",
  "RequestId": "F655A8D5-B967-440B-8683-DAD6FF8DE990",
  "TemplateCode": "SMS_15255****"
}

Error codes

HTTP status code

Error code

Error message

Description

400 TemplateParameterCountIllegal The verification code template only supports 1 verification code as a variable Verification code templates support only one variable, which must be a verification code.

See for a complete list.

Release notes

See Release Notes for a complete list.