OTP

Learn how to generate and validate One-Time Passwords (OTPs) using Flutterwave’s APIs.

With Flutterwave's API, you can generate OTPs for authenticating customers within your application. We support three delivery channels:

  1. Email
  2. WhatsApp
  3. SMS (Short Message Service).

Prices can be found below:

ChannelPrice
Email1NGN
SMS4NGN
Whatsapp15NGN

📘

You need to have sufficient funds in your NGN wallet to use this API

Creating an OTP

Creating an OTP requires you to send a well-formatted request to our create-otp endpoint. Your request payload should contain the following parameters:

  1. length: The length of the OTP string to be generated.
  2. customer: Your Customer's information like their name, email and phone number.
  3. sender: Name of the sender.
  4. medium; Channels to deliver OTP (email, sms, whatsapp).
  5. expiry: OTP expiry time in minutes.
curl --location 'https://api.flutterwave.com/v3/otps' \
--header 'Authorization: Bearer FLWSECK_TEST-SANDBOXDEMOKEY-X' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{
   "length":4,
   "customer":{
      "name":"Test User",
      "email":"[email protected]",
      "phone":"2347123456789"
   },
   "sender":"Example Inc",
   "send":true,
   "medium":[
      "email",
      "sms",
      "whatsapp"
   ],
   "expiry":1
}'

{
   "status":"success",
   "message":"OTP generated successfully",
   "data":[
      {
         "medium":"email",
         "reference":"CF-BARTER-20250410104814154740924",
         "otp":"7280",
         "expiry":"2025-04-10T10:49:14.661242+00:00"
      },
      {
         "medium":"sms",
         "reference":"CF-BARTER-20250410104815143520271",
         "otp":"7280",
         "expiry":"2025-04-10T10:49:15.5087245+00:00"
      },
      {
         "medium":"whatsapp",
         "reference":"CF-BARTER-20250410104815991111700",
         "otp":"7280",
         "expiry":"2025-04-10T10:49:16.3906317+00:00"
      }
   ]
}

VALIDATING OTP

Once you generate an OTP, you need to validate it for security purposes. Use the transaction reference and OTP returned from the Create OTP response.

curl --location 'https://api.flutterwave.com/v3/otps/transaction_reference/validate' \
--header 'Authorization: Bearer FLWSECK_TEST-SANDBOXDEMOKEY-X' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
    "otp":1445
}'

Successful Response:

{ 
"status": "success", 
"message": "Otp Authenticated successfully", 
"data": null
 }