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:
- SMS (Short Message Service).
Prices can be found below:
Channel | Price |
---|---|
1NGN | |
SMS | 4NGN |
15NGN |
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:
length
: The length of the OTP string to be generated.customer
: Your Customer's information like their name, email and phone number.- sender: Name of the sender.
- medium; Channels to deliver OTP (email, sms, whatsapp).
- 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
}
Updated 16 minutes ago