Verify OTP API
Check the validity of the one-time passcode (OTP) that a user provided. Please read API General Reference before reading this document.
After using the Send OTP API to send a verification code to the user, you can quickly verify whether the provided code is correct by simply submitting the received code and the user's phone number, without the need to cache any data.
Definitions
- Action:
otp.verify
- HTTP Method:
POST
- Content-Type:
application/json
Request Parameters
Name | Type | Required | Description | Example |
---|---|---|---|---|
to | string | Yes | User's phone number for verification. Using E.164 format. | +12068800123 |
code | string | Yes | Code the for verification. Must be a 4-8 digit string. | 123456 |
intent | string | No | User's intent for verification, should be the same as the one passed with the Send OTP API. Maximum 36 characters. | login |
ttl | integer | No | Time-to-live for the code in seconds. Max: 1800 . Default: 300 (5 minutes) * Only applicable to automatically generated OTP codes, does not affect custom codes. | 300 |
Request Example
The following example will check and return whether the user-provided verification code is correct.
curl -X POST 'https://api.unimtx.com/?action=otp.verify&accessKeyId=YOUR_ACCESS_KEY_ID' \
-H 'Content-Type: application/json' \
-d '{
"to": "+120688001xx",
"code": "123456"
}'
Response Parameters
Name | Type | Description | Example |
---|---|---|---|
code | string | Return code | 0 |
message | string | Return message | Success |
data | JSON | Results |
Results data
Name | Type | Description | Example |
---|---|---|---|
to | string | User's phone number (E.164) | +12068800123 |
valid | boolean | Indicates whether the provided code is valid | true |
Response Examples
Successful response example
Status Code: 200
, Response Body:
{
"code": "0",
"message": "Success",
"data": {
"to": "+12068800123",
"valid": true
}
}
Failure response example
Status Code: 400
, Response Body:
{
"code": "104001",
"message": "MissingParams"
}