Developer Guide
Send SMS Verification
Send an SMS with verification code and a custom message for authentication purpose.
Before sending SMS verification, kindly check whether you have enough SMS credits or not. A 24 hours cooldown required if the SMS failed to deliver 10 times in a day. An API key is needed before using this REST API, thus sign up for an API key if you do not have one.
SIGN UP NOWRequest
POST https://api.fraudlabspro.com/v2/verification/send
Parameter | Type | Description |
---|---|---|
tel | string | (required) The recipient mobile phone number in E164 format which is a plus followed by just numbers with no spaces or parentheses.
For example, +12015550123 |
country_code | string | (optional) ISO 3166 country code for the recipient mobile phone number. If parameter is supplied, then some basic telephone number validation is done. |
key | string | (required) FraudLabs Pro API key. |
mesg | string | (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, |
otp_timeout | integer |
(optional) Timeout feature for OTP value in seconds. Default is 3600 seconds(1 hour). Min timeout is 15 seconds whereas max timeout is 86400 seconds(24 hours). |
format | string |
(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 | Type | Description |
---|---|---|
tran_id | string | Unique ID (20 characters) for this particular API call. |
credits_remaining | string | Number of remaining credits for sending SMS. |
Sandbox
Test Mobile Phone Number | Result |
---|---|
+11 | You can enter this bogus phone number to simulate a success SMS sending (No credit will be deducted). For the OTP value, you can enter 123456 to successfully complete the SMS verification. |
+11234 | Error message of Invalid phone number will be returned. |
Sample Codes
require_once 'lib/FraudLabsPro.php';
// Configures FraudLabs Pro API key
FraudLabsPro\Configuration::apiKey('YOUR_API_KEY');
// Send SMS Verification
FraudLabsPro\SMSVerification::sendsms([
'tel' => '+123456789',
'mesg' => 'Hi, your OTP is <otp>.',
'country_code' => 'US',
]);
import com.fraudlabspro.*;
import java.util.Hashtable;
public class FLP {
public static void main(String[] args) {
// Configures FraudLabs Pro API key
FraudLabsPro.APIKEY = "YOUR_API_KEY";
// Send SMS Verification API
SMSVerification sms = new SMSVerification();
// Sets SMS details for authentication purpose
Hashtable data = new Hashtable<>();
data.put("tel", "+123456789");
data.put("country_code", "US");
data.put("mesg", "Hi, your OTP is <otp>.");
String result = sms.sendSMS(data);
}
}
Imports FraudLabsPro.FraudLabsPro
Imports Newtonsoft.Json
Module Program
Sub Main()
'Configure FraudLabs Pro API KEY
FraudLabsProConfig.APIKey = "YOUR_API_KEY"
'Send SMS Verification API
Dim SendSMS As New SMSVerification
'Sets SMS details for authentication purpose
Dim SMSPara As New SMSVerificationPara With {
.Tel = "+123456789",
.CountryCode = "US",
.Message = "Hi, your OTP is <otp>."
}
Dim result = SendSMS.SendSMS(SMSPara)
Console.WriteLine("tran_id: " & result("tran_id").ToString)
Console.WriteLine("credits_remaining: " & result("credits_remaining").ToString)
End Sub
End Module
using FraudLabsPro.FraudLabsPro;
using System.Collections;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
// Configure FraudLabs Pro API KEY
FraudLabsProConfig.APIKey = "YOUR_API_KEY";
// Send SMS Verification API
SMSVerification SendSMS = new();
// Sets SMS details for authentication purpose
SMSVerificationPara SMSPara = new()
{
Tel = "+123456789",
CountryCode = "US",
Message = "Hi, your OTP is <otp>.",
OtpTimeout = 3600
};
JObject result = SendSMS.SendSMS(SMSPara);
Console.WriteLine("tran_id: " + result["tran_id"]);
Console.WriteLine("credits_remaining: " + result["credits_remaining"]);
# Import SDK to use the function
from libs.smsverification import SMSVerification
# Configure your API key
api_key = 'YOUR_API_KEY'
sms_verification_variables = {
'key': api_key,
'tel': '+123456789',
'country_code': 'US',
'mesg': 'Your OTP for the transaction is <otp>.',
}
print(SMSVerification.send_sms(sms_verification_variables))
curl https://api.fraudlabspro.com/v2/verification/send \
--header 'Content-Type: application/json' \
--data '{
"key": "Enter_License_Key",
"format": "json",
"country_code": "Enter_Country_Code",
"tel": "Enter_Mobile_Phone_Number",
"mesg": "Hi, your OTP is <otp>"
}'
require 'fraudlabspro_ruby'
FraudlabsproRuby::Configuration.api_key = 'YOUR_API_KEY'
result = FraudlabsproRuby::Api::SMSVerification.sendSMS(
tel: '+123456789',
mesg: 'Hi, your OTP is <otp>.',
country_code: 'US'
)
const {SMSVerification} = require("fraudlabspro-nodejs");
var sms = new SMSVerification('YOUR API KEY');
params = {
tel: '+123456789',
mesg: 'Hi, your OTP is .',
otp_timeout: 3600,
country_code: 'US',
};
sms.sendSMS(params, (err, data) => {
if (!err) {
console.log(data);
}
});