Sends messages by using a message template.
Usage notes
You can call the SendMessageWithTemplate operation to send messages only to the Chinese mainland.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | SendMessageWithTemplate |
The operation that you want to perform. Set the value to SendMessageWithTemplate. |
To | String | Yes | 861503871**** |
The mobile phone number of the recipient. You must add the dialing code to the beginning of each mobile phone number. Example: 861503871****. |
From | String | Yes | Alicloud |
The signature. To view the signature, log on to the Short Message Service (SMS) console and navigate to the SMS Signature tab of the Go China page. |
TemplateCode | String | Yes | SMS_**** |
The code of the message template. To query the message template code, log on to the SMS console and navigate to the SMS Content tab of the Go China page. |
TemplateParam | String | No | {"code":"1234","product":"ytx"} |
The values of the variables that are included in the message template. If a variable exists in the template, the parameter is required. |
SmsUpExtendCode | String | No | 90999 |
The extension code of the upstream message. |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
ResponseCode | String | OK |
The status that indicates whether the message sending request was submitted. |
NumberDetail | Object |
The details about the recipient phone number. |
|
Carrier | String | China Mobile |
The carrier that provides the recipient phone number. |
Region | String | Nanjing, Jiangsu |
The region to which the recipient phone number belongs. |
Country | String | China |
The country to which the recipient phone number belongs. |
ResponseDescription | String | The SMS Send Request was accepted |
The description of the status that indicates whether the delivery request was submitted. |
Segments | String | 1 |
The number of the messages that incurred fees. |
To | String | 861503871**** |
The mobile phone number of the recipient. You must add the dialing code to the beginning of each mobile phone number. Example: 861503871****. |
MessageId | String | 1**************3 |
The ID of the message. |
RequestId | String | F655A8D5-B967-440B-8683-DAD6FF8D23D6 |
The ID of the request. |
Examples
Sample requests
http(s)://dysmsapi.ap-southeast-1.aliyuncs.com/?Action=SendMessageWithTemplate
&To=861503871****
&From=Alicloud
&TemplateCode=SMS_****
&TemplateParam={"code":"1234","product":"ytx"}
&SmsUpExtendCode=90999
&Common request parameters
Sample responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<SendMessageWithTemplateResponse>
<ResponseCode>OK</ResponseCode>
<NumberDetail>
<Carrier>China Mobile</Carrier>
<Region>Nanjing, Jiangsu</Region>
<Country>China</Country>
</NumberDetail>
<ResponseDescription>The SMS Send Request was accepted</ResponseDescription>
<Segments>1</Segments>
<To>861503871****</To>
<MessageId>1**************3</MessageId>
<RequestId>F655A8D5-B967-440B-8683-DAD6FF8D23D6</RequestId>
</SendMessageWithTemplateResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"ResponseCode" : "OK",
"NumberDetail" : {
"Carrier" : "China Mobile",
"Region" : "Nanjing, Jiangsu",
"Country" : "China"
},
"ResponseDescription" : "The SMS Send Request was accepted",
"Segments" : "1",
"To" : "861503871****",
"MessageId" : "1**************3",
"RequestId" : "F655A8D5-B967-440B-8683-DAD6FF8D23D6"
}
Error codes
For a list of error codes, visit the API Error Center.