OTPs
Create and manage one time passwords (OTPs) for your applications.
Create an OTP
Generate a one time password (OTP) for your users.
post
https://api.flutterwave.com/v3/otpsBody Params
int32
The length of the OTP. Expected values are between 5 and 7.
object
customer-related information.
string
The customer's fullname. Maxlength is 10 characters.
string
The customer's email address.
string
The customer's phone number to be used in sending the OTP through WhatsApp and SMS.
string
The business name displayed in the OTP message. Maxlength is 10 characters.
boolean
Set to true to send otp to customer.
string
The OTP delivery method. Expected values are sms, email and whatsapp.
Show optional parameters
Headers
string
Pass your secret key as a bearer token in the request header to authorize this call
var axios = require('axios');
var data = JSON.stringify({
"length": 7,
"customer": {
"name": "Flutterwave Developers",
"email": "developers@flutterwavego.com",
"phone": "2348000000000"
},
"sender": "Flutterwave Inc.",
"send": true,
"medium": [
"email",
"whatsapp"
],
"expiry": 5
});
var config = {
method: 'post',
url: 'https://api.flutterwave.com/v3/otps',
headers: {
'Authorization': 'Bearer FLWSECK_TEST-SANDBOXDEMOKEY-X',
'Content-Type': 'application/json'
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.flutterwave.com/v3/otps',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"length": 7,
"customer": { "name": "Flutterwave Developers", "email": "developers@flutterwavego.com", "phone": "2348000000000" },
"sender": "Flutterwave Inc.",
"send": true,
"medium": ["email", "whatsapp"],
"expiry": 5
}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer FLWSECK_TEST-SANDBOXDEMOKEY-X',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
require "uri"
require "json"
require "net/http"
url = URI("https://api.flutterwave.com/v3/otps")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer FLWSECK_TEST-SANDBOXDEMOKEY-X"
request["Content-Type"] = "application/json"
request.body = JSON.dump({
"length": 7,
"customer": {
"name": "Flutterwave Developers",
"email": "developers@flutterwavego.com",
"phone": "2348000000000"
},
"sender": "Flutterwave Inc",
"send": true,
"medium": [
"email",
"whatsapp"
],
"expiry": 5
})
response = https.request(request)
puts response.read_body
{
"status": "success",
"message": "OTP generated successfully",
"data": [
{
"medium": "email",
"reference": "CF-BARTER-20200616015533756952",
"otp": "5378980",
"expiry": "2020-06-16T02:00:33.4426637+00:00"
},
{
"medium": "whatsapp",
"reference": "CF-BARTER-20200616015533500912",
"otp": "5378980",
"expiry": "2020-06-16T02:00:33.6144889+00:00"
}
]
}
{}
Validate an OTP
Validate OTPs in your applications.
post
https://api.flutterwave.com/v3/otps/:reference/validatePath Params
string
The reference returned from the create OTP response.
Body Params
int32
The one time password sent to the customer.
Headers
string
Pass your secret key as a bearer token in the request header to authorize this call
var axios = require('axios');
var data = JSON.stringify({
"otp": "481208"
});
var config = {
method: 'post',
url: 'https://api.flutterwave.com/v3/otps/CF-BARTER-20190420022611377491/validate',
headers: {
'Authorization': 'Bearer FLWSECK_TEST-SANDBOXDEMOKEY-X',
'Content-Type': 'application/json'
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.flutterwave.com/v3/otps/CF-BARTER-20190420022611377491/validate',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"otp": "481208"
}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer FLWSECK_TEST-SANDBOXDEMOKEY-X',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
require "uri"
require "json"
require "net/http"
url = URI("https://api.flutterwave.com/v3/otps/CF-BARTER-20190420022611377491/validate")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer FLWSECK_TEST-SANDBOXDEMOKEY-X"
request["Content-Type"] = "application/json"
request.body = JSON.dump({
"otp": "481208"
})
response = https.request(request)
puts response.read_body
{
"status": "success",
"message": "Otp Authenticated successfully",
"data": null
}
{}