OTP/Phone verification

Besides sending SMS, TextLink API can automate one-time-password (OTP) verification for phone numbers. The pricing for OTP verification is the same as sending a normal SMS, but we give OTP messages higher priority and faster delivery times.

The main perk of using our solution for verifying phone number is the removal of need to store the valid codes in your database, since we can verify codes for you.

Sending an HTTP POST request

To send a verification SMS, you can send the following POST request with tool of your choice (like Postman), or use any of the programming languages that support REST API calls.

Send phone number verification SMS to your customers.

POST https://textlinksms.com/api/send-code

Headers

NameTypeDescription

Content-Type*

The value should be "application/json"

Authorization*

The value should be "Bearer API_KEY", where API_KEY is the API key that you have registered on the API Console

Request Body

NameTypeDescription

phone_number*

String

Recipient phone number, with country prefix. E.g. +11234567890

service_name

String

Your name to be shown in the message

source_country

String

Uppercase ISO2 code of the sender phone number country. If left out, the cheapest option will be used.

expiration_time

Integer

How long the code is valid, in miliseconds

{
  ok: true,
  code: "123456" // The code sent
}

Examples for different programming languages

// Firstly, install the helper library using  or 

const textlink = require("textlink-sms");
textlink.useKey("YOUR_API_KEY"); // Replace with your API key

const verificationOptions = {
    service_name: "Tribal", 
    expiration_time: 10 * 60 * 1000,
    source_country: "US"
}; // This is optional

await textlink.sendVerificationSMS("+11234567890", verificationOptions);

Check if the code is valid

After you have sent the one-time-password to your user, you can prompt him to enter the code in your website or application. After he has entered the code, you can use the /verify-code endpoint, to check if it is valid, without having to store the code locally.

Verify the code that the customer has submitted.

POST https://textlinksms.com/api/verify-code

Headers

NameTypeDescription

Content-Type*

The value should be "application/json"

Authorization*

The value should be "Bearer API_KEY", where API_KEY is the API key that you have registered on the API Console

Request Body

NameTypeDescription

phone_number*

String

The phone number that you would like to verify

code

String

The OTP code to verify

{
  ok: true
}

Code examples

const result = await textlink.verifyCode("+11234567890", "USER_ENTERED_CODE"); 
//if `result.ok` is true, then the phone number is verified. 

Last updated