Skip to content

Validate OTP ​

Verifies a basic or advance OTP. Both use the same endpoint, distinguished by otp_type — advance additionally requires the transaction_id the code was bound to.

Endpoint ​

http
POST /api/v1/saas-sotp/validate-sotp
Content-Type: application/json

Basic OTP ​

Verifies a code generated from the client secret and time alone, with no transaction context.

Parameters:

ParamTypeRequiredDefaultDescription
partner_idstringYes—The partner id.
partner_keystringYes—The partner key.
tokenstringYes—The registration token generated by Register.
app_idstringYes—The app id, used for tracking.
otpstringYes—The OTP generated by the SDK from the key returned by Activate.
otp_typestringYes—basic when verifying a basic Soft OTP.
bash
curl --location --request POST '<BASE_URL>/saas-sotp/validate-sotp' \
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json' \
  --data-raw '{
    "partner_id": "{{partner_id}}",
    "partner_key": "{{partner_key}}",
    "token": "{{token}}",
    "app_id": "{{app_id}}",
    "otp": "123456",
    "otp_type": "basic"
  }'

Advance OTP ​

Verifies a code bound to one transaction through its challenge key.

Parameters:

ParamTypeRequiredDefaultDescription
partner_idstringYes—The partner id.
partner_keystringYes—The partner key.
tokenstringYes—The registration token generated by Register.
app_idstringYes—The app id, used for tracking.
otpstringYes—The OTP generated by the SDK from the key returned by Activate.
otp_typestringYes—advance when verifying an advance Soft OTP.
transaction_idstringYes—The unique transaction id on the partner side.
bash
curl --location --request POST '<BASE_URL>/saas-sotp/validate-sotp' \
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json' \
  --data-raw '{
    "partner_id": "{{partner_id}}",
    "partner_key": "{{partner_key}}",
    "token": "{{token}}",
    "app_id": "{{app_id}}",
    "transaction_id": "{{transaction_id}}",
    "otp": "123456",
    "otp_type": "advance"
  }'

WARNING

Use advance for anything that moves money. A basic OTP proves only that the user holds the device — it is not bound to the amount or the recipient, so a code captured during one action can authorize a different one.

Response ​

json
{
  "success": true,
  "code": 1,
  "message": "Success"
}
FieldTypeDescription
successboolRequest status.
codeintThe status code — 1 means the OTP is valid.
messagestringThe status or error message.

Validate this on your backend and convert it into your own status code before returning anything to the app.

Errors ​

CodeDescription
103Thông tin Partner không chính xác — Partner details are incorrect.
121Yêu cầu vượt giới hạn. Vui lòng thử lại sau ít phút. — Request limit exceeded.
123Yêu cầu vượt giới hạn. Vui lòng thử lại sau ít phút. — Request limit exceeded.
124OTP không hợp lệ — Invalid OTP.
126Có lỗi xảy ra vui lòng thử lại — An error occurred, please retry.
129Token không hợp lệ — Invalid token.
190108Tài khoản chưa hoạt động — Account not activated.
190203Không tìm thấy transaction — Transaction not found. Advance OTP only.

Repeated 124 responses that the user believes are correct usually mean clock drift, not a wrong code — call Sync Time.

Next Steps ​

Developers