Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OTP API

A simple open-source OTP generator library for developers looking for the quickest auth for email verification.

Usage

  1. Send request to generate OTP and set its time to live (ttl)
curl -X POST http://localhost:3000/generate-otp -H "Content-Type: application/json" -d '{ "email": "tester@gmail.com", "ttl": 300 }'

Result:

  • Success
{
	"otp": "673073",
	"email": "odiraoseelazaro@gmail.com",
	"mailed": true,
	"mail-response": {
		"id": "4c7b3587-cd12-42ee-af3c-0038fae3c0e6"
	}
}
  • Email Send Error Sample
{
	"otp": "884702",
	"email": "tester@gmail.com",
	"mailed": false,
	"error": { "statusCode": 401, "name": "validation_error", "message": "API key is invalid" }
}
  • Invalid request body Error Sample
{
	"otp": "148958",
	"mailed": false,
	"error": {
		"statusCode": 422,
		"name": "missing_required_field",
		"message": "Missing `to` field."
	}
}

  1. Send request to verify OTP
curl -X POST http://localhost:3000/verify-otp -H "Content-Type: application/json" -d '{ "email": "odiraoseelazaro@gmail.com", "otp": "123456" }'

Result:

  • Success (Correct OTP)
{ "valid": true, "message": "OTP is valid." }
  • Invalid (Wrong) OTP
{ "valid": false, "message": "Invalid or Expired OTP." }

Releases

Packages

Contributors

Languages