Skip to main content

OTP Engine V2

The main difference between v1 and v2 is in v2 Response Body contains metadata that show
next_resend_at, resend_count and resend_limit. Also when resend_limit exceeded, it will Lock that User for requesting OTP. The Duration is based on authentication flow config. ba

Get Client Config

Same Implementation with V1 Here

OTP with Basic Auth

To request and validate OTP using otp with basic auth flow, you need to send base64(client_id:client_secret) as basic auth token. Here's the Example Flow Use Case:

ExampleFlow

API Endpoints

Request OTP

URL:
POST /v2/passwordless/start
Authorization: Basic <base64(client_id:client_secret)>
Content-Type: application/json
Request Body:
{
"username": "081200010002"
}
Success (200) Response Body:
{
"username": "081200010002",
"otp": "59180",
"timestamp": "2024-03-07T06:37:48.079251Z",
"metadata": {
"next_resend_at": "2024-03-07T13:38:48.078787+07:00",
"resend_count": 0,
"resend_limit": 3
}
}
Failed (400) Response Body:
{
"error": "invalid_body",
"error_description": "Invalid Request Body",
"timestamp": "2023-08-21T02:44:53Z"
}
Failed (401) Response Body:
{
"error": "identifier_has_active_verification",
"error_description": "User has Active OTP",
"timestamp": "2024-03-07T06:38:23.507756Z",
"metadata": {
"next_resend_at": "2024-03-07T13:38:48.078787+07:00",
"resend_count": 0,
"resend_limit": 3
}
}

List Of Possible Response

http status codeerror codemessage
500unexpected_errorSomething Went Wrong
400invalid_request_bodyInvalid Request, Please Check Your Request Body
400invalid_request_bodyPlease Enter a valid username
400otp_resend_limit_exceededOTP Resend Limit Exceeded
401invalid_client_credentialInvalid Client Credentials
401identifier_has_active_verificationUser has Active OTP

Validate OTP

URL:
POST /v2/passwordless/validate

Header:
Authorization: Basic <base64(client_id:client_secret)>
Content-Type: application/json
Request Body:
{
"username": "081200010002",
"otp": "123456"
}
Success (200) Response Body:
{
"message": "OTP Validated Successfully",
"timestamp": "2023-01-01T00:00:00Z"
}
Failed (400) Response Body:
{
"error": "invalid_otp",
"error_description": "OTP is Invalid",
"timestamp": "2024-03-07T07:06:36.977945Z",
"metadata": {
"invalid_attempt": 1,
"max_invalid_attempt": 3
}
}

List Of Possible Response

http status codeerror codemessage
500unexpected_errorSomething Went Wrong
400invalid_request_bodyInvalid Request, Please Check Your Request Body
400invalid_request_bodyPlease Enter a valid username
400verification_not_foundVerification Not Found
400wrong_otp_request_limitWrong OTP Limit Request Exceeded
400invalid_otpOTP is Invalid
400verification_is_expiredVerification Expired
400used_otpOTP is Already Used
400invalid_otp_config_changedOTP is Invalid, Please Request New OTP
401invalid_client_credentialInvalid Client Credentials
401identifier_has_active_verificationUser has Active OTP