SMS Verification Service

更新时间:
复制 MD 格式

SMS Verification Service is a cloud-native service that verifies user phone numbers with SMS messages. By integrating this service, you can offload the complexities of verification code generation, lifecycle management, security checks, high-concurrency handling, and high availability. This lets you easily verify user phone numbers with verification codes, which boosts developer productivity and reduces development costs.

Test SMS Verification Service

To try SMS Verification Service, or if your application is in the testing phase, use the Quick Test feature to send test messages.

Note
  1. Log in to the Phone Number Verification Service (PNVS) console and go to the SMS Verification Overview page.

  2. In the Quick Test area, review the provided Signature/Template Information. You can also select other signatures and templates as described in Configure SMS verification parameters. We recommend using the free signatures and templates.

    The Signature/Template Information includes fields such as Signature Name (for example, "Hengchuang Lianzhong"), Signature Usage Scenario (for example, "Send test SMS"), Template Name (for example, "Logon/Registration Template"), Template ID (for example, 100001), and Template Content.

  3. Click Bind Test Phone Number and complete the binding process in the dialog box that appears.

    In the dialog box, enter a phone number, and click Send Verification Code. After you receive the code, enter it in the Verification Code field, and then click OK.

  4. Click Call API to Test SMS Verification Service to open the OpenAPI Explorer page. The signature, template, and recipient phone number are automatically populated in the request parameters.

    • SendSmsVerifyCode: Call this API operation to send an SMS verification code. You can customize the code generation rules based on the parameter descriptions.

    • CheckSmsVerifyCode: Call this API operation to verify an SMS verification code. You can check the verification result from the returned VerifyResult parameter.

      Verification mechanism and response configuration: To prevent malicious guessing of the verification code, you must call the CheckSmsVerifyCode operation to verify the code entered by the user before you consider the phone number verified. By default, the verification code is sent only to the user's phone, and the SendSmsVerifyCode operation does not return the code in plaintext. For debugging or special scenarios, you can configure SendSmsVerifyCode to return the verification code directly in the response.

FAQ

Q: The console shows that the message was sent successfully, but the phone did not receive it. Or, I cannot receive test messages when I select a specific region. What should I do?

A:

  • SMS delivery occurs only when you call the SendSmsVerifyCode operation. Obtaining an AccessKey pair or binding a phone number in the console does not trigger message delivery on its own.

  • You do not need to change the service endpoint when you call the API. Use the default endpoint. Switching regions (for example, between Hangzhou and Shanghai) does not affect message delivery.

  • If delivery fails because of signature real-name registration issues, you can use the SMS Delivery Failure Diagnostics tool to self-check whether your signature is compliant.

Configure SMS Verification parameters

Important

Due to stricter carrier regulations on SMS signatures, all signatures must complete real-name registration before they can be used to send messages. Custom signatures may experience delivery failures. We recommend using the free SMS signatures and templates for verification. A free signature must be used with a free template.

Differences between SMS Verification Service and Short Message Service

SMS Verification Service and Short Message Service are independent products with isolated API endpoints and resources. Note the following when you use SMS Verification Service:

  • API usage: SMS verification must be implemented by calling the SendSmsVerifyCode and CheckSmsVerifyCode operations of PNVS (Dypnsapi). Do not call the SendSms operation of Short Message Service (Dysmsapi) for SMS verification scenarios. Otherwise, errors such as isv.SMS_TEMPLATE_ILLEGAL (template not found) or "no matching template under this account" may occur.

  • Resource isolation: Free signatures and free templates provided by SMS Verification Service can be used only with the SendSmsVerifyCode operation. They cannot be used with the SendSms operation. Likewise, custom signatures and templates created in Short Message Service cannot be used with SMS Verification Service operations.

  • Parameter format: The TemplateParam parameter of the SendSmsVerifyCode operation must be a JSON string, for example, {"code":"##code##","min":10}. The validity period of the verification code is determined by the ValidTime parameter.

  • Integration method: SMS Verification Service is called only through server-side API operations. It does not involve client SDK integration or the creation of an authentication scheme. If your frontend (such as H5 or a React Native Expo app) needs to trigger SMS verification, the frontend must forward the request through your backend server. Do not call the API operations directly from the frontend.

