OTP & verification

How Long Should an OTP Be Valid?

The trade-off between security and delivery delays, recommended OTP lifetimes for login, signup, and payments, and how expiry interacts with attempt limits and resends.

Updated · 3 min read

Every one-time password needs an expiry. Too short, and users with a slow network or a distracted moment have to request another code. Too long, and a leaked code stays useful to an attacker. Here is how to choose.

The short answer

For SMS OTPs, 5 minutes is a good default. Many teams allow anything from 3 to 10 minutes, depending on the action and on how reliable delivery is in their markets.

Use caseTypical expiryWhy
Login or signup5 minutesBalances slow delivery and security
Payment or transaction approval2–5 minutesHigher risk; the user is actively waiting
Account recovery10–15 minutesUsers may switch devices or apps
Email magic links15–30 minutesEmail is slower and users switch apps

Why not 30 seconds?

A very short expiry looks secure, but it mostly hurts real users:

  • SMS delivery can take 10 to 30 seconds on a busy network, longer when roaming.
  • Users switch apps, look for their phone, or get distracted.
  • Every expired code becomes a resend, which costs money and increases fraud exposure.

Expiry is not your main defence. Attempt limits are.

Attempt limits matter more

A 6-digit code has a million possible values. If you allow only 5 wrong attempts per code, an attacker has a 5 in 1,000,000 chance of guessing it, whether the code is valid for 2 minutes or 10. So:

  • Limit attempts per code, around 5, then invalidate it.
  • Limit codes per number and per time window, so attackers cannot simply request new codes.
  • Bind the code to the phone number and purpose.

With these in place, the expiry window can be generous enough for real-world delivery.

How expiry and resend interact

  • When a user requests a new code, invalidate the previous one. Otherwise several valid codes exist at once.
  • Do not reset the attempt counter when a new code is requested within a short time, or attackers get fresh guesses with each resend.
  • Show the remaining time only if it helps; a simple "Codes expire after 5 minutes" usually suffices.

See designing the OTP resend flow for the user-facing side.

Match expiry to delivery reality

Look at your delivery data. If your 95th-percentile delivery time to a country is 40 seconds, a 1-minute expiry will fail many users there. If you serve markets with uneven network quality, a 5-minute default with good attempt limits is the safer choice. Our guide to OTP delivery in Egypt shows how to measure delivery time per network.

Say it in the message

Tell users how long the code lasts: "It expires in 5 minutes." It sets expectations and reduces support requests from people trying an old code.

For the complete checklist, read OTP best practices.