SendSms

更新时间:
复制 MD 格式

Sends an SMS message to one or more specified mobile numbers.

Operation description

Use this API to send an SMS message to a single mobile number. This API also supports sending messages with the same signature and template variables to multiple mobile numbers, up to 1,000 per request. Note that bulk sending may experience some latency. If you need to send messages with different signatures or template variables to multiple recipients, use the SendBatchSms API, which supports up to 100 mobile numbers per request.

Usage notes

  • For SMS messages sent to the Chinese mainland, we recommend setting the timeout period to 1 second or longer. If a timeout occurs, check the delivery receipt status before retrying the request. For more information about timeout and retry settings, see Timeout mechanism and Retry mechanism.

  • This API does not support idempotence for domestic, international, or multimedia SMS messages. You must implement your own idempotence controls to prevent sending duplicate messages during retries.

  • This is a billable API. For messages sent to the Chinese mainland, billing is based on the delivery receipt status from the carrier. You are not charged if the API call is successful but the carrier fails to deliver the message. For more information, see Billing.

QPS limit

This API has a queries per second (QPS) limit of 5,000 for each user. The system throttles calls that exceed this limit. To avoid throttling, use this API within the specified limit.

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

get

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

PhoneNumbers

string

Yes

The recipient's mobile number. The format varies based on the destination region:

  • For messages to the Chinese mainland: A mobile number, with or without a country code. Valid prefixes are +, +86, 0086, and 86. Example: 1390000****.

  • For international messages or messages to Hong Kong, Macao, or Taiwan: Use the format [Country code][Mobile number]. Example: 852000012****.

  • To send a test message, bind a test mobile number in the console.

Note

To send a message to multiple numbers, separate them with commas (,). You can specify up to 1,000 mobile numbers per request. Bulk sending may have higher latency than sending single messages. For time-sensitive messages such as verification codes, we recommend sending them individually.

1390000****

SignName

string

Yes

The signature name.

Call the QuerySmsSignList API or view your list of signatures in the Short Message Service console. You must use a signature that has been approved.

Note
  • 1. If a verification code signature and a general-purpose signature share the same name, the general-purpose signature is used by default.

  • 2. The system uses the specified signature to send the message.

阿里云

TemplateCode

string

Yes

The code of the template.

Call the QuerySmsTemplateList API or view your list of templates in the Short Message Service console. You must use the code of a template that has been approved.

SMS_15305****

TemplateParam

string

No

The values for the template variables, specified as a JSON string. This parameter is required if the template contains variables. The JSON string must provide a value for each variable.

Note
  • If the JSON string needs to include line breaks, format it according to standard JSON specifications.

  • For more information about template variable formatting, see SMS template specifications.

{"name":"张三","number":"1390000****"}

SmsUpExtendCode

string

No

The upstream SMS extension code. An upstream SMS message is a message sent from a user to a service provider to subscribe to a service, make a query, or perform other tasks. Such messages are charged by the carrier at standard rates.

Note

The system assigns a default extension code when a signature is created. Use this parameter to specify a different code. You can ignore this parameter if you do not have special requirements.

90999

OutId

string

No

The external transaction ID.

Note

You can ignore this parameter if you do not have special requirements.

abcdefgh

Response elements

Element

Type

Description

Example

object

The response body.

Code

string

The request status code.

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

  • For other error codes, see API error codes.

OK

Message

string

The description of the status code.

OK

BizId

string

The delivery receipt ID.

Use this ID to query the delivery status by calling the QuerySendDetails API.

9006197469364984****

RequestId

string

The Request ID.

F655A8D5-B967-440B-8683-DAD6FF8DE990

Examples

Success response

JSON format

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

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.