• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Rakuten RapidAPI Blog

The World's Largest API Marketplace

  • Enterprise
    • Product
    • eBooks
    • Contact Us
  • Marketplace
    • Product
    • Sign Up
    • Docs
  • Resources
    • API Blog
    • API Tutorial
    • Developer Showcase
  • EnglishEnglish
    • 日本語日本語
You are here: Home / API Tutorial / API Tutorial: Telesign API

API Tutorial: Telesign API

October 25, 2019 By Shyam Purkayastha Leave a Comment

TeleSign is a CPaaS (Communication Platform as a Service) platform that offers programmable voice and SMS services over the cloud.

In this api tutorial, you will learn to set up a SMS based verification service for achieving two-factor authentication using the Telesign’s SMS Verify API. This API allows online service providers the ability to send SMS passcodes to users to verify their credentials through mobile.

TeleSign SMS Verify API is integrated with Rakuten Rapid API so you can use it straight out of  your account.

API Tutorial TeleSign SMS Verify

In case you don’t have an account on Rakuten Rapid API, sign up now and get your universal API key to access the TeleSign SMS Verify API and thousands of other APIs hosted on Rakuten Rapid API.

Connect to API

Table of Contents

  • 1 Setting Up Telesign SMS API
  • 2 TeleSign SMS Verify API Overview
    • 2.1 User Account Verification
    • 2.2 Phone Number Validation
    • 2.3 Transaction Authorization
    • 2.4 SMS API Endpoint
  • 3 Sending SMS Programmatically
  • 4 Do More With SMS APIs
    • 4.1 Share this:

Setting Up Telesign SMS API

Log on to your Rakuten Rapid API account and search for SMS.  You can see a bunch of SMS APIs that are hosted on our platform.

You should be able to quickly locate the Telesign SMS Verify API from the search results.

rakuter rapid api sms apis

Click on the TeleSign SMS Verify API and you will be presented with the API console.

telesign sms verify api console

TeleSign SMS Verify API is a paid service, hence you need to choose from one of the available pricing plans under the pricing tab.

telesign sms verify pricing

Connect to API

To try out this service you can subscribe to the $1/month BASIC plan.

Let’s go ahead and explore the TeleSign SMS Verify API.

TeleSign SMS Verify API Overview

SMS based verification is one of the most widely used methods for 2FA (Two-factor Authentication). Due to the scale of Internet usage, it is no longer safe to just rely on a password for securing access to online services. A 2FA mechanism allows service providers to gain evidence about the authenticity of the user’s actions through an alternate mechanism, which, in this case, is the smartphone.

So how can you leverage TeleSign SMS Verify API? Here are some use cases.

User Account Verification

 

login

 

If you are building a web-based service that requires users to login, then apart from the usual username & password-based authentication, you can additionally verify the user’s authenticity by sending them a passcode on their smartphone. This is one of the most secure ways of logging in, Since a smartphone is a personal device only accessible to the user, the user’s account is not compromised even if the password gets revealed.

Phone Number Validation

 

smartphone

 

There are a lot of services that are based on mobile apps. In such cases, it is important to verify the phone number of the user’s mobile/smartphone before they even start using the service.  A one-time passcode sent to the user’s phone suffices the verification step if the user enters the same passcode on the verification screen of the app.

Transaction Authorization

 

transaction password

 

We hear about users availing services from eCommerce stores, payment wallets and OTT subscriptions all the time. Since these transactions are monetary in nature, it is always better to have an additional guard at the payment process to prevent misuse of the user’s account. A one-time password (OTP) sent via SMS to the user’s phone ensures that each transaction is authorized by the user after seeing the OTP.

 

Connect to API

 

SMS API Endpoint

The TeleSign’s SMS Verify API is really a very simple and straightforward API call that accepts a phone number and the passcode.

telesign api parameters

To test this API from the Rakuten Rapid API console, enter your phone number in the phoneNumber field (by prefixing the country code without the ‘+’ sign) and enter some random code in the verifyCode field. Click on “Test Endpoint” and you should see a successful API response.

telesign api test

And within a few seconds, you should also get an SMS on your phone with the value that you entered for verifyCode field.

telesign sms received

 

Did you get that? That’s all about using this API. It can’t get simpler than that.

In case you didn’t get the SMS, make sure that you keyed in the right phone number and also check the API response. If you got a non 2XX HTTP response then there can be an issue with TeleSign’s coverage in your country. You can request for coverage details from TeleSign to check if your country or carrier is supported by them.

Sending SMS Programmatically

For real-world applications, you can call the TeleSign SMS Verify API endpoint programmatically using your favorite programming language.

The Rakuten Rapid API console provides code snippets for invoking the APIs. Choose the language and the library and you will have it displayed.

telesign api code snippets

Here is a quick and short python program to call this API using the Python2 unirest library.

import unirest

RAKUTEN_RAPIDAPI_KEY  = "<YOUR_RAKUTEN_RAPIDAPI_KEY>"
RAKUTEN_RAPIDAPI_HOST = "<YOUR_RAKUTEN_RAPIDAPI_HOST>"

phone_string    = raw_input("Enter the phone number: ")
passcode_string = raw_input("Enter the pass code: ")

response = unirest.post("https://telesign-telesign-send-sms-verification-code-v1.p.rapidapi.com/sms-verification-code? phoneNumber=" + phone_string + "&verifyCode=" + passcode_string,
    headers={
        "X-RapidAPI-Host": RAKUTEN_RAPIDAPI_HOST,
        "X-RapidAPI-Key": RAKUTEN_RAPIDAPI_KEY,
        "Content-Type": "application/x-www-form-urlencoded"
    }
)

if(response.code == 290):
    print "SMS sent successfully..."

Copy this code in a text editor, replace the <YOUR_RAKUTEN_RAPIDAPI_KEY> and <YOUR_RAKUTEN_RAPIDAPI_HOST> placeholders with your API key and host domain displayed under the “Header Parameters” section in the API console, and save the file.

You must also ensure that you have the Python unirest library installed under your Python2 runtime environment. This library is used to invoke the API call from within the Python code. In case you don’t have it, use the pip utility to install it,

pip install unirest

Now you can run the program. It will prompt you to enter a phone number and passcode. Afterward, you should see the SMS coming with the same passcode.

You can integrate this code in the backend server logic of an application that handles 2FA for user login The typical sequence of events for handling 2FA with this API will be like this.

TeleSign 2FA Sequence Diagram

Connect to API

Do More With SMS APIs

Under the basic plan, TeleSIgn does not provide a custom phone number. However, you can purchase a phone number from TeleSign directly and use that as a sender phone number for SMSs. That way, the SMS message will look more genuine.

Additionally, you can try out the other TeleSign APIs integrated with Rakuten Rapid API.

telesign all apis

In case you are looking for more options for SMS APIs, we have got you covered. Check out our Top 10 SMS APIs and take your pick. You can also take a look at out SMS API collection.

That’s it for now. We will be back soon with yet another API tutorial to ease your development chores. Good luck with TeleSIgn SMS Verify and do not hesitate to contact us in case you need any support.

 

5 / 5 ( 2 votes )

Share this:

  • Click to share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Reddit (Opens in new window)

Filed Under: API Tutorial

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Accelerate tech modernization

To compete in the digital age, Rakuten RapidAPI helps enterprises deploy scalable and flexible IT systems to allow for ongoing experimentation and iteration at speed.

Learn More
Try Rakuten RapidAPI for free
  • Enterprise
  • Marketplace
  • Resources
  • EnglishEnglish

© 2022 Rakuten RapidAPI. All rights reserved.