Short validity and one-time use
Use a short, clearly communicated validity period. A verified, replaced or expired code must never be accepted again.
SMS API / MFA and 2FA
Ask the user for a password, followed by a time-limited one-time code sent by your server through the SMS API. SMS is a broadly accessible added layer, but it is not phishing-resistant.
Server-side flow
The browser must never call the SMS API directly or receive the API key. Your backend owns the complete code lifecycle.
Verify the user’s password on the server. Do not start the SMS step for an unknown or incorrectly authenticated account.
Generate the code with a cryptographically secure random number generator. Store only a hash with the user, purpose, expiry and attempt count.
The backend sends the code with its protected API key. Use a short validity period, omit sensitive information from the message and bind the code to one sign-in.
Compare the submitted code on the server. Consume it after a successful check and invalidate it when its time or attempt limit has passed.
Security controls
Use a short, clearly communicated validity period. A verified, replaced or expired code must never be accepted again.
Limit incorrect code attempts per challenge. Lock or replace the challenge when the limit is reached.
Limit requests and resends per account, phone number, IP address and time window. Add progressive delays where appropriate.
Use cryptographically secure randomness, hash codes at rest, and never log codes, API keys or full phone numbers.
Use delivery-report webhooks for operations and troubleshooting. Delivered does not mean that the correct person read the SMS or authenticated.
Provide secure recovery routes and let users enrol a stronger method. Treat phone-number changes as sensitive actions.
Integration principle
The client asks your application to start an MFA challenge. The backend checks policy, generates the code, stores its hash and calls the SMS API. During verification, the backend checks the code, expiry and attempts before issuing a session.
Frequently asked questions
2FA uses exactly two factors. MFA can use two or more. A common SMS flow combines something the user knows, their password, with access to the phone number that receives a one-time code.
No. SMS codes can be exposed to phishing, social engineering and phone-number takeover. Passkeys and security keys provide phishing-resistant authentication, while authenticator apps are also a stronger choice for many use cases.
Use a short validity period suited to the user flow and delivery conditions, typically a few minutes. The code must also be consumed after successful verification and expire after too many incorrect attempts.
No. Call the API from your backend so the API key, code generation, storage, rate limiting and verification remain on the server.
No. A delivery report describes the message transport status. The user is verified only after your server accepts a valid, unused code for the correct challenge.
Get started
Read the documentation, try a payload locally and then create an account for your server-side integration.