SendMessageWithTemplate

Updated at: 2025-02-20 02:49

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

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

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:
    • For mandatory resource types, indicate with a prefix of * .
    • 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
OperationAccess levelResource typeCondition keyAssociated operation
dysms:SendMessageWithTemplatecreate
*All Resources
*
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
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
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
Change timeSummary of changesOperation
2024-03-28The request parameters of the API has changedView Change Details
2023-06-27API Description Update. The request parameters of the API has changedView Change Details
  • On this page (1)
  • Operation description
  • Usage notes
  • Debugging
  • Authorization information
  • Request parameters
  • Response parameters
  • Examples
  • Error codes
  • Change history
Feedback
phone Contact Us

Chat now with Alibaba Cloud Customer Service to assist you in finding the right products and services to meet your needs.

alicare alicarealicarealicare