tencent cloud

문서Tencent OneID Identity Security

Sending OTP Verification Code

Download
포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-08-26 15:38:13
AI 번역

API Description

Send an SMS or email OTP verification code to the user for login, registration, or updating user information.

Supported Application Types

Web applications and M2M applications.

Request Method

POST

Request path

/otp/send

Request Content-Type

application/json

Request Example

In the SMS OTP login scenario, an SMS verification code is sent for login.
POST /otp/send HTTP/1.1
Content-Type: application/json
Authorization: Basic VEVOQU5UX0NMSUVOVF9JRDpURU5BTlRfQ0xJRU5UX1NFQ1JFVA==
Host: sample.portal.tencentciam.com

{
"usage" : "login",
"phone_number" : "13612345678",
"auth_source_id" : "MOCK_SMS_OTP_AUTH_SOURCE_ID"
}

In the email OTP login scenario, an email verification code is sent for login.
POST /otp/send HTTP/1.1
Content-Type: application/json
Authorization: Basic Q0xJRU5UXzRfSUQ6Q0xJRU5UXzRfU0VDUkVU
Host: sample.portal.tencentciam.com

{
"usage" : "login",
"email" : "MOCK_USERNAME@example.com",
"auth_source_id" : "MOCK_EMAIL_OTP_AUTH_SOURCE_ID"
}
In the user registration scenario, an SMS verification code is sent for binding a mobile phone.
POST /otp/send HTTP/1.1
Content-Type: application/json
Authorization: Basic Q0xJRU5UXzRfSUQ6Q0xJRU5UXzRfU0VDUkVU
Host: sample.portal.tencentciam.com

{
"usage" : "signup",
"phone_number" : "13612345678"
}
In the user registration scenario, an email verification code is sent for binding an email address.
POST /otp/send HTTP/1.1
Content-Type: application/json
Authorization: Basic Q0xJRU5UXzRfSUQ6Q0xJRU5UXzRfU0VDUkVU
Host: sample.portal.tencentciam.com

{
"usage" : "signup",
"email" : "MOCK_USERNAME@example.com"
}
In the update user information scenario, an SMS verification code is sent for binding or updating a mobile phone number.
POST /otp/send HTTP/1.1
Content-Type: application/json
Authorization: Basic Q0xJRU5UXzRfSUQ6Q0xJRU5UXzRfU0VDUkVU
Host: sample.portal.tencentciam.com

{
"usage" : "update_userinfo",
"phone_number" : "13612345678"
}
In the password reset scenario, an email verification code is sent.
POST /otp/send HTTP/1.1
Content-Type: application/json
Authorization: Basic Q0xJRU5UXzRfSUQ6Q0xJRU5UXzRfU0VDUkVU
Host: sample.portal.tencentciam.com

{
"usage" : "reset_password",
"email" : "MOCK_USERNAME@example.com"
}

Request header

Term
Description
Authorization
The HTTP Basic authentication request header has the format Basic <credentials>. Here, Basic is a fixed string, and <credentials> is calculated as base64(url_encode(client_id) + ":" + url_encode(client_secret)). A single space separates Basic and <credentials>.

Request Body JSON Parameters

JSON Path
Data Type
Description
usage
String
Scenarios for OTP verification code usage.
In the SMS and email OTP login scenario, enter login.
In the user registration scenario, enter signup.
In the update user information scenario, enter update_userinfo.
In the reset user password scenario, enter reset_password.
If no input parameters are provided, the login scenario is represented by default.
phone_number
String
The user's mobile phone number must be an 11-digit number from one of the three major domestic carriers. Pass this parameter when an SMS OTP verification code is sent.
email
String
The user's email address. Pass this parameter when an email OTP verification code is sent.
auth_source_id
String
The SMS OTP or email OTP authentication source ID. You can view it on the General Authentication Sources list page in the console. Pass this parameter in SMS and email OTP login scenarios, and the system will use the verification code length and validity period configured for the authentication source. In other scenarios, do not pass this parameter. The system then uses a 6-digit numeric verification code by default, with a validity period of 60 seconds.

Normal Response Example

The verification code has been sent successfully.
HTTP/1.1 200 OK
Content-Type: application/json

{
"otp_token" : "MOCK_OTP_TOKEN"
}

Response Parameters

Field
Data Type
Description
otp_token
String
The OTP token is used for subsequent OTP verification. Its validity period is 5 minutes.

Exception Response Example

The mobile phone number format is incorrect.
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8

{
"error" : "malformed_phone_number"
}
The email address format is incorrect.
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8

{
"error" : "malformed_email"
}
SMS cannot be sent due to insufficient SMS quota. This is usually because the free SMS quota has been exhausted. You need to configure an SMS template in the console.
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8

{
"error" : "insufficient_sms_quota"
}
Email cannot be sent due to insufficient email quota. This is usually because the free email quota has been exhausted. You need to configure an email template in the console.
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8

{
"error" : "insufficient_email_quota"
}
The email address does not exist or is on the blocklist.
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8

{
"error" : "invalid_email"
}
The verification code failed to be sent.
HTTP/1.1 503 Service Unavailable
Content-Type: application/json;charset=UTF-8

{
"error" : "temporarily_unavailable",
"error_description" : "Failed to send OTP. Please try again later."
}
In the registration scenario, the email address is already in use.
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8

{
"error": "email_is_used"
}
In the registration scenario, the mobile phone number is already in use.
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8


{
"error": "phone_number_is_used"
}
The frequency of sending SMS to a single mobile phone number has exceeded the limit.
If you are using a self-purchased SMS service, you can go to the SMS console to adjust the SMS frequency limit policy.
If you are using the free SMS quota, the frequency limit is: For the same mobile phone number, the number of SMS messages sent per calendar day must not exceed 50. For SMS messages with the same content sent to the same mobile phone number, the number of SMS messages sent within 30 seconds must not exceed 1.
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8

{
"error" : "sms_rate_limit_exceeded",
"error_description" : "SMS rate limit exceeded for same phone number"
}


도움말 및 지원

문제 해결에 도움이 되었나요?

피드백