Overview
This guide will walk you through sending your first OTP and verifying it. You’ll learn the basic workflow that powers all OTP verification in your applications.
Step 1: Get Your API Key
Navigate to API Keys
Once logged in, go to the API Keys section in your dashboard.
Create a new API key
Click “Create API Key” and give it a descriptive name. Copy and save your key securely.
Store your API key securely! It provides access to your account and cannot be retrieved after creation.
Step 2: Send Your First OTP
Choose your preferred method:
cURL
Node.js (SDK)
Node.js (Fetch)
Python (SDK)
Python (Requests)
Go
curl -X POST https://app.easyotp.dev/api/v1/send \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"channel": "sms",
"recipient": "+1234567890",
"message": "Your verification code is: {code}",
"expires_in": 300
}'
import { EasyOTP } from '@easy-otp/sdk' ;
const client = new EasyOTP ({
apiKey: 'YOUR_API_KEY'
});
const result = await client . send ({
channel: 'sms' ,
recipient: '+1234567890' ,
message: 'Your verification code is: {code}' ,
expires_in: 300
});
console . log ( result );
const response = await fetch ( 'https://app.easyotp.dev/api/v1/send' , {
method: 'POST' ,
headers: {
'Authorization' : 'Bearer YOUR_API_KEY' ,
'Content-Type' : 'application/json' ,
},
body: JSON . stringify ({
channel: 'sms' ,
recipient: '+1234567890' ,
message: 'Your verification code is: {code}' ,
expires_in: 300
})
});
const data = await response . json ();
console . log ( data );
from easyotp import EasyOTP
client = EasyOTP( api_key = 'YOUR_API_KEY' )
result = client.send(
channel = 'sms' ,
recipient = '+1234567890' ,
message = 'Your verification code is: {code} ' ,
expires_in = 300
)
print (result)
import requests
response = requests.post(
'https://app.easyotp.dev/api/v1/send' ,
headers = {
'Authorization' : 'Bearer YOUR_API_KEY' ,
'Content-Type' : 'application/json' ,
},
json = {
'channel' : 'sms' ,
'recipient' : '+1234567890' ,
'message' : 'Your verification code is: {code} ' ,
'expires_in' : 300
}
)
data = response.json()
print (data)
package main
import (
" bytes "
" encoding/json "
" fmt "
" net/http "
)
func main () {
payload := map [ string ] interface {}{
"channel" : "sms" ,
"recipient" : "+1234567890" ,
"message" : "Your verification code is: {code}" ,
"expires_in" : 300 ,
}
jsonData , _ := json . Marshal ( payload )
req , _ := http . NewRequest ( "POST" , "https://app.easyotp.dev/api/v1/send" , bytes . NewBuffer ( jsonData ))
req . Header . Set ( "Authorization" , "Bearer YOUR_API_KEY" )
req . Header . Set ( "Content-Type" , "application/json" )
client := & http . Client {}
resp , _ := client . Do ( req )
defer resp . Body . Close ()
}
Response
{
"success" : true ,
"verification_id" : "11f951d5-32d1-4b49-bdda-7da248e2615c" ,
"expires_at" : "2024-01-01T12:05:00.000Z" ,
"request_id" : "7b4d6022-7260-4568-b6b7-29c366c47bbc"
}
Save the verification_id - you’ll need it to verify the code.
Step 3: Verify the Code
When your user enters the code they received, verify it:
cURL
Node.js (SDK)
Node.js (Fetch)
Python (SDK)
Python (Requests)
Go
curl -X POST https://app.easyotp.dev/api/v1/verify \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"verification_id": "11f951d5-32d1-4b49-bdda-7da248e2615c",
"code": "123456"
}'
import { EasyOTP } from '@easy-otp/sdk' ;
const client = new EasyOTP ({
apiKey: 'YOUR_API_KEY'
});
const result = await client . verify ({
verification_id: '11f951d5-32d1-4b49-bdda-7da248e2615c' ,
code: '123456'
});
console . log ( result );
const response = await fetch ( 'https://app.easyotp.dev/api/v1/verify' , {
method: 'POST' ,
headers: {
'Authorization' : 'Bearer YOUR_API_KEY' ,
'Content-Type' : 'application/json' ,
},
body: JSON . stringify ({
verification_id: '11f951d5-32d1-4b49-bdda-7da248e2615c' ,
code: '123456'
})
});
const data = await response . json ();
console . log ( data );
from easyotp import EasyOTP
client = EasyOTP( api_key = 'YOUR_API_KEY' )
result = client.verify(
verification_id = '11f951d5-32d1-4b49-bdda-7da248e2615c' ,
code = '123456'
)
print (result)
import requests
response = requests.post(
'https://app.easyotp.dev/api/v1/verify' ,
headers = {
'Authorization' : 'Bearer YOUR_API_KEY' ,
'Content-Type' : 'application/json' ,
},
json = {
'verification_id' : '11f951d5-32d1-4b49-bdda-7da248e2615c' ,
'code' : '123456'
}
)
data = response.json()
print (data)
package main
import (
" bytes "
" encoding/json "
" net/http "
)
func main () {
payload := map [ string ] interface {}{
"verification_id" : "11f951d5-32d1-4b49-bdda-7da248e2615c" ,
"code" : "123456" ,
}
jsonData , _ := json . Marshal ( payload )
req , _ := http . NewRequest ( "POST" , "https://app.easyotp.dev/api/v1/verify" , bytes . NewBuffer ( jsonData ))
req . Header . Set ( "Authorization" , "Bearer YOUR_API_KEY" )
req . Header . Set ( "Content-Type" , "application/json" )
client := & http . Client {}
resp , _ := client . Do ( req )
defer resp . Body . Close ()
}
Response
{
"success" : true ,
"verified" : true ,
"message" : "Code verified successfully" ,
"request_id" : "7b4d6022-7260-4568-b6b7-29c366c47bbc"
}
Understanding Channels
EasyOTP supports three channels:
SMS Send codes via text message. Recipient must be a valid E.164 phone number (e.g., +1234567890).
Email Send codes via email. Supports custom subject lines for better branding.
Voice Deliver codes via automated voice call. Great for accessibility and international users.
Next Steps
JavaScript SDK Use our official JavaScript SDK
Python SDK Use our official Python SDK
API Reference Explore the complete API documentation
View Logs Monitor your API usage and debug issues
Manage Credits Add credits to your account
Get Support Need help? Contact our support team
Best Practices
Store verification IDs securely
Keep verification IDs associated with user sessions server-side. Never expose them in URLs or client-side code.
Set appropriate expiration times
Use shorter expiration times (2-5 minutes) for sensitive operations. Longer times (10-15 minutes) are acceptable for email verification.
Include your brand name and make messages clear. Good: “Your Acme Corp verification code is: ”. Bad: "".
Always check the response status and handle errors. Provide clear feedback to users when codes expire or are invalid.
Limit how many codes users can request in a time period to prevent abuse and reduce costs.