Developer Guide

Send SMS Verification

Send an SMS with verification code and a custom message for authentication purpose.

NOTE: You need to register for an API key before using this REST API. Please visit Micro Plan to sign up for an API key if you do not have one. In addition, you will also have to make sure you have enough SMS credits to send any verification SMS.

GET https://api.fraudlabspro.com/v1/verification/send

Request
Parameter Description
tel (required) The recipient mobile phone number in E164 format which is a plus followed by just numbers with no spaces or parentheses.

For example, +123456789

country_code (optional) ISO 3166 country code for the recipient mobile phone number. If parameter is supplied, then some basic telephone number validation is done.
key (required) FraudLabs Pro API key.
mesg (required) The message template for the SMS. Add <otp> as placeholder for the actual OTP to be generated. Max length is 140 characters.

For example,
Your OTP for the transaction is <otp>

format (optional) Returns the API response in json (default) or xml format.
Valid values: json | xml
The input parameter must be encoded the same way that the posted data from a WWW form is encoded. In other words, the percent-encoding.
Response
Parameter Description
tran_id Unique ID (20 characters) for this particular API call.
credits_remaining Number of remaining credits for sending SMS.
error Blank if there is no error otherwise it will contain one of the errors below:
  • FraudLabs Pro plan has expired.
  • Invalid phone number.
  • Message cannot be blank.
  • Message is too long.
  • API key not found.
  • Insufficient credits.
  • Invalid phone number.
  • Cannot send SMS to fixed line or VoIP lines.
  • Unknown error.
Sample Code
<?php
$apiKey = 'Enter_License_Key';
$params['format']           = 'json';
$params['country_code']     = 'Enter_Country_Code';
$params['tel']              = 'Enter_Mobile_Phone_Number';
$params['mesg']             = 'Hi, your OTP is <otp>.';

$query = '';

foreach($params as $key=>$value){
    $query .= '&' . $key . '=' . rawurlencode($value);
}

////////////
//For https request, please make sure you have enabled php_openssl.dll extension.
//
//How to enable https
//- Uncomment ;extension=php_openssl.dll by removing the semicolon in your php.ini, and restart the apache.
//
//In case you have difficulty to modify the php.ini, you can always make the http request instead of https.
////////////
$result = file_get_contents('https://api.fraudlabspro.com/v1/verification/send?key=' . $apiKey . $query);

$data = json_decode($result);

print_r($data);
?>
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Hashtable;
import java.util.Map;

public class test {
    public static void main(String[] args) {
        try {
            String key = "Enter_License_Key";
            Hashtable<String, String> data = new Hashtable<String, String>();
            data.put("format", "json");
            data.put("tel", "Enter_Mobile_Phone_Number");
            data.put("country_code", "Enter_Country_Code");
            data.put("mesg", "Hi, your OTP is <otp>.");

            String datastr = "";
            for (Map.Entry<String,String> entry : data.entrySet()) {
                datastr += "&" + entry.getKey() + "=" + URLEncoder.encode(entry.getValue(), "UTF-8");
            }
            URL url = new URL("https://api.fraudlabspro.com/v1/verification/send?key=" + key + datastr);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("GET");
            conn.setRequestProperty("Accept", "application/json");

            if (conn.getResponseCode() != 200) {
                throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode());
            }

            BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));

            String output;

            while ((output = br.readLine()) != null) {
                System.out.println(output);
            }
            conn.disconnect();
        }
        catch (MalformedURLException e) {
            e.printStackTrace();
        }
        catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Imports System.Net
Imports System.IO
Imports System.Uri

Public Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim request As HttpWebRequest = Nothing
        Dim response As HttpWebResponse = Nothing

        Dim apiKey As String = "Enter_License_Key"
        Dim data As New Dictionary(Of String, String)

        data.Add("format", "json")
        data.Add("tel", "Enter_Mobile_Phone_Number")
        data.Add("country_code", "Enter_Country_Code")
        data.Add("mesg", "Hi, your OTP is <otp>.")
        Dim datastr As String = String.Join("&", data.[Select](Function(x) x.Key & "=" & EscapeDataString(x.Value)).ToArray())

        request = Net.WebRequest.Create("https://api.fraudlabspro.com/v1/verification/send?key=" & apiKey & "&" & datastr)

        request.Method = "GET"
        response = request.GetResponse()

        Dim reader As System.IO.StreamReader = New IO.StreamReader(response.GetResponseStream())

        Page.Response.Write(reader.ReadToEnd)

    End Sub

End Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Net;
using System.IO;

namespace WebApplication1
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            WebRequest request = null;
            WebResponse response = null;

            string apiKey = "Enter_License_Key";
            Dictionary<string, string> data = new Dictionary<string, string>();

            data.Add("format", "json");
            data.Add("tel", "Enter_Mobile_Phone_Number");
            data.Add("country_code", "Enter_Country_Code");
            data.Add("mesg", "Hi, your OTP is <otp>.");
            string datastr = string.Join("&", data.Select(x => x.Key + "=" + System.Uri.EscapeDataString(x.Value)).ToArray());

            request = System.Net.WebRequest.Create("https://api.fraudlabspro.com/v1/verification/send?key=" + apiKey + "&" + datastr);

            request.Method = "GET";
            response = request.GetResponse();

            System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream());

            Page.Response.Write(reader.ReadToEnd());
        }
    }
}
import httplib
import urllib
import hashlib

p = { 'key': 'Enter_License_Key', 'format': 'json', 'tel': 'Enter_Mobile_Phone_Number', 'country_code': 'Enter_Country_Code', 'mesg': 'Hi, your OTP is <otp>.' }

conn = httplib.HTTPConnection("api.fraudlabspro.com")
conn.request("GET", "/v1/verification/send?" + urllib.urlencode(p))
res = conn.getresponse()
print res.read()