TextLink
  • Sending an SMS
  • OTP/Phone verification
  • Send SMS through your phone
  • Receiving SMS and webhook setup for SMS notifications
Powered by GitBook
On this page
  • Sending an HTTP POST request
  • Send phone number verification SMS to your customers.
  • Examples for different programming languages
  • Check if the code is valid
  • Verify the code that the customer has submitted.
  • Code examples

OTP/Phone verification

Last updated 1 month ago

Besides , 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

Name
Type
Description

Content-Type*

The value should be "application/json"

Authorization*

Request Body

Name
Type
Description

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

expiration_time

Integer

How long the code is valid, in miliseconds

{
  ok: true,
  code: "123456" // The code sent
}
{
  ok: false,
  message: "Reason string"
}

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);
// Firstly, install the helper library using  or 

import TextLink from "textlink-sms";
TextLink.useKey("YOUR_API_KEY");

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

await TextLink.sendVerificationSMS("+11234567890", verificationOptions);
# Firstly, install the helper library using 

import textlink as tl

tl.useKey("YOUR_API_KEY") # Replace with your API key

result = tl.sendVerificationSMS("+11234567890", service_name="Tribal")
print(result)

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

Name
Type
Description

Content-Type*

The value should be "application/json"

Authorization*

Request Body

Name
Type
Description

phone_number*

String

The phone number that you would like to verify

code

String

The OTP code to verify

{
  ok: true
}
{
  ok: false,
  message: "Reason string"
}

Code examples

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

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

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

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

API Console
ISO2 code
API Console
sending SMS