SendSmsVerifyCode

更新时间:
复制 MD 格式

Sends an SMS verification code.

Operation description

  • Carriers recently tightened controls on SMS signatures. Your custom signature may fail to deliver. Use the SMS signature and template provided by the Phone Number Verification Service console for SMS authentication. System-provided signatures must be used with system-provided templates.

  • Before using this API, understand the billing model and pricing of the Phone Number Verification Service. SMS authentication charges only for successfully delivered messages (billed based on carrier receipt status. There is no charge if the message is submitted but the carrier reports failure). The verification service itself is free.

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

dypns:SendSmsVerifyCode

create

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

SchemeName

string

No

Scheme name. If not specified, defaults to "default scheme". Maximum length is 20 characters.

测试方案

CountryCode

string

No

Country code for the phone number. Default is 86. Currently, only domestic numbers are supported.

86

PhoneNumber

string

Yes

Recipient's mobile phone number.

130****0000

SignName

string

Yes

Signature name. Custom signatures are not supported. Use a system-provided signature. Select a signature to use on the System Signature Configuration page.

速通互联验证码

TemplateCode

string

Yes

SMS template code. When using a system-provided signature in the SignName parameter, pair it with a system-provided template. Select a template that fits your business scenario on the System Template Configuration page.

100001

TemplateParam

string

Yes

Template parameters. You can specify the verification code in two ways:

  • Use "##code##" as a placeholder. The system generates the code based on rules defined by the CodeType parameter.

  • Provide a specific verification code value directly. The system sends this exact code to the recipient.

Example: If the template content is: "Your Captcha is ${code}. It is valid for ${min} minutes. Do not share it with others."

Important Replace `code` in the preceding text with the parameter name from your requested Captcha template.

  • Pass {"code":"##code##","min":"5"} to let the system generate the code dynamically.

  • Or pass a fixed code like {"code":"123456","min":"5"}.

Note
  • {"code":"##code##","min":"5"} uses a code dynamically generated by the API. Alibaba Cloud can verify this code.

  • {"code":"123456","min":"5"} uses a user-defined code. Alibaba Cloud cannot verify this code.

Note
  • If your JSON includes line feeds, follow standard JSON formatting rules.

  • For template variable guidelines, see SMS template specifications.

{"code":"##code##","min":"5"}

SmsUpExtendCode

string

No

Uplink SMS extension code. Uplink SMS refers to messages sent to your carrier for services such as queries or transactions. Charges apply based on standard carrier SMS rates.

Note

The extension code is automatically generated when you create a signature. You cannot specify your own. Ignore this field unless you have a specific need. Contact your account manager if you require this feature.

1213123

OutId

string

No

External transaction ID.

外部流水号(透传)

CodeLength

integer

No

Verification code length. Supports 4 to 8 digits. Default is 4.

4

ValidTime

integer

No

Verification code validity period in seconds. Default is 300 seconds.

300

DuplicatePolicy

integer

No

Verification policy for handling repeated requests to the same number within the same scenario during the validity period.

  • 1: Overwrite (default). The previous code becomes invalid.

  • 2: Keep. Multiple codes remain valid and can be verified.

Valid values:

  • 1 :

    Overwrite

  • 2 :

    Keep

1

Interval

integer

No

Minimum interval between sending verification codes, in seconds. Used for rate limiting. Default is 60 seconds.

60

CodeType

integer

No

Type of verification code to generate. Required when TemplateParam uses a placeholder. The system generates the code based on this rule. Values:

  • 1: Numeric only (default).

  • 2: Uppercase letters only.

  • 3: Lowercase letters only.

  • 4: Mixed uppercase and lowercase letters.

  • 5: Numeric and uppercase letters.

  • 6: Numeric and lowercase letters.

  • 7: Numeric, uppercase, and lowercase letters.

Valid values:

  • 1 :

    Numeric only

  • 2 :

    Uppercase letters only

  • 3 :

    Lowercase letters only

  • 4 :

    Mixed uppercase and lowercase letters

  • 5 :

    Numeric and uppercase letters

  • 6 :

    Numeric and lowercase letters

  • 7 :

    Numeric, uppercase, and lowercase letters

1

ReturnVerifyCode

boolean

No

Whether to return the verification code in the response. Values:

  • true: Return the code.

  • false: Do not return the code.

true

AutoRetry

integer

No

Whether to automatically retry with a different signature (enabled by default). Values:

  • 1: Enable auto-retry. During the code's validity period, if the carrier returns a clear failure status, Alibaba Cloud attempts to resend using alternative methods—such as other carriers or different signatures—to improve delivery success.

  • 0: Disable auto-retry.

是否自动重试

Response elements

Element

Type

Description

Example

object

AccessDeniedDetail

string

Details of access denial.

Message

string

Description of the status code.

成功

RequestId

string

Request ID.

CC3BB6D2-2FDF-4321-9DCE-B38165CE4C47

Model

object

Response data.

VerifyCode

string

Verification code.

4232

RequestId

string

Request ID.

a3671ccf-0102-4c8e-8797-a3678e091d09

OutId

string

External transaction ID.

1231231313

BizId

string

Business ID.

112231421412414124123^4

Code

string

Request status code. "OK" indicates success. For other error codes, see Return code list.

OK

Success

boolean

Whether the request succeeded.

  • true: Request succeeded.

  • false: Request failed.

true

Examples

Success response

JSON format

{
  "AccessDeniedDetail": "无",
  "Message": "成功 ",
  "RequestId": "CC3BB6D2-2FDF-4321-9DCE-B38165CE4C47",
  "Model": {
    "VerifyCode": "4232",
    "RequestId": "a3671ccf-0102-4c8e-8797-a3678e091d09",
    "OutId": "1231231313",
    "BizId": "112231421412414124123^4"
  },
  "Code": "OK",
  "Success": true
}

Error codes

HTTP status code

Error code

Error message

Description

400 MOBILE_NUMBER_ILLEGAL The mobile number is illegal. Phone number format error
400 BUSINESS_LIMIT_CONTROL The number has exceeded the limit for the day. Trigger number day flow control
400 FREQUENCY_FAIL Check frequency fail. Frequency control check failed
400 INVALID_PARAMETERS parameter is not valid. Illegal parameter
400 FUNCTION_NOT_OPENED You have not opened this function. Converged authentication function is not activated

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.