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

NameTypeRequiredDescriptionExample
tostringYesUser's phone number for verification. Using E.164 format.+12068800123
codestringYesCode the for verification. Must be a 4-8 digit string.123456
intentstringNoUser's intent for verification, should be the same as the one passed with the Send OTP API. Maximum 36 characters.login
ttlintegerNoTime-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

NameTypeDescriptionExample
codestringReturn code0
messagestringReturn messageSuccess
dataJSONResults

Results data

NameTypeDescriptionExample
tostringUser's phone number (E.164)+12068800123
validbooleanIndicates whether the provided code is validtrue

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"
}