Two factor authentication API with phone call
Back to Articles
News VoIP SIP API Security Two Factor Authentication Howto

Two factor authentication API with phone call

May 15, 2018 3 min
Aivis Olsteins

Aivis Olsteins

Two factor authentication (2FA) using telephone can be made in several different ways. One, most popular is of course by sending a text message. It is fast and easy way to verify the authenticity of the other party. However, there are cases when SMS is not the best option or even not possible at all, like;

  1. if the remote party is unable to receive text messages, like fixed lang line phones;
  2. if increased security is needed: short messages might be stored on users phones and their contents viewed by third parties, whereas voice message does not persist after once spoken;
  3. accessibility: for persons who may have difficulties to read;
  4. cost issues: for many destinations a cost of the voice call of halt a minute is still lower than sending a text message

In these cases sending a voice call with prerecorded or text-to-speech message is an alternative solution.

There are two main ways to send authorization code over a phone call: either by a prerecorded voice message or by text-to-speech. The advantages of each method include:

  1. for text-to-speech:much easier and faster deployment: no need to prerecord voice messages;
  2. no additional third-party costs for text to speech conversion;
  3. no need to worry about language constructs if sending multi-digit numbers;
  4. for prerecorded messages:larger langauge coverage: may record messages in the languages where text to speech is not available;
  5. higher reliability: text-to-speech engine more probable to be unavailable than an audio file stored locally;

Here are examples of API call for the methods described above.

First example is for a text-to-speech message which will send authentication code 123456 in English. For better user experience it will repeat the message two times:

POST /voice/call/play


{
"to": "12125551212",
"from": "me",
"playlist":
[
{
"play": "Your code is 123456",
"type": "tts",
"options":
{
"language": "en-US",
"gender": "female",
"say-as": "digits"
}
},
{
"play": "Your code is 123456",
"type": "tts",
"options":
{
"language": "en-US",
"gender": "female",
"say-as": "digits"
}
}
],
"carrier_id": "74445609"
}

 

The other example uses files stored at the location http://server.domain.com/voices/ . Here also they speak the same code two times:

 

POST /voice/call/play

{
"to": "12125551212",
"from": "me",
"playlist":
[
{
"play": "http://server.domain.com/voices/your-code-is.wav"
},
{
"play": "http://server.domain.com/voices/1.wav"
},
{
"play": "http://server.domain.com/voices/2.wav"
},
{
"play": "http://server.domain.com/voices/3.wav"
},
{
"play": "http://server.domain.com/voices/4.wav"
},
{
"play": "http://server.domain.com/voices/5.wav"
},
{
"play": "http://server.domain.com/voices/6.wav"
},
{
"play": "http://server.domain.com/voices/your-code-is.wav"
},
{
"play": "http://server.domain.com/voices/1.wav"
},
{
"play": "http://server.domain.com/voices/2.wav"
},
{
"play": "http://server.domain.com/voices/3.wav"
},
{
"play": "http://server.domain.com/voices/4.wav"
},
{
"play": "http://server.domain.com/voices/5.wav"
},
{
"play": "http://server.domain.com/voices/6.wav"
}
],
"carrier_id": "74445609"
}

Notes regarding above examples:

  1. carrier_id tag is described in a previous post entry about SIP routing.
  2. there is a say-as tag in the text to speech example. It is needed to indicate to text to speech engine to say digits individually instead of pronouncing a six-digit number as a whole.

Share this article

Aivis Olsteins

Aivis Olsteins

An experienced telecommunications professional with expertise in network architecture, cloud communications, and emerging technologies. Passionate about helping businesses leverage modern telecom solutions to drive growth and innovation.

Related Articles

The Commitment Economy: Why Voice AI Bookings Must Be Integrated, Not Just Conversational

The Commitment Economy: Why Voice AI Bookings Must Be Integrated, Not Just Conversational

AI can promise a booking, but what about the broken promise? Learn why systemic integration, Accuracy Rate, and System Sync define the real test of Voice AI reliability

Read Article
Beyond the Dial Tone: 3 Metrics That Define Outbound AI Success

Beyond the Dial Tone: 3 Metrics That Define Outbound AI Success

Outbound AI requires a new scorecard. Learn the 3 metrics (Connection Rate, Engagement Quality, and Conversion Impact) that measure pipeline movement, not just call volume

Read Article
The New AI Scorecard: How to Measure Campaign Effectiveness Beyond "Call Volume"

The New AI Scorecard: How to Measure Campaign Effectiveness Beyond "Call Volume"

Stop guessing with 'Call Volume'. Discover the 3-Layer Framework for measuring Voice AI success: Goal Completion Rate (GCR), Sentiment Drift, and Knowledge Retrieval. Turn phone calls into structured marketing data

Read Article
What Happens to Metrics When "Hold Time" Hits Zero?

What Happens to Metrics When "Hold Time" Hits Zero?

Does Voice AI just save money? No. Discover the "CSAT Paradox" and how zero hold time improves revenue, lead capture, and team morale simultaneously.

Read Article

SUBSCRIBE TO OUR NEWSLETTER

Stay up to date with the latest news and updates from our telecom experts