SMS Textr offers a secure and reliable One Time Password (OTP) verification service via SMS, available exclusively for users in the USA and Canada. Our API allows your application to handle both stagesβsending the OTP and verifying it. 1 credit is deducted per OTP sent to a phone number. OTP Verification is done without any credit deductions.
You can initiate the OTP process by making a POST request to:
https://smstextr.web.app/api/sendotp
Required payload:
{ "to": "+1-123-456-7890", "apikey": "Your_API_Key" }
Optional parameters:
{ "to": "+1-123-456-7890", "org": "SMS Textr", "limit": "7", "apikey": "Your_API_Key" }
limit
: Number of minutes before OTP expires (between 2 and 10, default is 5)org
: Organization name to personalize the SMS messageMessage received by the user:
Your one-time verification code is 123456.
Message from [SMS Textr]. Your one-time verification code is 123456.
* Future updates will allow custom message templates as well as different digits of OTP ranging from 4 digits to 8 digits.
To verify the OTP submitted by your user, send a POST request to:
https://smstextr.web.app/api/verifyotp
Required payload:
{ "otp": "123456", "apikey": "Your_API_Key" }
Response:
"OTP verified"
β Success β
"OTP not found"
β Invalid or incorrect"OTP expired"
β Time limit exceeded"OTP already used"
β Previously verifiedconst axios = require('axios');
// Sending OTP example
const sendOtp = async () => {
const payload = {
to: "+1 123-456-7890",
org: "YourCompany", // Optional
limit: 5, // Optional
apikey: "Your_API_Key"
};
try {
const response = await axios.post('https://smstextr.web.app/api/sendotp', payload);
console.log('OTP sent successfully:', response.data);
} catch (error) {
console.error('Error sending OTP:', error.response ? error.response.data : error.message);
}
};
const axios = require('axios');
// Verifying OTP example
const verifyOtp = async () => {
const payload = {
otp: 123456,
apikey: "Your_API_Key"
};
try {
const response = await axios.post('https://smstextr.web.app/api/verifyotp', payload);
console.log('OTP verified successfully:', response.data);
} catch (error) {
console.error('Error verifying OTP:', error.response ? error.response.data : error.message);
}
};