A customer opens your app to reset a forgotten password. If the only thing standing between “forgot password” and “full account access” is an email address, you’ve built a system that’s exactly as secure as that email account, no more. Add a one-time password sent by SMS to the phone number on file, and the picture changes: an attacker now needs the account credentials and physical access to the victim’s phone. That second factor is what OTP and 2FA SMS actually buy you, and for businesses operating in Sri Lanka, where mobile penetration outpaces both email literacy and app-based authenticator adoption, SMS is usually the most reliable channel to deliver it on.
This guide covers what an OTP SMS gateway does, where 2FA over SMS fits (and where it doesn’t), the compliance context specific to Sri Lanka, and a working integration example.
What OTP SMS and 2FA SMS actually mean
OTP (one-time password) is a short numeric or alphanumeric code, usually 4-6 digits, generated for a single use and valid for a short window (typically a few minutes). It expires after use or after a timeout, whichever comes first.
2FA (two-factor authentication) is the broader security pattern: proving identity with two different categories of evidence, something you know (a password) and something you have (a phone that receives the OTP). SMS is one delivery mechanism for that second factor. Others include authenticator apps (TOTP) and hardware keys, but SMS remains the default for most consumer-facing Sri Lankan businesses because it needs no app install and works on every phone, feature phones included.
The two terms get used almost interchangeably in practice: “send an OTP” is the mechanism, “2FA” is the security goal it usually serves.
Where Sri Lankan businesses actually use this
Banking and fintech apps. Login verification, transaction confirmation above a threshold amount, and beneficiary addition are the three places OTP shows up most in Sri Lankan banking apps, largely because the Central Bank of Sri Lanka’s guidelines on electronic banking push institutions toward multi-factor verification for exactly these actions.
E-commerce checkout. A guest checkout flow that verifies the phone number by OTP before an order is confirmed cuts down on fake orders and typo’d delivery numbers, both of which are a real cost problem for local delivery-heavy retailers.
Account creation and password reset. Verifying a phone number at signup, and requiring an OTP (not just an email link) to reset a password, closes the most common account-takeover path: an attacker with access to an old or compromised email inbox.
Ride-hailing, food delivery, and marketplace apps. Phone verification at signup confirms the account belongs to a real, reachable person, which matters for trust between two strangers meeting for a delivery or a ride.
High-value transaction confirmation. Wire transfers, large withdrawals, and profile changes like updating a linked bank account are common trigger points for a step-up OTP challenge, even in a session that’s already logged in.
Government and utility services. Bill payment portals and citizen service apps increasingly require phone verification, both to confirm identity and to make sure notices about outages, dues, or appointments reach a working number.
Why SMS, specifically, in the Sri Lankan market
Three practical reasons SMS still wins over app-based 2FA for a large share of the Sri Lankan user base:
- Universal reach. Every mobile connection can receive SMS, smartphone or not, data plan or not. An authenticator app assumes a smartphone, storage for the app, and the user having actually installed it before the moment they need it, which is often not true for a first-time user resetting a password at 11pm.
- No pre-enrollment required. A TOTP app has to be set up before the security event happens. An OTP SMS just needs a phone number the business already has on file, so it works for the very first login attempt, not just the hundredth.
- Familiar user behavior. Sri Lankan consumers are already used to receiving SMS from banks, telcos, and government services. An OTP text doesn’t require any new mental model to understand or trust.
None of this means SMS OTP is flawless. SIM-swap fraud and SMS interception are real, if uncommon, attack vectors, which is why higher-risk actions (large transfers, adding a new payment method) are often better served by combining OTP with a secondary check, like a registered device or a short cooldown period, rather than treating SMS 2FA as an unconditional guarantee.
Compliance context to know before you launch
Sri Lanka doesn’t have a dedicated OTP-specific regulation, but a few overlapping obligations apply:
- Sender ID and content rules for commercial SMS sit under the Telecommunication Regulatory Commission (TRC), which governs what can be sent and from what sender identity. Transactional OTP messages are generally treated differently from bulk marketing SMS, but a registered, recognizable sender ID still matters for deliverability and trust.
- Financial-sector guidance. Banks and licensed finance companies operate under Central Bank of Sri Lanka directives on electronic banking and payment security, which is where the practical push toward multi-factor authentication for transactions above certain thresholds originates.
- Data protection. Sri Lanka’s Personal Data Protection Act applies to the phone numbers and verification records a business stores as part of an OTP flow, the same way it applies to any other personal data. Keep OTP logs (who was sent what, when, whether it was verified) only as long as you need them for fraud investigation, not indefinitely.
None of this is legal advice. Confirm current requirements for your specific sector with your compliance or legal counsel before launch, especially for anything customer-money-adjacent.
Setting up an OTP SMS flow: the pattern
Regardless of which gateway you use, a working OTP flow has the same shape:
- Generate and send. The gateway generates a random code and delivers it via SMS to the destination number, returning a reference ID you store against that verification attempt.
- User submits the code. The user reads the SMS and types the code into your app.
- Verify against the reference ID. Your backend calls the gateway’s verify endpoint with the code and reference ID, which checks the code against what was actually sent, whether it’s expired, and whether it’s already been used.
- Handle the result explicitly. A wrong code is a normal response, not a network error, check the “valid” field rather than assuming any 200 response means success.
- Rate-limit and expire. Cap send attempts per number per minute, and expire unused codes after a few minutes, to blunt both OTP flooding (spamming a number with codes as harassment) and brute-force guessing.
A working example: ShoutOUT Engage’s OTP API
ShoutOUT Engage’s OTP API handles steps 1 and 3 above directly. Sending a code:
curl -X POST https://backgroundservice.getshoutout.com/otpservice/send \
-H "Authorization: Apikey <your-api-key>" \
-H "Content-Type: application/json" \
-d '{
"source": "ShoutDEMO",
"destination": "94777123456",
"content": {
"sms": "Your verification code is {{code}}"
},
"transport": "sms"
}'
The {{code}} placeholder gets replaced with the generated code before sending. The response includes a referenceId, save it against the session or user record, since the verify step needs it.
Verifying what the user typed back:
curl -X POST https://backgroundservice.getshoutout.com/otpservice/verify \
-H "Authorization: Apikey <your-api-key>" \
-H "Content-Type: application/json" \
-d '{
"code": "12345",
"referenceId": "2d313c9a-6c6e-4c64-b9ad-2d4e0e3d9f7b"
}'
A wrong code returns a normal 200 with valid: false, not an error, so check that field explicitly rather than only handling the error case. If you’re building in Node.js, the @shoutoutlabs/engage-sdk package wraps both of these calls behind sendOtp and verifyOtp methods, and the full Developer Guides page has the endpoint reference for other stacks.
The underlying API enforces per-source-IP send limits and a global verify rate limit, worth building a short back-off into your retry logic rather than hammering the endpoint on a failed attempt, this also protects your own users against OTP flooding.
Practical checklist before you go live
- Keep the message short and code-forward. “Your verification code is 482913. Valid for 5 minutes.” reads faster than a message that opens with your company name and a marketing line before the code.
- Set a short expiry. 3-5 minutes is typical, long enough for a real user, short enough to limit the window a stolen code is useful.
- Use a recognizable sender ID. A code arriving from a name the user doesn’t recognize defeats the trust benefit OTP is supposed to add.
- Rate-limit by destination number, not just globally. A single phone number receiving twenty OTP requests in a minute is a signal to block, not a normal usage pattern.
- Log verification outcomes, not the codes themselves. You need to know an attempt happened and whether it succeeded, you don’t need to retain the plaintext code once it’s expired or used.
- Have a fallback. A number that’s temporarily unreachable (roaming, network outage) shouldn’t be a dead end. A retry option, or a secondary channel for account recovery, keeps a network hiccup from becoming a locked-out customer.
FAQ
What’s the difference between OTP and 2FA?
OTP is the one-time code itself. 2FA is the security pattern of combining two different proof types, typically a password plus that OTP. SMS is one way to deliver the OTP half of a 2FA flow; authenticator apps and hardware keys are others.
Is SMS OTP secure enough for banking transactions in Sri Lanka?
It’s the baseline most Sri Lankan financial institutions use today, driven partly by Central Bank of Sri Lanka guidance on multi-factor verification for electronic banking. For higher-value actions, many providers pair SMS OTP with additional checks (registered device, cooldown periods) rather than relying on SMS alone.
Do I need a special sender ID to send OTP messages in Sri Lanka?
Transactional OTP messages are generally treated differently from bulk marketing SMS, but a registered, recognizable sender ID still improves deliverability and reduces the chance a code gets mistaken for spam. Check current Telecommunication Regulatory Commission (TRC) requirements for your specific sender configuration.
How long should an OTP code stay valid?
3-5 minutes is the common range: long enough for a legitimate user to read the SMS and type the code, short enough to limit how useful an intercepted code is to anyone else.
What happens if a user enters the wrong OTP code?
A correctly-functioning gateway returns a normal successful response with a “valid: false” field, not an error. Build your app logic to check that field explicitly, and decide how many wrong attempts you’ll allow before requiring a new code.
Can OTP SMS work for users without a smartphone or data plan?
Yes, that’s one of its core advantages over app-based authenticators. SMS delivery only requires a working mobile connection, not a smartphone, an app install, or a data plan, which matters for reaching the full range of a Sri Lankan customer base.
Capterra
Software Advice
G2 Crowd
Gartner