1. Home
  2. Docs
  3. API Documentation
  4. Active APIs
  5. requestOneTimeCode

requestOneTimeCode

This API generates an OTP (One Time Password).

The OTP generated will be sent to you in the response of this API.

Additionally, if you send a tokenCreator, the API will generate and send a token-OTP pair to you which you can send back if you need verification (please see the API verifyOneTimeCode).

This API needs to be called using an HTTP Post method with data in JSON format as shown below.

URL: https://api2.juvlon.com/v4/requestOneTimeCode

JSON Parameters

'{"apiKey":"$apiKey",
   "codeType":"$codeType",
   "codeLength":"$codeLength",
   "tokenCreator":"$tokenCreator",
   "expiry":"$expiry",
   "reCreate":"$reCreate"          		   
 }';

Arguments

NameTypeDescriptionDefault
apiKeyStringMandatory. The apiKey that gives you access to our HTTP APIs. The apiKey authenticates you and helps us to identify your Juvlon account. 
codeTypeStringMandatory.
num – If you want an OTP with digits only
alpha  – If you want an OTP with alphabets only
alphanum – If you want an OTP that is a mix of digits and alphabets.
 num
codeLengthintMandatory. The length of the OTP code to be generated.

You can specify a length between 4-12.
 4
tokenCreatorStringAny string that helps you to identify your user (for e.g., the user’s email address, mobile number, sessionID etc.). 

To be provided if you need to verify the OTP, that your user will eventually provide, by calling our verifyOneTimeCode API.

When provided, the API will generate a token in addition to the OTP, and send the token-OTP pair in the response. You will then need to store and re-send the token along with the OTP entered by the user for verification (see API verifyOneTimeCode).
expiryintTo be used with the tokenCreator if OTP verification is required.

Number of seconds for which the token-OTP pair is to be kept active. Any verification attempt made after this time elapses will fail.

(No Expiry)
reCreatebooleanTo be used with the tokenCreator if OTP verification is required when the user requests an OTP again. For example the “Resend OTP” feature if the user has not received an OTP.

true – To generate a new token-OTP pair even if an older active token-OTP pair exists for the same tokenCreator (email address / mobile number etc.).

false – To again receive any older live token-OTP pair for the same tokenCreator (if exists).
false

Return values

NameTypeDescription
codeStringThe Success or Error response code as returned by the API. Please refer to the section “Possible-Response-Codes” for more details.
statusStringDescription of the error code returned.
transactionIdStringA number generated by the API to uniquely identify the current call. Also known as the API_Call_ID.
OTPStringThe one time code generated by the API.
token String A token generated when requested (by sending a tokenCreator).

To be stored and re-sent along with the OTP entered by the user for verification (see API verifyOneTimeCode).

Usage / Example(s)

PHP Example Code for Integration

$url = 'https://api2.juvlon.com/v4/requestOneTimeCode';
$data = '{"apiKey":"KEY",
          "codeType":"num",
          "codeLength":"4",
          "tokenCreator":"example@abc.com",
          "expiry":"300",
          "reCreate":"false"
         }'; 
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$res1 = curl_exec($ch);
curl_close($ch);

Success-Response

 HTTP/1.1
  {
     "code":200,
     "status":"Success",
     "transactionId":"3274",
     "OTP":"9027",
     "token":"OJUWLB"
  }

Error-Response

 HTTP/1.1
  {
     "code":403,
     "status":"Error",
     "transactionId":"3275"
  } 

Possible-Response-Codes

200    Success: API Request Accepted
401    Error:Invalid Method
402    Error: Unauthorized/Empty Key
403    Error: Unauthorized/Invalid Key
404    Error: Account Sending Blocked
405    Error: Your Juvlon account is expired
448    Error: Your Juvlon account is Deactivated
480    Error: Invalid Code Type
481    Error: Invalid Code Length
482    Error: Invalid Expiry
483    Error: Invalid Recreate Option