All Products
Search
Document Center

Short Message Service:SendMessageWithTemplate

Last Updated:May 28, 2024

Sends a message to the Chinese mainland by using a message template.

Operation description

Usage notes

You can call the SendMessageWithTemplate operation to send messages only to the Chinese mainland.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
dysms:SendMessageWithTemplateWrite
  • All Resources
    *
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
TostringYes

The mobile phone number to which the message is sent. You must add the country code to the beginning of the mobile phone number. Example: 861503871****.

For more information, see Dialing codes.

861503871****
FromstringYes

The signature. To query the signature, log on to the Short Message Service (SMS) console and navigate to the Signatures tab of the Go China page.

Alicloud321
TemplateCodestringYes

The code of the message template. To query the code, log on to the SMS console and navigate to the Templates tab of the Go China page.

SMS_****
TemplateParamstringNo

The value of the variable in the message template. If a variable exists in the template, the parameter is required.

{"code":"1234","product":"ytx"}
SmsUpExtendCodestringNo

The extension code of the MO message.

90999
ValidityPeriodlongNo

The validity period of the message.

1
ChannelIdstringNo

The ID of the channel.

5739

Response parameters

ParameterTypeDescriptionExample
object
ResponseCodestring

The status code of the delivery request.

OK
NumberDetailobject

The details about the mobile phone number of the recipient.

Carrierstring

The carrier that owns the mobile phone number.

China Mobile
Regionstring

The region to which the mobile phone number belongs.

Nanjing, Jiangsu
Countrystring

The country to which the mobile phone number belongs.

China
ResponseDescriptionstring

The description of the delivery request status.

The SMS Send Request was accepted
Segmentsstring

The number of messages that incurred fees.

1
Tostring

The mobile phone number to which the message was sent. The dialing code was added to the beginning of the mobile phone number. Example: 861503871****.

861503871****
MessageIdstring

The ID of the message.

1**************3
RequestIdstring

The ID of the request.

F655A8D5-B967-440B-8683-DAD6FF8D23D6

Examples

Sample success responses

JSONformat

{
  "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 Service error codes.

Change history

Change timeSummary of changesOperation
2024-03-28The request parameters of the API has changedsee changesets
Change itemChange content
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: ChannelId
2023-06-27API Description Update. The request parameters of the API has changedsee changesets
Change itemChange content
API DescriptionAPI Description Update.
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: ValidityPeriod