Skip to main content

Request One-Time Passcode

Use the BlockID SDK to request a one-time passcode to your user's phone number or email address.

Request One-Time Passcode

After configuring the SDK with your tenant information and license key found on the BlockID Developer Dashboard, you are ready to request a one-time passcode.

Parameters

  • dns: Your tenant domain as shown in the dashboard
  • communityName: Your tenant communnity name as shown in the dashboard
  • licenseKey: Your tenant license key as shown in the dashboard
  • username: Your registered full email address
  • emailToOrNull: Email to send OTP - enter null to omit
  • smsToOrNull: Phone number, including area code, to send OTP - enter null to omit
  • ISDCodeOrNull: International subscriber dialing code of the phone number - enter null to omit
Important:

Not all the parameters are necessary for each request. To send an OTP to only an email, or only a phone number, omit the parameters you don't wish to use.

If you omit both the phone and email, the OTP will be returned in the body of the server response

Request Format

  • Set tenant info and request OTP
const BIDOTP = require('blockid-nodejs-helpers/BIDOTP');

let otpResponse = await BIDOTP.requestOTP({ "dns": "<dns>", "communityName": "<communityName>", "licenseKey": "<licenseKey>" }, "<username>", "<emailToOrNull>", "<smsToOrNull>", "<smsISDCodeOrNull>");

Example OTP Request

We've provided some example OTP requests using the BlockID SDK.

Please note:

These are just examples - you will probably want to configure your development environment to request a one-time passcode as part of a sign-in request or something similar.


Example OTP Request - SMS and Email

Send a one-time passcode to both a user's phone number and an email. The same passcode will be sent simultaneously to the number and email entered.

const BIDOTP = require('blockid-nodejs-helpers/BIDOTP');

let otpResponse = await BIDOTP.requestOTP({ "dns": "blockid-trial.1kosmos.net", "communityName": "devx", "licenseKey": "0005c9f8-1918-40be-aa00-e319043f7xxx" }, "john.smith", "john.smith@company.com", "5558675309", "1");

Example OTP Request - SMS Only

To send a one-time passcode to only a phone number, omit the email parameter.

const BIDOTP = require('blockid-nodejs-helpers/BIDOTP');

let otpResponse = await BIDOTP.requestOTP({ "dns": "blockid-trial.1kosmos.net", "communityName": "devx", "licenseKey": "0005c9f8-1918-40be-aa00-e319043f7xxx" }, "john.smith", null, "5558675309", "1");

Example OTP Request - Email Only

const BIDOTP = require('blockid-nodejs-helpers/BIDOTP');

let otpResponse = await BIDOTP.requestOTP({ "dns": "blockid-trial.1kosmos.net", "communityName": "devx", "licenseKey": "0005c9f8-1918-40be-aa00-e319043f7xxx" }, "john.smith", "john.smith@company.com", null, null);

Example OTP Request - Neither SMS nor Email (OTP Returned in Response Body)

const BIDOTP = require('blockid-nodejs-helpers/BIDOTP');

let otpResponse = await BIDOTP.requestOTP({ "dns": "blockid-dev.1kosmos.net", "communityName": "devx", "licenseKey": "9b074532-845b-4c75-ba3e-2b89598adxxx" }, "john.smith", null, null, null);

Example Server Response

The SDK will return an immediate response from our API. The responses are the same across each SDK and are JSON formatted. Possible response codes you might receive include:

Server Responses

200 OK

{
"messageId":"15f9dd86-9a8a-4c66-900a-f711f5acceb1",
"info":"OTP request accepted"
}

The API accepted the OTP request and sent a one-time passcode to the phone or email.