Sends a text message by using a template. Only China and the United States are allowed to send.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String No SendMessageWithTemplate

The operation that you want to perform. Valid values:

SendMessageWithTemplate*.

TemplateCode String Yes SMS_0000

The template code.

To String Yes 86137xxx688

The mobile phone numbers to receive the text messages. You must add the country code to the beginning of each mobile phone number. For example, 86137 xxx688.

From String No Alicloud

The ID of the sender. Signature requests sent to ECS instances both in mainland China and non-China respectively. Please apply for an SMS signature on the console.

TemplateParam String No {"code":"1234","product":"ytx"}

The values of the variables that are included in the text message template. The values must use the JSON format.

Note If line feeds are required in JSON-formatted data, the line feeds must meet the relevant requirements that are specified in the standard JSON protocol.
SmsUpExtendCode String No 90999

The extension code of the upstream text message.

Response parameters

Parameter Type Example Description
MessageId String 1008030xxx3003

The ID of the text message.

NumberDetail Struct

The details of the mobile phone number.

Carrier String China Mobile

The carrier that provides the mobile phone number.

Country String China

The country to which the mobile phone number belongs.

Region String Nanjing, Jiangsu

The region to which the mobile phone number belongs.

ResponseCode String OK

The status code that indicates whether the request of sending the text message was submitted.

ResponseDescription String The SMS Send Request was accepted

The detailed description of the status code that indicates whether the request of sending the text message was submitted.

Segments String 1

The number of the text messages that incurred fees.

To String 86137xxx688

The mobile phone numbers to receive the text messages. You must add the country code to the beginning of each mobile phone number. For example, 86137 xxx688.

Examples

Sample requests


     http(s)://dysmsapi.ap-southeast-1.aliyuncs.com/?Action=SendMessageWithTemplate&TemplateCode=SMS_0000&To=86137xxx688&<common request parameters> 
   

Sample success responses

XML format


     <MessageId>1008030xxx3003</MessageId> <NumberDetail> <Carrier>China Mobile</Carrier> <Country>China</Country> <Region>Nanjing, Jiangsu</Region> </NumberDetail> <ResponseCode>OK</ResponseCode> <ResponseDescription>The SMS Send Request was accepted</ResponseDescription> <Segments>1</Segments> <To>86137xxx688</To> 
   

JSON Format


     { "MessageId": "1008030xxx3003", "NumberDetail": { "Carrier": "China Mobile", "Country": "China", "Region": "Nanjing, Jiangsu" }, "ResponseCode": "OK", "ResponseDescription": "The SMS Send Request was accepted", "Segments": "1", "To": "86137xxx688" } 
   

Error code

Go to the Error CenterFor more information, see error codes.