Free signatures and templates

Use the free signatures and templates to skip the review and registration process and increase the message delivery success rate.

Free signatures

  1. Log in to the PNVS console and go to the SMS Verification Parameter Configuration page.

  2. On the Signature Configuration tab, select Free Signature Configuration.

  3. View the list of free signatures. You can select any signature from this list to send messages.

Free templates

  1. Log in to the PNVS console and go to the SMS Verification Parameter Configuration page.

  2. On the Template Configuration tab, select Free Template Configuration.

  3. View the list of free templates. You can select any template from this list to send messages.

    Note

    A free signature must be used with a free template.

    The list of free templates includes five templates: Logon/Registration Template (100001), Modify Bound Phone Number Template (100002), Reset Password Template (100003), Bind New Phone Number Template (100004), and Verify Bound Phone Number Template (100005).

FAQ

Q: After my Alibaba Cloud account completes enterprise identity verification and I enable SMS Verification Service, is a free signature that contains my company name automatically generated?

A: No. SMS Verification Service supports access without qualification review, and you can use only the system-provided free signatures and free templates. Custom signatures are not supported. A signature that contains your company name is usually generated in the separate Short Message Service product after you submit and pass qualification review there. It is not related to SMS Verification Service. If your app store review requires the signature to match your app name, we recommend that you use Short Message Service instead and upload your enterprise qualifications to apply for a custom signature.

FAQ

Q: I purchased a resource plan, but I cannot use it, or my API calls fail. What should I do?

A: Check the following items:

  • Account status: Make sure that your Alibaba Cloud account balance is greater than 0. If your account is in arrears, the resource plan cannot be used to offset charges.

  • Permission configuration: If you use a RAM user, make sure that the RAM user is granted the AliyunDypnsFullAccess permission.

  • API operation and parameters: Make sure that you call SendSmsVerifyCode instead of SendSms, and that the TemplateParam parameter is in the correct format.

  • Signature and template pairing: Make sure that you use a free signature together with a free template provided by the system. Do not mix free and custom signatures or templates.

Q: I have enabled Converged Authentication. Can I use only SMS verification and disable the other authentication methods?

A: If you need only the SMS verification code capability, we recommend that you integrate directly with the SMS Verification API of PNVS. This is a pure server-side API that requires no client SDK integration and gives you full control over the authentication flow. You do not need to disable the other methods in Converged Authentication. Note that SMS Verification Service provides only verification code generation, delivery, and verification capabilities. It does not include business logic such as handling network disconnection and reconnection. You must implement such logic yourself on the business side.

Billing and resource plans

SMS Verification Service offers two billing methods: pay-as-you-go and resource plans. Choose a billing method based on your expected usage.

For tiered pricing details, see SMS Verification (API Version). On the SMS Verification Overview page, you can also view your current resource plan balance or purchase an SMS Verification resource plan.

Delivery records

Log in to the PNVS console. In the left-side navigation pane, choose SMS Verification Service > Delivery Records. On the Delivery Record Query page, filter or export data.

On this page, filter queries by date, Scheme Name, Signature, Template, Delivery Status, Phone Number, bizId, and OutId. SMS delivery receipts are typically returned within 72 hours. You can query detailed records up to 180 days old.

FAQ

Q: How do I get the SDK dependency and complete sample code for the SMS Verification Service API operations?

A: You can obtain the SDK dependency and sample code as follows:

  • Java SDK dependency: groupId com.aliyun, artifactId dypnsapi20170525. We recommend version 2.0.0. This version is also compatible with JDK 8 environments.

  • PHP SDK dependency: Run composer require alibabacloud/dypnsapi-20170525 2.0.0.

  • Sample code: Go to the Alibaba Cloud OpenAPI Explorer, and select your programming language to view and download a complete project that includes both sending (SendSmsVerifyCode) and verifying (CheckSmsVerifyCode) verification codes.