OTP for website login vs app login: what changes and what stays the same

OTP login works the same way on a website and in a mobile app: the user enters a mobile number, your server asks Fast2SMS to send a code, the user types it, and your server verifies it. The differences are in where the code is typed, how autofill works, and how you stop abuse. This page explains OTP for website login vs app login so you can plan both with one Smart OTP setup.

The flow is the same on both

  1. The user enters a mobile number on your site or in your app.
  2. The site or app calls your server, not Fast2SMS.
  3. Your server calls /dev/otp/send with the number and your OTP ID.
  4. The user types the code. The site or app sends it to your server.
  5. Your server calls /dev/otp/verify and logs the user in only on “OTP verified successfully”.
curl -X POST "https://www.fast2sms.com/dev/otp/verify" \
  -H "authorization: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"mobile":"9999999999","otp":"482913"}'
Never put your API key in website JavaScript or inside an Android or iPhone app. Anyone can read it there. Keep it on your server.

Website login vs app login: the differences

Website login App login
Code autofill Add autocomplete="one-time-code" to the code field so the phone keyboard can suggest the code Android apps can read the SMS with the SMS Retriever API (the app hash must be in your DLT template text)
WhatsApp OTP Copy code button. The user pastes the code. Copy code, or one-tap and zero-tap autofill for Android apps
Who can call your “send OTP” endpoint Anyone with a browser, including bots Mostly your app, but the endpoint can still be found and called
Abuse controls CAPTCHA, limits per IP and per session Limits per device and per number, app integrity checks
Staying logged in Session cookie, “remember this device” Long-lived token, so users rarely need a new OTP

Tips for website OTP login

  • Use one input for the code with inputmode="numeric" and autocomplete="one-time-code".
  • Show a resend countdown that matches the resend wait in OTP Settings.
  • Add a CAPTCHA or a similar check before “Send OTP”. Public forms are the main target of OTP abuse.
  • After a correct code, start a fresh session for the user.
<input type="text" name="otp" inputmode="numeric"
       autocomplete="one-time-code" maxlength="6">

Tips for app OTP login

  • For Android SMS autofill, add your app’s 11-character hash to the DLT OTP template text before you register it.
  • For WhatsApp one-tap or zero-tap, add the package name and signature hash to the WhatsApp Authentication template.
  • Keep users signed in with a token, and ask for a new OTP only on a new device or a sensitive action.

Set it up once for both

  1. Create one Smart OTP template

    Open Smart OTP, then OTP Template List, and add a template for SMS or WhatsApp. Each card shows the OTP ID your server uses. Web and app can share the same OTP ID, or you can make separate templates if the message text differs.

    OTP Template List with WhatsApp and SMS OTP template cards showing OTP ID, sender or number, template ID and fallback
    Each template has its own OTP ID.
  2. Set verify and resend limits

    In OTP Settings, set Max Verify OTP Limit (Per SMS) and SMS Resend / Time Limit (Seconds). These apply to every send from your account.

    OTP Settings with Max Verify OTP Limit 5 and SMS Resend Time Limit 30 seconds
    One set of limits for web and app.
  3. Lock the API key to your server

    In Account Settings, open API Security, add your server IPs under Whitelisted IPs and switch API Security on. Calls from other IPs are refused.

    API Security page with API Security switched on and three whitelisted IP addresses
    Only your servers can use the key.

Frequently asked questions

Can I use the same OTP API for my website and app?

Yes. Both call your server, and your server calls the same Smart OTP send and verify endpoints.

Can I tell which OTPs came from the app and which from the website?

Yes. Pass a label in udf1, udf2 or udf3 when you send. These values are stored with the OTP and sent in OTP webhooks.

Does SMS autofill work on websites?

Many phones suggest the code above the keyboard when the field uses autocomplete="one-time-code". The user taps the suggestion.

Which is safer, website or app OTP?

The OTP itself is the same. Safety depends on your server: keep the key there, limit requests and verify only on the server.

Should I send the OTP by WhatsApp for app users?

If your users use WhatsApp, yes, with an SMS fallback. Android apps can use one-tap or zero-tap autofill with WhatsApp Authentication templates.