What is OTP? A Complete Guide for Developers and Users (2026)
OTP (One-Time Password) explained: how it works, where it is used, the difference between SMS OTP, TOTP, HOTP, and Voice OTP, and how to add OTP to your app safely.
StartMessaging Team
Engineering
If you have logged into a banking app, paid online, or signed up for an Indian e-commerce site recently, you have used an OTP. The four-, six-, or eight-digit code that landed on your phone? That is a One-Time Password — and it is the single most common second factor of authentication on the internet today.
This guide answers the question “what is OTP?” from both the user’s and the developer’s perspective. It covers what an OTP is, how it is generated and verified, the different types of OTPs you will encounter, where OTPs are used, their strengths and weaknesses, and how to add OTP-based verification to your own application.
OTP — Definition
An OTP (One-Time Password) is a short, automatically generated code that authenticates a user for a single transaction or session. The defining properties of an OTP are:
- Single use. Once consumed (or once it expires), it cannot be used again.
- Time-bound. Most OTPs expire within 5–10 minutes of being issued.
- Out-of-band delivery. The code is delivered through a different channel from the one being authenticated — usually SMS, email, voice call, or an authenticator app — so an attacker who has stolen one channel cannot complete the login alone.
Compare this to a regular password, which is reusable, has no built-in expiry, and lives entirely on the user’s side. OTPs trade the memorability of a password for stronger guarantees about who is on the other end of the session.
How OTP Works
At a high level, OTP-based verification has three actors: the user, your application, and an OTP service (such as StartMessaging). The flow is straightforward:
- User triggers the flow. They enter their phone number to log in or to confirm a payment.
- Your backend asks the OTP service to send a code. The service generates a 4–6 digit number, stores a hashed copy with an expiry timestamp, and dispatches it to the user’s phone via SMS, voice, or WhatsApp.
- The user types the code into your app.
- Your backend asks the OTP service to verify. The service compares the submitted code to the hash, checks expiry and attempt counts, and returns
{ verified: true }or an error. - You issue a session (JWT, cookie, etc.) to the authenticated user.
The exact crypto used to generate the code differs by OTP type (described in the next section), but the verification model is always the same: hash the input and compare in constant time, never expose the plaintext code on your servers, and never log it.
Types of OTP
The acronym “OTP” covers a small family of related schemes. The four you will encounter most often:
SMS OTP
A code sent over SMS. By far the most common in India because it works on every phone, requires no app install, and is well understood by end users. The trade-off is delivery cost (Rs 0.10–0.30 per message) and SIM-swap risk. See our deep dive on SMS OTP.
Voice OTP
Identical to SMS OTP except the code is read aloud over an automated voice call. Useful as a fallback when SMS is blocked or for visually impaired users. SMS vs Voice OTP comparison breaks down when each is appropriate.
TOTP (Time-Based OTP)
Generated by an authenticator app (Google Authenticator, Authy, 1Password) from a shared secret. The current 30-second time window is hashed with the secret to derive a 6-digit code. No SMS cost, no SIM-swap risk, works offline. Read our explainer on what TOTP is and how it works.
HOTP (Counter-Based OTP)
Like TOTP but instead of time, a monotonically increasing counter is hashed. Older hardware tokens (RSA SecurID-style) are the canonical example.
Flash-call / silent authentication
A newer pattern where the carrier verifies possession of a number without any user-facing code. Faster and cheaper but less compatible. When to choose silent authentication over OTP explores the trade-offs.
Where OTPs Are Used
OTPs show up almost any time a system needs to verify either identity or intent:
- Login & signup. Phone-number-based auth on consumer apps, password-less login flows, and second-factor checks after a password.
- Payments & high-value transactions. RBI-mandated additional-factor authentication on Indian card payments, UPI transactions over a threshold, mutual-fund redemptions, demat-account changes.
- Account-recovery flows. Reset password, change phone number, recover deleted account.
- Sensitive actions. Withdraw funds, change beneficiary, delete data, place a large order.
- Delivery handoff. Food-delivery driver hands over the order, courier delivers a Bluetooth lock, you pick up a parcel from a locker.
Why OTPs Matter for Security
A correctly implemented OTP defends against three of the most common attacks on user accounts:
- Credential stuffing. Even if an attacker has your email/password from an unrelated breach, they cannot log in without the OTP.
- Brute-forcing passwords. The OTP step throttles attempts and adds an unbypassable delay.
- Session theft on shared computers. The user must actively prove possession of their phone to extend or escalate a session.
OTP is not a complete defence — see the limitations section — but it raises the cost of attack by orders of magnitude. NIST, ISO/IEC 27001, India’s RBI, and SEBI all explicitly require OTP or an equivalent second factor for sensitive flows.
Limitations of OTP
It is important to be honest about what OTPs do not protect against:
- Phishing. A fake login page that proxies the OTP to the real site in real time can complete the login. TOTP and FIDO2 (passkeys) are stronger here.
- SIM swapping. An attacker socially engineers the telco into porting the victim’s number, then receives the OTPs. Read our guide on protecting users from SIM swap attacks.
- Bot-driven traffic pumping. Attackers trigger OTP sends at scale to inflate your SMS bill. How to defend against OTP traffic pumping covers the full playbook.
How to Add OTP to Your App
The fastest path is to call a managed OTP API rather than build the cryptography, retry logic, and DLT compliance yourself. With StartMessaging it is two HTTP calls:
// 1. Send
POST /otp/send { "phoneNumber": "+919876543210" }
// → { requestId, expiresAt, attemptsLeft }
// 2. Verify
POST /otp/verify { "requestId": "...", "otpCode": "482910" }
// → { verified: true }Concrete walk-throughs for the most popular stacks: Node.js, Python, PHP/Laravel, Django, Next.js App Router, and many more in our developer tutorial library.
OTP in the Indian Context (DLT, TRAI)
India is unique in that every entity sending bulk SMS — including OTPs — must register on the DLT (Distributed Ledger Technology) platform run by telecom operators, with pre-approved templates and a registered sender ID. This adds 1–4 weeks of compliance work and an ongoing template-approval process.
StartMessaging absorbs this entirely: we run the DLT compliance for you, so your team can ship OTP login the same day. We handle PE-ID registration, sender-ID approval, and TRAI message-scrubbing rules. See our DLT registration explainer if you want to understand what is happening on our side.
FAQ
Ready to ship phone-number-based auth? Sign up for a StartMessaging account and send your first OTP in five minutes — at Rs 0.25 per OTP, no DLT registration required.
Related Articles
Two-Factor Authentication (2FA) explained in plain English. The three factor categories, common 2FA methods, OTP vs TOTP vs passkeys, and how to add 2FA to your product.
TOTP — Time-Based One-Time Password — explained: how the RFC 6238 algorithm generates 6-digit codes, how it differs from SMS OTP, when to use it, and how to implement it.
A step-by-step explanation of what happens when you click "Send OTP": from generation and hashing on the server, to telecom routing in India, to verification and replay protection.
Ready to Send OTPs?
Integrate StartMessaging in 5 minutes. No DLT registration required.