Part of: Messaging Gateway

How Does SMS OTP Work, From App to Phone?

An SMS OTP is a one-time code your app makes and sends by text message. Your app passes the code to an SMS gateway. The gateway finds the customer's mobile operator and hands the message over. The operator delivers it to the phone and sends back a delivery report, so you know it arrived.

By Krishall Magage · Published · 6 min read

A customer opens your banking app and types the password. The app asks for a code. That code is an SMS OTP. If it arrives, the customer logs in or pays. If it does not arrive, the customer is stuck. Often they call your call centre, or they give up the payment.

This post explains, in plain words, how that code travels and where it can go wrong.

What is an SMS OTP?

An SMS OTP is a one-time password that your system sends to a customer’s phone by text message. The code works once, and only for a short time. It proves that the person who logs in or pays also holds the phone linked to the account.

Banks use SMS OTPs to:

  • confirm a login on a new device
  • approve a payment or a fund transfer
  • confirm a change of phone number, address or password
  • approve an online card payment

SMS works on almost every mobile phone. The customer needs no app and no mobile data, only a signal. That is why SMS is still the first channel most banks use for OTPs.

Delivery reports
TimeTypeToRouteStatus
10:41:02OTP+94 77 ••• 4821Operator B · link 2Delivered
10:41:03Alert+94 71 ••• 1180Operator A → BRerouted
10:41:03OTP+94 76 ••• 9035Operator C · link 1Delivered
10:41:05Campaign+94 70 ••• 2264Operator B · link 1Sent
Example Sprout MGW delivery report: one alert moved to another route when an operator link failed, and was delivered.

How does an SMS OTP get from your app to the phone?

An SMS OTP passes through four steps: your app, the SMS gateway, the mobile operator and the phone.

  1. Your app makes the code. Your banking system makes a random code and keeps a copy to check later. Then it asks for the message to be sent.
  2. The gateway takes the message. Your app sends the code and the phone number to an SMS gateway through an API. The gateway finds which mobile operator the customer uses.
  3. The operator carries it. The gateway hands the message to that operator’s SMS centre, over a link that uses SMPP. SMPP is the standard protocol that gateways and operators use to exchange text messages. The SMS centre sends the message to the phone when the phone is reachable.
  4. The phone receives it. The customer reads the code and types it in. Your system checks it against its copy. If the two match and the code has not expired, the login or payment goes through.

After the message reaches the phone, the operator sends a delivery report back to the gateway. The report says whether the message arrived.

What does the SMS gateway do in the middle?

The SMS gateway decides whether your OTP takes an open route or waits in a queue. It sits between your systems and the mobile operators. A good gateway does more than pass messages on:

  • It picks the route. It finds the customer’s operator and sends the message on the best route for that number.
  • It keeps OTPs ahead of bulk messages. OTPs need their own queue. If they share a queue with a marketing campaign, a code can wait behind the whole campaign.
  • It keeps to sending limits. Operators set limits on how fast you may send. The gateway keeps to those limits, so the operator does not reject your traffic.
  • It has a plan when a link fails. If a connection to an operator goes down, the gateway moves traffic to another connection or another operator.
  • It records each step. It logs when your app sent the message and what the operator reported back.

For more on the fourth point, read what happens when an operator fails.

Where can an SMS OTP go wrong?

An SMS OTP can fail at any of the four steps, and each failure is a customer who cannot log in or pay. The common causes are:

  • the phone is off, has no signal, or is abroad
  • the phone number on the account is old or wrong
  • the OTP waits behind bulk messages in the same queue
  • an operator connection is down, and the gateway has no other route
  • the code arrives after it has expired

Some of these causes sit with the customer. Many sit with the gateway, and you can fix them. Read why OTP SMS do not arrive, and how banks fix it for each cause and its fix.

How do you know an OTP was delivered?

You know an OTP was delivered when the operator’s delivery report comes back with a “delivered” status. Without that report, your team can only guess. With it, your call centre can answer a customer who says “my code never came”. Did your app send it? Did the operator accept it? Did the phone receive it?

Ask your provider to show every message, from the moment your app sends it to the operator’s delivery report. That record turns a complaint into a fact your team can act on.

How does Sprout MGW send SMS OTPs for banks?

Sprout Messaging Gateway (Sprout MGW) sends messages from a bank’s applications to its customers’ phones, over direct SMPP links to the mobile operators. It runs inside the bank’s own data centre. Only the bank’s own systems and staff can reach it.

  • OTPs and transaction alerts have their own priority queue, apart from campaigns, so a bulk campaign does not delay them.
  • It connects to several mobile operators, with several sessions to each one. If one connection fails, traffic moves to that operator’s other connections. If a whole operator fails, traffic moves to another operator.
  • If a send fails, it retries automatically on another operator.
  • It reports every message, from the moment the app sends it to the operator’s delivery report.
  • For international mobile numbers, it can send OTPs as WhatsApp authentication messages.

HNB, Seylan Bank, NDB and Cargills Bank run their OTPs and transaction messages on Sprout MGW. The four banks together have done so for more than five years, and HNB for more than twelve years.

See how it handles OTPs on the OTP SMS gateway page. Read about the whole product on the Sprout Messaging Gateway page, or see what Sprout does for banks.

What should you ask your SMS provider?

Ask your provider how it keeps your OTPs moving when something goes wrong. Five questions cover most of it:

  1. Do OTPs have their own queue, apart from campaigns?
  2. How many links do you have to each operator, and what happens when one fails?
  3. Do you retry a failed OTP on another route?
  4. Can we see the delivery report for each message?
  5. Can a code go on WhatsApp when SMS fails?

FAQs

What does OTP mean?

OTP means one-time password. It is a short code that works once, and only for a short time. It proves that the person who logs in or pays also holds the phone linked to the account.

Does the customer need internet to receive an SMS OTP?

No. An SMS OTP needs only a mobile signal. The customer needs no app and no mobile data.

What is SMPP?

SMPP is the standard protocol that SMS gateways and mobile operators use to exchange text messages. A gateway with direct SMPP links sends your messages straight to each operator.

Photo of Krishall Magage

About the author: Krishall Magage

Head of Sprout, hSenid Mobile

AI Product Leader & GTM Engineer. Bridging business and tech with full-stack skills.

Krishall Magage on LinkedIn