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/otps

Body Params

length int32

The length of the OTP. Expected values are between 5 and 7.

customer object
customer-related information.
name string

The customer's fullname. Maxlength is 10 characters.

email string

The customer's email address.

phone string

The customer's phone number to be used in sending the OTP through WhatsApp and SMS.

sender string

The business name displayed in the OTP message. Maxlength is 10 characters.

send boolean

Set to true to send otp to customer.

medium string

The OTP delivery method. Expected values are sms, email and whatsapp.

Show optional parameters

Headers

Authorization 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/validate

Path Params

reference string

The reference returned from the create OTP response.

Body Params

otp int32

The one time password sent to the customer.

Headers

Authorization 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
}
{}
Loading...