OTP
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 |
---|---|
NGN 1 | |
SMS | NGN 4 |
NGN 15 |
Wallet Funding
You need to have funds in your NGN balance to use this feature. If you don't, you can fund your NGN balance using any of your other currencies. Learn more about wallet funding here.
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
: The name of the sender.medium
: Supported delivery channels for the OTP i.e. via email, SMS or WhatsApp.expiry
: The expiry time of the OTP 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"
}
]
}
{
"status": "error",
"message": "Insufficient funds in merchant's NGN wallet",
"data": null
}
Validating an OTP string
After you generate an OTP string for your user, you need to validate it in your application. This validation helps you confirm the user's identity and access to the mobile number or email provided to you.
Before you validate your OTP, first retrieve the reference (data.reference
) returned in the OTP creation response. Pass this reference as a path variable in the validate endpoint and send your OTP as the request body.
curl --location 'https://api.flutterwave.com/v3/otps/:reference/validate' \
--header 'Authorization: Bearer FLWSECK_TEST-SANDBOXDEMOKEY-X' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"otp":123456
}'
{
"status":"success",
"message":"Otp Authenticated successfully",
"data":null
}
Updated 1 day ago