Home
Separator
Blog
Separator

How to Send OTP SMS with Dexatel's Verify API

Diana Nersisyan
Diana NersisyanProduct Owner

Published: Aug 4, 2022

How to Send OTP SMS

Traditionally, applications ask users for a login and password to authenticate accounts.

However, this method is no longer considered secure.

One initial problem users face is creating and setting strong passwords.

They might carelessly write credentials on sticky notes or save them on other devices.

Additionally, hacker attacks can break password-based systems and access corporate data.

To enhance security, an extra layer of protection is necessary.

Nowadays, applications send one-time passwords (OTP) via SMS for user authentication.

OTPs are also used during the user registration process to verify phone numbers while creating accounts.

This method proves account ownership via a phone number.

A randomly generated unique code is sent to the user’s phone, which they must enter for authentication.

One-factor authentication (1FA) requires only a password or a code received on the phone.

A more secure approach is multi-factor authentication (MFA), which requires multiple pieces of information, such as a password and a code.

Two-factor authentication (2FA), a type of MFA, asks users to provide a code received via message along with their username or password.

Requiring two pieces of information, 2FA prevents identity theft by using a code that can only be used once.

Dexatel's SMS API delivers phone-based SMS authentication codes within a limited duration.

Implementing user verification via phone number has several benefits for businesses.

First, verifying mobile numbers adds an extra layer of security, reducing fraudulent activities.

The Verification API sends an automated text message to the subscriber’s phone number for verification, ensuring that the account holder is a real person.

Second, phone number verification protects against spam and multiple account creation, as each phone number is associated with one user.

Third, you obtain a database of verified mobile numbers, allowing you to contact clients whenever needed.

All these tasks are easy to accomplish with Dexatel's Verify API.

How to Integrate Dexatel’s Verify API to Send OTPs

Create an Account

  • Sign up for a free account on the Dexatel platform.
  • Log in to your dashboard to manage your account settings, such as topping up your balance and updating information.

Generate a Unique API Key

  • Navigate to the API Keys section.

The system will generate a unique API key, which you will use to send automatic requests on your behalf.

Create a Sender Name

  • Add your brand name to the Sender IDs, use your shortcode, or choose a new one in the dashboard.

Alternatively, you can send a POST request to the Sender endpoint to send OTP messages with a customized ID.

Get a Template ID

  • Go to the Templates page or send a POST request to the Template endpoint.

Once a template is created, the API will generate a template ID for you to use.

You can also send a GET request to the Templates endpoint to retrieve your template ID.

When creating a template text, make sure to include a {code} variable in it.

The Dexatel Verify API will generate a random OTP and replace the {code} variable in your message.

Example SMS Verification Templates

  • Your dynamic code is {code}. Do not share it with anyone.
  • Your verification code is {code}. Complete the verification as soon as possible.
  • Your registration code is {code}. Thank you!

Verify Your Clients’ Phone Numbers

  • Request your clients' phone numbers to verify their ownership by sending an SMS code.

If the code matches, the verification process will be completed.

If the code does not match, it will expire, and the user will be temporarily blocked after three unsuccessful attempts.

How It Works

When your client provides a phone number for verification purposes, such as to make a payment, your application sends a POST request to the Verification API endpoint.

Here's an example of how to do this:

Endpoint: v1/verifications

Headers:

  • X-Dexatel-Key: {Your Unique Key}
  • Content-Type: application/json

Example POST Request

json
Copy code
{
  "data": {
    "sender": "Your Sender Name",
    "phone": "Your Client’s Phone Number",
    "template": "Your Template ID",
    "code_length": "Length of Code"
  }
}

Upon receiving the request, the Verification API creates a unique code with the specified length as the value for the code_length parameter.

It then sends a message to the phone number specified in the phone parameter.

Make sure to specify the template ID for the template parameter in your request.

The Verify API will use the template corresponding to that ID and replace the {code} placeholder in the message with the generated OTP.

Verification Process

Sending the OTP:

  • The client receives an SMS message containing the OTP.
  • The message is formatted according to the specified template, with the {code} placeholder replaced by the OTP.

Entering the OTP:

  • The client types the OTP into your application.

Validating the OTP:

  • Your application sends a POST request to the Verification API endpoint with the entered OTP.
  • The API compares the entered OTP with the one sent to the client.

Possible Outcomes

Successful Verification:

  • If the OTP matches, the client is successfully verified.

Failed Verification:

  • If the OTP does not match, the client will not be verified.
  • If the client fails to enter the correct OTP within the specified time frame, the OTP will expire.
  • The system can regenerate a new OTP upon receiving a new POST request from your application.

Multiple Failed Attempts:

  • After several unsuccessful attempts, the client may be temporarily blocked.
  • The client can request new OTP SMS codes only after being unblocked.

This process ensures secure and efficient verification of your client's phone number, adding an extra layer of security to your application.