SendSmsVerifyCode

Updated at:

Sends an SMS verification code.

Operation description

  • Due to recent stricter control over SMS signatures by carriers, custom signatures may fail to be delivered. Use the complimentary SMS signatures and templates provided in the Phone Number Verification Service console for SMS verification. Complimentary signatures must be used with complimentary templates.

  • Before calling this operation, make sure that you fully understand the billing methods and pricing of Phone Number Verification Service. The SMS verification service charges only SMS sending fees (billed based on the carrier receipt status. No fee is charged if the SMS is submitted successfully but the carrier receipt fails). The verification service is free of charge.

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

The scheme name. If you leave this parameter empty, the default scheme is used. The name can be up to 20 characters in length.

Test scheme

CountryCode

string

No

The country code of the phone number. Default value: 86. Currently, only domestic phone numbers are supported.

86

PhoneNumber

string

Yes

The phone number of the SMS recipient.

130****0000

SignName

string

Yes

The signature name. Custom signatures are not supported. Use a complimentary signature provided by the system. You can select the signature to be delivered on the Complimentary Signature Configuration page.

Hengchuanglianzhong

TemplateCode

string

Yes

The code of the SMS template. If you select a complimentary signature for the SignName parameter, you must use a complimentary template to send the SMS. You can select a template that suits your business scenario on the Complimentary Template Configuration page.

100001

TemplateParam

string

Yes

The SMS template parameters. You can specify the verification code in two ways:

  • Use "##code##" as a placeholder and specify the verification code generation rule by using the CodeType parameter.

  • Directly pass the specific verification code value to be sent to the recipient.

Example: If the template content is "Your verification code is ${code}, which is valid for ${min} minutes. Do not disclose it to others.".

Important Replace code in the preceding example with the actual parameter name in your applied verification code template.

  • You can pass {"code":"##code##","min":"5"} to let the system generate the verification code based on the rule.

  • Alternatively, you can directly pass the specified verification code value, such as {"code":"123456","min":"5"}.

Note
  • If you pass {"code":"##code##","min":"5"}, the verification code is dynamically generated by the API and can be verified by Alibaba Cloud API operations.

  • If you pass {"code":"123456","min":"5"}, the verification code is configured by the user and not dynamically generated by the API. In this case, Alibaba Cloud API operations cannot verify the code.

Note
  • If the JSON string requires line breaks, handle them in accordance with the standard JSON protocol.

  • For template variable specifications, refer to SMS template specifications.

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

SmsUpExtendCode

string

No

The extension code for upstream SMS messages. Upstream SMS messages are sent to communication service providers to subscribe to services, perform queries, or handle business. These messages are charged based on the standard SMS rates of carriers.

Note

The extension code is automatically generated by the system when the signature is created and cannot be manually specified. Ignore this parameter unless you have special requirements. To use this parameter, contact your account manager.

1213123

OutId

string

No

The external serial number.

External serial number (pass-through)

CodeLength

integer

No

The length of the verification code. Valid values: 4 to 8. Default value: 4.

4

ValidTime

integer

No

The validity period of the verification code. Unit: seconds. Default value: 300.

300

DuplicatePolicy

integer

No

The verification rule that specifies how to handle the old verification code when a new verification code is sent to the same phone number in the same scenario within the validity period. Valid values:

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

  • 2: Retain. Multiple verification codes remain valid and can be verified within their validity periods.

Valid values:

  • 1 :

    Overwrite.

  • 2 :

    Retain.

1

Interval

integer

No

The time interval at which a verification code can be sent. Unit: seconds. This parameter is used for frequency control. Default value: 60.

60

CodeType

integer

No

The type of the generated verification code. This parameter is required when a placeholder is passed in the TemplateParam parameter. The system generates the verification code based on the specified rule. Valid values:

  • 1: Digits only (default).

  • 2: Uppercase letters only.

  • 3: Lowercase letters only.

  • 4: Mixed uppercase and lowercase letters.

  • 5: Mixed digits and uppercase letters.

  • 6: Mixed digits and lowercase letters.

  • 7: Mixed digits, uppercase letters, and lowercase letters.

Valid values:

  • 1 :

    Digits only.

  • 2 :

    Uppercase letters only.

  • 3 :

    Lowercase letters only.

  • 4 :

    Mixed uppercase and lowercase letters.

  • 5 :

    Mixed digits and uppercase letters.

  • 6 :

    Mixed digits and lowercase letters.

  • 7 :

    Mixed digits, uppercase letters, and lowercase letters.

1

ReturnVerifyCode

boolean

No

Specifies whether to return the verification code. Valid values:

  • true: Return the verification code.

  • false: Do not return the verification code.

true

AutoRetry

integer

No

Specifies whether to automatically replace the signature and retry sending the SMS. This feature is enabled by default. Valid values:

  • 1: Enable automatic retry. After this feature is enabled, if the carrier returns a clear failure status within the validity period of the verification code, Alibaba Cloud tries to send the verification code by using other methods to improve the delivery success rate. Other methods include but are not limited to retrying through other carriers and replacing the signature.

  • 0: Disable automatic retry.

1

Response elements

Element

Type

Description

Example

object

AccessDeniedDetail

string

The details of the access denial.

None

Message

string

The description of the status code.

Success

RequestId

string

The request ID.

CC3BB6D2-2FDF-4321-9DCE-B38165CE4C47

Model

object

The request result data.

VerifyCode

string

The verification code.

4232

RequestId

string

The request ID.

a3671ccf-0102-4c8e-8797-a3678e091d09

OutId

string

The external serial number.

1231231313

BizId

string

The business ID.

112231421412414124123^4

Code

string

The request status code. A value of OK indicates that the request is successful. For other error codes, refer to List of return codes.

OK

Success

boolean

Indicates whether the request is successful. Valid values:

  • true: The request is successful.

  • false: The request fails.

true

Examples

Success response

JSON format

{
  "AccessDeniedDetail": "None",
  "Message": "OK",
  "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.