Skip to contentSkip to navigationSkip to topbar

Verify TOTP

Created by: Twilio
  • Verify
  • JavaScript
  • Quick Deploy

This app will show you an example of how to build a time-based one-time passcode (TOTP) experience using your favorite authenticator app (like Google Authenticator or Authy) with the Twilio Verify API(link takes you to an external page).

TOTP is a more secure alternative to SMS 2FA and is a popular form of authentication for higher risk users (politicians, celebrities, journalists) or platforms (email, banking).

This sample uses function templates(link takes you to an external page) to quickly create and deploy serverless functions you can use to interface with the Twilio Verify API from your production application. The interface provided shows off an example onboarding flow.

How it works:

  1. User enters their username
  2. App generates a QR code
  3. User scans QR code in a compliant authenticator app
  4. User enters the correct token
  5. App verifies the token and the factor
  6. App verifies additional factors on an ongoing basis

For more information, check out:

Example TOTP accounts in Google Authenticator
Report this template(link takes you to an external page)
Quick Deploy to TwilioGet CodeUse Twilio CLI
Launch and test this app in a few minutes with Quick Deploy. No server needed. Quick Deploy will automatically configure and deploy this app using Twilio Functions. Learn more about Twilio Functions(link takes you to an external page)
  1. Log in to Twilio

    Access your Twilio account to get started.

    Checking for existing account...

  2. Verify Service SID

    SID of your Twilio Verify Service

  3. Click the button below to deploy your app

    This will use the details entered above to deploy your application to Twilio Functions.

    You will be able to view the application in the browser and edit it using the Functions UI.

Need some help?

We all do sometimes; code is hard. Get help now from our support team(link takes you to an external page), or lean on the wisdom of the crowd by browsing the Twilio tag(link takes you to an external page)on Stack Overflow.

Terms of servicePrivacy Policy

Copyright © 2025 Twilio Inc.