Developer Guide
- Send SMS Verification
- Get Verification Result
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. A 24 hours cooldown required if the SMS failed to deliver 10 times in a day.
POST https://api.fraudlabspro.com/v1/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, +123456789 |
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.
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. |
error | string |
Blank if there is no error otherwise it will contain one of the errors below:
|
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. |
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 .");
String result = sms.sendSMS(data);
}
}
Imports FraudLabsPro.FraudLabsPro
Public Class WebForm4
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Configure FraudLabs Pro API KEY
FraudLabsProConfig.APIKey = "YOUR_API_KEY"
'Send SMS Verification API
Dim Send_SMS_Verification As New SMSVerification
'Sets SMS details for authentication purpose
Dim SMS_Details As New SMSVerificationPara
SMS_Details.Tel = "+123456789"
SMS_Details.CountryCode = "US"
SMS_Details.Message = "Hi, your OTP is <otp>."
Dim result = Send_SMS_Verification.SendSMS(SMS_Details)
Response.Write("TransactionID: " + result.TransactionID + "</br>")
Response.Write("CreditsRemaining: " + result.CreditsRemaining + "</br>")
Response.Write("Error: " + result.Error + "</br>")
End Sub
End Class
using FraudLabsPro.FraudLabsPro;
public class WebForm4 : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
// Configure FraudLabs Pro API KEY
FraudLabsProConfig.APIKey = "YOUR_API_KEY";
// Send SMS Verification API
SMSVerification Send_SMS_Verification = new SMSVerification();
// Sets SMS details for authentication purpose
SMSVerificationPara SMS_Details = new SMSVerificationPara();
SMS_Details.Tel = "+123456789";
SMS_Details.CountryCode = "US";
SMS_Details.Message = "Hi, your OTP is <otp>.";
var result = Send_SMS_Verification.SendSMS(SMS_Details);
Response.Write("TransactionID: " + result.TransactionID + "</br>");
Response.Write("CreditsRemaining: " + result.CreditsRemaining + "</br>");
Response.Write("Error: " + result.Error + "</br>");
}
}
# 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/v1/verification/send -X POST \
-d "key=Enter_License_Key" \
-d "format=json" \
-d "country_code=Enter_Country_Code" \
-d "tel=Enter_Mobile_Phone_Number" \
-d "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);
}
});
Country Code (alpha-2) | Country Name |
---|---|
AD | Andorra |
AE | United Arab Emirates |
AF | Afghanistan |
AG | Antigua and Barbuda |
AI | Anguilla |
AL | Albania |
AM | Armenia |
AO | Angola |
AR | Argentina |
AS | American Samoa |
AT | Austria |
AU | Australia |
AW | Aruba |
AZ | Azerbaijan |
BA | Bosnia and Herzegovina |
BB | Barbados |
BD | Bangladesh |
BE | Belgium |
BF | Burkina Faso |
BG | Bulgaria |
BH | Bahrain |
BI | Burundi |
BJ | Benin |
BM | Bermuda |
BN | Brunei Darussalam |
BO | Bolivia (Plurinational State of) |
BR | Brazil |
BS | Bahamas |
BT | Bhutan |
BW | Botswana |
BY | Belarus |
BZ | Belize |
CA | Canada |
CD | Congo (Democratic Republic of the) |
CF | Central African Republic |
CG | Congo |
CH | Switzerland |
CI | Cote d'Ivoire |
CK | Cook Islands |
CL | Chile |
CM | Cameroon |
CN | China |
CO | Colombia |
CR | Costa Rica |
CU | Cuba |
CV | Cabo Verde |
CY | Cyprus |
CZ | Czechia |
DE | Germany |
DJ | Djibouti |
DK | Denmark |
DM | Dominica |
DO | Dominican Republic |
DZ | Algeria |
EC | Ecuador |
EE | Estonia |
EG | Egypt |
ES | Spain |
ET | Ethiopia |
FI | Finland |
FJ | Fiji |
FK | Falkland Islands (Malvinas) |
FM | Micronesia (Federated States of) |
FO | Faroe Islands |
FR | France |
GA | Gabon |
GB | United Kingdom of Great Britain and Northern Ireland |
GD | Grenada |
GE | Georgia |
GF | French Guiana |
GH | Ghana |
GI | Gibraltar |
GL | Greenland |
GM | Gambia |
GN | Guinea |
GP | Guadeloupe |
GQ | Equatorial Guinea |
GR | Greece |
GT | Guatemala |
GU | Guam |
GW | Guinea-Bissau |
GY | Guyana |
HK | Hong Kong |
HN | Honduras |
HR | Croatia |
HT | Haiti |
HU | Hungary |
ID | Indonesia |
IE | Ireland |
IL | Israel |
IN | India |
IQ | Iraq |
IR | Iran (Islamic Republic of) |
IS | Iceland |
IT | Italy |
JM | Jamaica |
JO | Jordan |
JP | Japan |
KE | Kenya |
KG | Kyrgyzstan |
KH | Cambodia |
KI | Kiribati |
KM | Comoros |
KN | Saint Kitts and Nevis |
KR | Korea (Republic of) |
KW | Kuwait |
KY | Cayman Islands |
KZ | Kazakhstan |
LA | Lao People's Democratic Republic |
LB | Lebanon |
LC | Saint Lucia |
LI | Liechtenstein |
LK | Sri Lanka |
LR | Liberia |
LS | Lesotho |
LT | Lithuania |
LU | Luxembourg |
LV | Latvia |
LY | Libya |
MA | Morocco |
MC | Monaco |
MD | Moldova (Republic of) |
ME | Montenegro |
MG | Madagascar |
MK | North Macedonia |
ML | Mali |
MM | Myanmar |
MN | Mongolia |
MO | Macao |
MP | Northern Mariana Islands |
MQ | Martinique |
MR | Mauritania |
MS | Montserrat |
MT | Malta |
MU | Mauritius |
MV | Maldives |
MW | Malawi |
MX | Mexico |
MY | Malaysia |
MZ | Mozambique |
NA | Namibia |
NC | New Caledonia |
NE | Niger |
NF | Norfolk Island |
NG | Nigeria |
NI | Nicaragua |
NL | Netherlands |
NO | Norway |
NP | Nepal |
NU | Niue |
NZ | New Zealand |
OM | Oman |
PA | Panama |
PE | Peru |
PF | French Polynesia |
PG | Papua New Guinea |
PH | Philippines |
PK | Pakistan |
PL | Poland |
PR | Puerto Rico |
PS | Palestine, State of |
PT | Portugal |
PW | Palau |
PY | Paraguay |
QA | Qatar |
RE | Reunion/Mayotte |
RO | Romania |
RS | Serbia |
RW | Rwanda |
SA | Saudi Arabia |
SB | Solomon Islands |
SC | Seychelles |
SD | Sudan |
SE | Sweden |
SG | Singapore |
SI | Slovenia |
SK | Slovakia |
SL | Sierra Leone |
SM | San Marino |
SN | Senegal |
SO | Somalia |
SR | Suriname |
SS | South Sudan |
ST | Sao Tome and Principe |
SV | El Salvador |
SY | Syrian Arab Republic |
SZ | Eswatini |
TC | Turks and Caicos Islands |
TD | Chad |
TG | Togo |
TH | Thailand |
TJ | Tajikistan |
TL | Timor-Leste |
TM | Turkmenistan |
TN | Tunisia |
TO | Tonga |
TR | Turkey |
TT | Trinidad and Tobago |
TV | Tuvalu |
TW | Taiwan (Province of China) |
TZ | Tanzania, United Republic of |
UA | Ukraine |
UG | Uganda |
US | United States of America |
UY | Uruguay |
UZ | Uzbekistan |
VC | Saint Vincent and the Grenadines |
VE | Venezuela (Bolivarian Republic of) |
VG | Virgin Islands (British) |
VI | Virgin Islands (U.S.) |
VN | Viet Nam |
VU | Vanuatu |
WS | Samoa |
YE | Yemen |
ZA | South Africa |
ZM | Zambia |
ZW | Zimbabwe |