Skip to main content
Real-world integration examples showing how to use Telnyx Verify in common application flows. Each example includes complete server-side code, error handling, and frontend UX guidance.

Login verification

Add phone-based 2FA to your login flow. After the user enters their password, send a verification code to their registered phone number before granting access.

Sequence diagram

Server implementation

Frontend UX guidance

  • Use a single input field or separate digit boxes (4–6 boxes depending on code length)
  • Auto-focus the input when the 2FA screen appears
  • Auto-submit when the full code length is entered (no submit button needed)
  • Accept numeric input only — set inputmode="numeric" and pattern="[0-9]*"
  • Enable paste support for users copying from SMS notifications
  • Show a countdown timer (e.g., “Code expires in 4:32”)
  • Disable the Resend button for 30 seconds after sending to prevent rapid resends
  • After timeout, show a clear “Code expired” message with a Resend button
  • Wrong code: “Invalid code. X attempts remaining.” Keep the input active for retry.
  • Expired code: “Code expired. Click Resend to get a new code.”
  • Max attempts: “Too many attempts. Please start the login process again.”
  • Network error: “Could not verify. Check your connection and try again.”

Registration verification

Verify phone number ownership during account creation. This confirms the user has access to the phone number before your application creates the account.

Sequence diagram

Server implementation


Payment verification

Add step-up authentication for high-value transactions. When a user initiates a payment above a threshold, require phone verification before processing.

Sequence diagram

Server implementation

Security considerations for payment verification:
  • Always verify the payment amount hasn’t been tampered with between initiation and confirmation
  • Set short timeouts (5 minutes) for payment verification codes
  • Log all verification attempts for audit purposes
  • Never expose payment details in verification messages — the SMS should only contain the code

Common patterns across all flows

Rate limiting resend requests

Prevent abuse by limiting how often users can request new codes:

Handling user cancellation

Always clean up pending verifications when users navigate away:

Webhook-driven verification

Instead of polling, use webhooks for real-time verification status updates:
For more on webhooks, see Receiving Webhooks for Telnyx Verify.

Next steps

Verify Quickstart

Get started with the Verify API basics

Security Best Practices

Protect against SMS pumping and fraud

Rate Limiting & Fraud Prevention

Implement rate limiting and anomaly detection

Custom Templates

Create branded verification messages