Verification codes on iPhone: AutoFill OTP and 2FA codes and fixes
One-time codes on an iPhone usually arrive by text or email, and your iPhone can fill them in for you from Messages or Mail. The Passwords app can also generate codes. If codes do not come, check texts, filters, signal and your account details.

Photo by Julian on Unsplash
Many accounts now ask for a code when you sign in: a six digit number sent to your phone, called a one-time passcode, an OTP or a 2FA code. Your iPhone has several features that make these codes easier and safer to use, and a few reasons why they sometimes do not arrive. This guide explains how the codes work, how to use AutoFill, how to keep your inbox clean, what to do when a code does not show up and how to avoid scams. Menu names change between iOS versions, so use the closest match on your phone.
How do verification codes reach your iPhone?
- Text message: the most common way. A short number or a service sends a code to your phone number.
- Email: a code is sent to the address on the account.
- An authenticator app: an app generates a new code every 30 seconds without any message. This is safer than a text.
- A notification on a trusted device: Apple shows codes for your Apple Account on devices you already trust.
How do you AutoFill a code from Messages?
Fill in a code with one tap
- 1
Start signing in to the app or website.
Choose to get the code by text.
- 2
Wait for the text to arrive.
You do not need to open Messages.
- 3
Look above the keyboard.
The code appears with the label From Messages.
- 4
Tap it to fill it in, then continue.
If it does not appear, copy it from the notification.
AutoFill for texted codes has been in iOS for years, and recent versions also fill in codes that arrive in Apple Mail into Safari. Some reports say iOS 26 extends this to other messaging apps, but check on your own phone before you rely on it.
How do you delete verification codes automatically?
Old codes pile up in your messages and inbox. Your iPhone can clear a code after you use it. Open Settings, tap Passwords, unlock with Face ID or your passcode, open Password Options and look for the option under Verification Codes that deletes them after use. The name has changed between versions, and some older versions call it Clean Up Automatically. Turn it on, and used codes are removed from Messages and Mail. This also helps if you share a screen with someone.
Can the Passwords app generate codes?
Yes, on recent versions of iOS. The Passwords app can store a setup key for a site and then create the six digit codes for you, so you do not need a separate authenticator app. When you turn on two-factor authentication for a site, choose to use an authenticator app and look for an option to enter a setup key, then add it in Passwords. Third-party authenticator apps also work, and many people prefer one that backs up its codes. See how to set up two-factor authentication for the steps.
What about your Apple Account codes?
When you sign in to your Apple Account on a new device, Apple shows a six digit code on a device you already trust or sends it to a trusted phone number. You can also find a code in Settings › your name › Sign-In & Security › Get Verification Code on a trusted iPhone. Keep your trusted phone numbers current. If you cannot sign in, read an Apple Account that is locked.
Why is the code not arriving?
- Signal or Airplane Mode: you need service or Wi-Fi Calling to get texts.
- A wrong or old phone number on the account: check what number the service has on file.
- Filters and Focus: look in Messages for an Unknown Senders list, and check Focus settings.
- A blocked number: check Settings › Messages › Blocked Contacts.
- Carrier delays: short codes can arrive late. Wait a minute before you request a new one.
- Too many requests: services pause codes if you ask too often.
Our guide to an iPhone that is not receiving texts goes through every cause.
What if you changed your phone number or SIM?
If you changed carriers or moved to a new SIM or eSIM, update the phone number on your important accounts first, because codes are still sent to the old number. If you suddenly lose signal and are not getting any codes, think about a SIM swap scam, where someone takes over your number. Read SIM swap scams for warning signs.
How do you stay safe with one-time codes?
- Never read a code to someone who calls you, and never reply to a text with a code.
- Do not tap links in texts that say your account has a problem. Open the app yourself.
- Prefer an authenticator app or passkeys for important accounts.
- Keep backup codes for key accounts in a safe place.
- See how to tell if a text is a scam for common tricks.
What if you lose the phone that has your codes?
Use a backup code, a recovery key or another trusted device. For many services you can sign in with an email link or a recovery process, which may take a few days. That is why you should save backup codes when you turn on two-factor authentication. If the phone is stolen, see what to do if your phone is stolen.
Quick checklist
How do you find an old verification code?
Open Messages and use the search box at the top, then type the name of the service or the word code. Codes sent by text appear in the thread of the number that sent them. If you turned on automatic deleting, used codes may be gone, which is the point. Request a new code instead of digging for an old one, because codes expire quickly, often within a few minutes.
Can you use a verification code on a Mac or iPad?
Yes, if your devices are signed in to the same Apple Account, texts can reach your Mac and iPad through Text Message Forwarding, and AutoFill can offer the code in Safari. Turn it on under Settings › Messages › Text Message Forwarding on the iPhone. Many people also keep a separate authenticator app that works on every device.
Are passkeys better than codes?
For sites that support them, yes. A passkey lets you sign in with Face ID or Touch ID instead of a password and a code, and it cannot be phished the way a texted code can. Your iPhone stores passkeys in the Passwords app and iCloud Keychain. When a site offers to create a passkey, it is usually worth accepting. Keep a backup sign-in method in case you lose the phone.
Why do I get codes I did not ask for?
An unexpected code means someone entered your phone number or email on a sign-in page, often a mistake or a bot, and sometimes an attempt to get into your account. Do not share the code and do not tap links. Check your account, and change the password if you are worried. Turn on two-factor authentication using an authenticator app for important accounts.
What is the difference between a code and a passcode?
A verification code is a short number that proves you are the person signing in, usually valid for a few minutes. A passcode is the number or phrase that unlocks your iPhone. Never mix them up, and never give either to someone who asks you for it.
- AutoFill works for texted codes, and you can tap them above the keyboard.
- Used codes are deleted automatically if you want a tidy inbox.
- Important accounts use an authenticator app or the Passwords app.
- Your phone number is up to date on your accounts.
- You never share a code with anyone.
Frequently asked questions
How do I AutoFill a verification code on my iPhone?
When a site or app asks for a code and the text arrives, the code shows above the keyboard. Tap it to fill it in. Codes from Mail can also fill in Safari on recent versions.
How do I delete verification codes automatically?
Open Settings › Passwords, unlock, then Password Options, and turn on the option that deletes codes after use. The name of the option varies by iOS version.
Why am I not getting my verification code on my iPhone?
Common causes are no signal, a wrong phone number, a Focus or filter, a blocked sender or a carrier delay. Wait a minute, check Messages for unknown senders and request a new code.
Is it safe to share a verification code?
No. A verification code is for you only. Anyone who asks you to read it out or send it is trying to get into your account.
What to try next
Related guides

Change km to miles on iPhone
How to change km to miles on iPhone: set Measurement System for Apple Maps and Distance units in Google Maps. Also change temperature units.

Activate eSIM on iPhone
How to activate eSIM on iPhone with a QR code, manual details or your carrier's app. Steps for Verizon, AT&T and T-Mobile, plus fixes when activation fails.

Add a Home button to the iPhone screen
How to add home button to iPhone screen: turn on AssistiveTouch in Accessibility, tap Home, move the button and set shortcuts. Works on every iPhone, no repair.

Change a document to PDF on iPhone
How to change a document to PDF on iPhone: use Files and Markup, the Print trick, Pages, Word or Google Docs. Free, no extra app needed, for each file type.
More guides you may need

Recover data from a dead phone
How to recover data from a dead phone, starting with free options. Check cloud backups, try a charge and force restart, and know when a lab is worth paying.

Recover deleted photos on iPhone
Recover deleted photos on iPhone from Recently Deleted, iCloud.com or a backup, and learn your honest options after 30 days before paying for recovery software.