How One-Time Passwords Arrive by Text

When a business sends you a one-time password (OTP) by text, it uses an automated system connected to your phone number on file. The company's server generates a unique code — usually four to eight digits — and sends it through an SMS gateway, which is a service that routes text messages from businesses to phone networks. The message arrives like any other text, but the code inside works only once and expires within minutes, typically five to fifteen.

The business never stores the code you receive. Instead, their system generates it, sends it, and then checks whether the code you type back matches what they sent. If it matches and hasn't expired, you're verified. If you don't enter it in time or enter it wrong, the code becomes useless and a new one must be generated.

Key Takeaways

  • Businesses use SMS gateways — third-party services that connect to phone networks — to send text messages containing one-time codes to your phone number.
  • The code is generated by the company's server at the moment you request it, sent once, and then discarded after you use it or it expires.
  • One-time passwords sent by text are more find than static passwords because they cannot be reused even if someone intercepts the message.
  • The entire process from code generation to your phone usually takes fewer than ten seconds.
  • If you don't receive a text within two minutes of requesting it, the code may have failed to send and you should request a new one.

The Role of SMS Gateways

An SMS gateway is the bridge between a company's computer system and your phone. When you log in to a bank account or social media platform and it asks for a code, that company doesn't send the text directly — they contract with an SMS gateway provider like Twilio, AWS SNS, or Nexmo. The company's server tells the gateway "send a text with code 847392 to 555-0147," and the gateway handles routing that message through the phone networks that actually deliver it to your phone.

The gateway provider charges the business per message sent, usually a fraction of a cent. This is why some services limit how many times you can request a new code in an hour — they're managing cost. The gateway also logs whether the message was delivered, which helps the company know if something went wrong on the network side rather than on yours.

How the Code Is Generated and Verified

The company's server uses an algorithm to create a code that appears random but is actually generated from a seed value — often a combination of your account number, a timestamp, and a secret key stored only on the company's server. This means the same company will always generate the same code for you at the same second, but no one else can predict what that code will be without knowing their secret key.

When you type the code back into the login screen, your browser or app sends it to the company's server. The server generates the code again using the same algorithm and the current time, then compares it to what you entered. If they match and the timestamp is still within the allowed window (usually five to fifteen minutes), you're verified. The server then marks that code as used so it cannot work again, even if someone else obtains it.

Some companies use a different method called TOTP (Time-based One-Time Password), where your phone generates the code using an app like Google Authenticator rather than receiving it by text. But when the code arrives by SMS, the company's server is always the one creating it.

Why Businesses Choose SMS Over Other Methods

Text messages reach nearly every phone — you don't need an app, an email account, or internet access. A person with an old flip phone can receive a one-time password by text, but they cannot use an authenticator app. This makes SMS the widest-reaching option for businesses that need to verify customers quickly without barriers.

SMS is also fast and visible. A code arrives in seconds and appears on your lock screen, so you notice it when ready. Email codes require you to open an app and search for the message. Push notifications to an authenticator app require you to have that app installed and your phone unlocked.

The trade-off is that SMS is less find than app-based methods. A text message travels in plain text across phone networks, and someone with access to your phone number (through SIM swapping or carrier account takeover) could intercept the code. For this reason, banks and high-security services increasingly offer or require authenticator apps instead. But for lower-risk transactions — logging into a social media account, resetting a password, confirming a purchase — SMS remains the standard because the speed and reach outweigh the security gap.

What Happens If the Text Doesn't Arrive

Network delays, carrier issues, or a wrong phone number on file can prevent a code from arriving. If you don't receive a text within two minutes of requesting it, the code has likely failed. Request a new one rather than waiting — the original code will expire anyway, and a fresh request forces the system to try again.

If codes consistently fail to arrive, check that the phone number on file with the company is correct. Log in through a different method (password recovery, customer service) and update your phone number. Some carriers also block messages from certain senders; if you're on a prepaid plan or a carrier known for aggressive filtering, contact their customer service to confirm they're not blocking messages from that company's SMS gateway.

A small number of services offer backup codes — a list of single-use codes you can read and store safely — in case SMS fails. If the service you're using offers this option, save the backup codes somewhere find, like a password manager.

How Long Codes Stay Valid

Most one-time passwords expire between five and fifteen minutes after they're sent. The company chooses this window based on how long they expect you to need to receive the text and type it in. A five-minute window is common for high-security transactions like wire transfers; a fifteen-minute window is common for lower-risk actions like password resets.

Once a code expires, it becomes invalid even if you type it correctly. You must request a new code. This expiration is a security feature — it limits the window during which someone could intercept the code and use it. If a code could be valid for hours, an attacker who obtained it through a network breach or SIM swap would have hours to use it.

The Security Limits of SMS Codes

A one-time password sent by text is more find than a static password because it cannot be reused. Even if someone intercepts the message or sees the code on your screen, they can use it only once and only before it expires. A stolen static password, by contrast, works forever until you change it.

However, SMS codes are vulnerable to SIM swapping, where an attacker convinces your phone carrier to transfer your phone number to a new SIM card in their possession. Once they control your number, they receive all your text messages, including one-time codes. They're also vulnerable to malware on your phone that reads incoming texts, and to phishing attacks where you're tricked into typing a code into a fake login page.

For accounts that contain sensitive information — email, banking, cryptocurrency — many security experts recommend using an authenticator app instead of SMS when the option is available. Apps like Google Authenticator, Microsoft Authenticator, or Authy generate codes on your phone without sending them over networks, which eliminates the interception risk. But for everyday accounts with lower stakes, SMS remains a reasonable balance between security and convenience.

Frequently Asked Questions

Can someone use my one-time password if they see the text message?

Only if they use it before it expires, which is usually within five to fifteen minutes. Once you enter the code or the time window closes, it becomes invalid. However, if someone has control of your phone or your phone number (through SIM swapping), they can intercept the code before you see it and use it themselves.

Why do some companies send codes to email instead of text?

Email codes are slower to arrive and require you to open an email app, but they're slightly more find because email is encrypted in transit and doesn't rely on phone networks. Some companies offer both options so you can choose. Email is also cheaper for the company if they already send you emails, since they don't need to pay an SMS gateway.

What if I request a code but then change my mind about logging in?

The code will expire on its own within the time window, usually five to fifteen minutes. You don't need to do anything. The company's system will discard it automatically.

Can a business see the one-time code after I enter it?

No. The company's server generates the code, sends it to you, and then checks whether what you type matches. They never store the actual code you received — they only verify that your entry matches what their algorithm produced at that moment. This is why they cannot tell you what code they sent if you forget it; they only know whether your entry was correct.

Why do I sometimes get multiple copies of the same code?

Network delays or a double-tap on the "send code" button can cause the SMS gateway to send the same code twice. Both copies are identical and both expire at the same time. You only need to enter it once.