SMS Texter Logo

πŸ” One-Time Password (OTP) Service

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.

πŸ“€ Send OTP

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 message

Message 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.

βœ… Verify OTP

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 verified

Example of Node JS Code for Sending OTP

const 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);
  }
};

Example of Node JS Code for Verifying OTP

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);
  }
};