Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Authy Users


(warning)

Warning

As of November 2022, Twilio no longer provides support for Authy SMS/Voice-only customers. Customers who were also using Authy TOTP or Push prior to March 1, 2023 are still supported. The Authy API is now closed to new customers and will be fully deprecated in the future.

For new development, we encourage you to use the Verify v2 API.

Existing customers will not be impacted at this time until Authy API has reached End of Life. For more information about migration, see Migrating from Authy to Verify for SMS(link takes you to an external page).

Before you can secure a user with the Twilio Authy API, you need to create a user. The API requires you set an email, phone number and country code for each user.

When a user is first created, you will receive an authyid which you must then store with the user's profile in your own database. Do not lose this ID - you will use it every time you wish to authenticate a user!

Your users can change their phone number registered with the API without your knowledge by using the Authy Mobile(link takes you to an external page) or Desktop(link takes you to an external page) Application. They may also use the Authy.com phone change security review(link takes you to an external page). You can get webhooks of when this phone number changes via our Webhooks API.


Add a User

enabling-new-user page anchor

Create an Authy User

create-an-authy-user page anchor
Python
C#
Java
PHP
Ruby
curl

_17
# Download the helper library from https://github.com/twilio/authy-python
_17
from authy.api import AuthyApiClient
_17
_17
# Your API key from twilio.com/console/authy/applications
_17
# DANGER! This is insecure. See http://twil.io/secure
_17
authy_api = AuthyApiClient('api_key')
_17
_17
user = authy_api.users.create(
_17
email='new_user@email.com',
_17
phone='405-342-5699',
_17
country_code=57)
_17
_17
if user.ok():
_17
print user.id
_17
# user.id is the `authy_id` needed for future requests
_17
else:
_17
print user.errors()

Output

_10
{
_10
"message": "User created successfully.",
_10
"user": {
_10
"id": 123
_10
},
_10
"success": true
_10
}

A user may have multiple email addresses but only one phone is associated with each authy_id. Two separate API calls to register a user with the same device and different emails will return the same authy_id and store both emails for that user.


_10
POST https://api.authy.com/protected/{FORMAT}/users/new

Parameters

enabling-new-user-parameters page anchor
NameTypeDescription
user[email]String (required)More than one email can be stored per AuthyID, but only the initially created email will display in the Dashboard until it is removed. (📇 PII )
user[cellphone]String (required)Foreign key for the AuthyID (the AuthyID will be the primary key going forward). You can use dashes, periods, spaces or nothing to separate parts of the cell phone number. (📇 PII )
user[country_code]String (required)Numeric calling country code of the country Eg: 1 for the US. 91 for India. 52 for Mexico. See: Country code list dropdown(link takes you to an external page) (🏢 not PII )
send_install_link_via_smsBoolean (optional)Enable or disable an sms message with a link to download the Authy App. See Sending Install Link for detailed behavior. Default can be set from the console(link takes you to an external page). (🏢 not PII )
NameTypeDescription
userUseruser object contains the AuthyID of the created user. (🏢 not PII )
messageStringA message indicating the result of the operation. (🏢 not PII )
successBooleanTrue if the request was successful. (🏢 not PII )

Email and phone number must be valid for the request to succeed. An invalid request will produce the following error response:


_10
{
_10
"message": "User was not valid",
_10
"success": false,
_10
"errors": {
_10
"email": "is invalid",
_10
"message": "User was not valid"
_10
},
_10
"email": "is invalid",
_10
"error_code": "60027"
_10
}


[Optional] Allow user to set up other authenticator apps like Google Authenticator

optional-allow-user-to-set-up-other-authenticator-apps-like-google-authenticator page anchor

Enrolling a user (if you use the same phone number they used to sign up for the Authy App) automatically adds your application to their Authy App. You do not need to do any additional work to support TOTP tokens in the Authy app. To support additional Authenticator apps, like Google Authenticator, display a QR code to your users that contain a compatible TOTP secret. The API will return a link to a valid QR code. Instructions for generating that QR code are in the One-Time Passcodes reference documentation.


Add a user without providing email or phone number

add-a-user-without-providing-email-or-phone-number page anchor

You might not have the email and the phone number of the user, or if you do, you might not want to share it with Twilio for compliance reasons.

For those cases you can use our Authy App based onboarding flow. The end user must have the Authy App installed and registered, meaning the end user has already provided their phone number and email to us.

(information)

Info

This feature is only supported in the following versions of the Authy App. End users will have to update their mobile applications to the following versions:

  • iOS 22.4+
  • Android 23.8+

No-PII user registration JWT

no-pii-user-registration-jwt page anchor
json

_16
// Example Payload
_16
{
_16
"iss": "My Authy App",
_16
"iat": 1554395479,
_16
"exp": 1554395879,
_16
"context": {
_16
"custom_user_id": "3YgAIZklGPHmwpJfIC0PDy0E7l763OF3BHZo1p2xKhY",
_16
"authy_app_id": "1111111"
_16
}
_16
}
_16
_16
// Example Header
_16
{
_16
"alg": "HS256",
_16
"typ": "JWT"
_16
}

Output

_10
// JWT signed with key 'obK3KxxxxxxxxxxxxxxxxxxxxC'
_10
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJNeSBBdXRoeSBBcHAiLCJpYXQiOjE1NTQzOTU0NzksImV4cCI6MTU1NDM5NTg3OSwiY29udGV4dCI6eyJjdXN0b21fdXNlcl9pZCI6IjNZZ0FJWmtsR1BIbXdwSmZJQzBQRHkwRTdsNzYzT0YzQkhabzFwMnhLaFkiLCJhdXRoeV9hcHBfaWQiOiIxMTExMTExIn19.6pBOX0UL7jTmrudWGsJjT07GD8DlAP6uVlpHVZwJPTs"

First, create a JWT(link takes you to an external page). The token will be used to tie the end user's Authy ID to your application. The token must:

  1. Follow RFC 7519(link takes you to an external page) .
  2. Be signed with your application's Production API Key found in the Twilio console(link takes you to an external page) .
  3. Contain the following:

_10
{
_10
"iss": "{authy_app_name}",
_10
"iat": "{issue date in NumericDate}",
_10
"exp": "{expiration date in NumericDate}",
_10
"context": {
_10
"custom_user_id": "{custom_user_id}",
_10
"authy_app_id": "{app_authy_id}"
_10
}
_10
}

HS256 is the only algorithm supported.


_10
{
_10
"alg": "HS256",
_10
"typ": "JWT"
_10
}

issThe issuer param in the JWT payload MUST be the Application name, other value will raise an error in the validation.
iatThe date the JWT is issued. The difference between iat and exp cannot be more than 15 minutes.
expThe expiration time of the JWT. Used to prevent the JWT from being reused in the future. Maximum expiration time allowed is 15 minutes after the current time.
custom_user_idProvided by you, uniquely identifies a user. We are not expecting PII or any sensitive data, so please do not provide phone numbers, emails, SSN, or other identifying information . If you only have PII to identify your users we recommend to either: • Create a de-identified ID like a UUID • De-identify the PII by sending us the HMAC of the PII. Use URL safe Base64 encoding.
authy_app_idThe application id can be retrieved from console by going to Applications(link takes you to an external page) selecting the Application, and browsing to settings.

During development, you can validate your JWT using https://jwt.io/(link takes you to an external page). The example can be found here.(link takes you to an external page)

Next, create a QR string with the following format:


_10
authy://account?token={JWT}

Example No-PII user registration QR String

example-no-pii-user-registration-qr-string page anchor

_10
// JWT created using example payload above
_10
// signed with example API key 'obK3KxxxxxxxxxxxxxxxxxxxxC'
_10
_10
authy://account?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJNeSBBdXRoeSBBcHAiLCJpYXQiOjE1NTQzOTU0NzksImV4cCI6MTU1NDM5NTg3OSwiY29udGV4dCI6eyJjdXN0b21fdXNlcl9pZCI6IjNZZ0FJWmtsR1BIbXdwSmZJQzBQRHkwRTdsNzYzT0YzQkhabzFwMnhLaFkiLCJhdXRoeV9hcHBfaWQiOiIxMTExMTExIn19.6pBOX0UL7jTmrudWGsJjT07GD8DlAP6uVlpHVZwJPTs

Generate the QR Code from the transaction string

generate-the-qr-code-from-the-transaction-string page anchor

Note: we do not recommend storing the QR code since it can potentially leak sensitive data. Instead, we recommend:

  1. Sending the QR code as a base64 encoded image in your HTML
  2. Generating the QR code from your application with a library like github.com/skip2/go-qrcode(link takes you to an external page) . For testing, you can use an online generator like https://www.qr-code-generator.com/(link takes you to an external page) .

After the QR code is generated display it so your user can scan it with the Authy App.

(information)

Info

Keep in mind the QR codes expire, so don't display it for more time than the assigned expiration. The mobile device requires internet connectivity to complete the flow.

No-PII Registration: Get the User's Authy ID

no-pii-registration-get-the-users-authy-id page anchor

After the end user scans the QR code there are two ways to get the user's Authy ID (required for subsequent verification challenges).

  1. Poll registration status
  2. Subscribe to a registration webhook

1. Poll registration status

1-poll-registration-status page anchor

_10
GET https://api.authy.com/protected/{FORMAT}/registrations/status?custom_user_id={CUSTOM_USER_ID}

URL

NameDescription
FORMAT StringThe format to expect back from the REST API call. json or xml.
CUSTOM_USER_ID StringID provided by you to uniquely identify a user. (🏢 not PII )
NameDescription
status StringPossible responses: "pending", the user didn't scan the QR code yet. "expired", the received JWT was expired, it was either created with a short duration or the user took to long to scan. "completed", the user was successfully added. Make sure you keep your time in sync with an NTP server.
authy_id NumberUniquely identifies a user in the Authy API. Use this ID to call other Authy API endpoints.

Get No-PII User Registration Status

get-no-pii-user-registration-status page anchor
Python
curl

_16
# Download the helper library from https://github.com/twilio/authy-python
_16
from authy.api import AuthyApiClient
_16
_16
# Your API key from twilio.com/console/authy/applications
_16
# DANGER! This is insecure. See http://twil.io/secure
_16
authy_api = AuthyApiClient('api_key')
_16
_16
# NOTE: this feature only available in authy-python version 2.2.5+
_16
user = authy_api.users.registration_status(
_16
custom_user_id='3YgAIZklGPHmwpJfIC0PDy0E7l763OF3BHZo1p2xKhY')
_16
_16
if user.ok():
_16
print user.id
_16
# user.id is the `authy_id` needed for future requests
_16
else:
_16
print user.errors()

Output

_10
{
_10
"registration": {
_10
"status": "completed",
_10
"authy_id": 11111111
_10
},
_10
"success": true
_10
}

2. Subscribe to a registration webhook

2-subscribe-to-a-registration-webhook page anchor

You can subscribe to a webhook that will notify you in real time when the registration is successful or not.

The payload for event user_registration_completed:


_45
"method": "POST",
_45
"params": {
_45
"events": [
_45
{
_45
"event": "user_registration_completed",
_45
"time": "2019-04-09T22:26:10.503Z",
_45
"objects": {
_45
"app": {
_45
"b_custom_code_allowed": false,
_45
"b_custom_message_allowed": false,
_45
"s_account_sid": "AC5f123456eabfa99ee3441ef1e84ad528",
_45
"s_device_app": null,
_45
"s_errors": "",
_45
"s_id": "54321",
_45
"s_name": "Application Name",
_45
"s_type": null
_45
},
_45
"registration": {
_45
"s_app_id": 54321,
_45
"s_authy_id": 123456,
_45
"s_custom_id": "885de433faedf8475426f11baeee2424f88fd935"
_45
},
_45
"user": {
_45
"as_authy_ids": [
_45
"123456"
_45
],
_45
"b_banned": false,
_45
"s_authy_id": "123456",
_45
"s_country_code": "57",
_45
"s_errors": "",
_45
"s_locale": "en",
_45
"s_phone_number": "953a0fd8c9ec2a9f16a5ce58183cfa03"
_45
}
_45
},
_45
"request": {
_45
"id": "413fd53c-09af-43d6-8390-c346de8ccf0c",
_45
"ip": "IPv4_99a65f1a9e58fe49150aed5a188459b9b0b47157"
_45
},
_45
"public": true
_45
}
_45
],
_45
"webhook_id": "WH_50087ea9-9568-4839-9191-b43908a4abd4"
_45
},
_45
"url": "https://example.io/webhook"
_45
}

The payload for event user_registration_failed:


_33
{
_33
"method": "POST",
_33
"params": {
_33
"events": [
_33
{
_33
"event": "user_registration_failed",
_33
"time": "2019-04-09T22:26:10.503Z",
_33
"objects": {
_33
"app": {
_33
"b_custom_code_allowed": false,
_33
"b_custom_message_allowed": false,
_33
"s_account_sid": "AC5f586933eabfa99ee3441ef1e84ad528",
_33
"s_device_app": null,
_33
"s_errors": "",
_33
"s_id": "54321",
_33
"s_name": "Application Name",
_33
"s_type": null
_33
},
_33
"error": {
_33
"s_code": "60000"
_33
}
_33
},
_33
"request": {
_33
"id": "413fd53c-09af-43d6-8390-c346de8ccf0c",
_33
"ip": "IPv4_99a65f1a9e58fe49150aed5a188459b9b0b47157"
_33
},
_33
"public": true
_33
}
_33
],
_33
"webhook_id": "WH_50087ea9-9568-4839-9191-b43908a4abd4"
_33
},
_33
"url": "https://example.io/webhook"
_33
}


Python
C#
Java
PHP
Ruby
curl

_11
# Download the helper library from https://github.com/twilio/authy-python
_11
from authy.api import AuthyApiClient
_11
_11
# Your API key from twilio.com/console/authy/applications
_11
# DANGER! This is insecure. See http://twil.io/secure
_11
authy_api = AuthyApiClient('api_key')
_11
_11
status = authy_api.users.status(authy_id)
_11
_11
if status.ok():
_11
print(status.content)

Output

_56
{
_56
"status": {
_56
"authy_id": 123,
_56
"confirmed": true,
_56
"registered": true,
_56
"country_code": 1,
_56
"phone_number": "XXX-XXX-1111",
_56
"email": "user@domain.com",
_56
"devices": [
_56
"desktop",
_56
"iphone"
_56
],
_56
"has_hard_token": false,
_56
"account_disabled": false,
_56
"detailed_devices": [
_56
{
_56
"creation_date": 1540576334,
_56
"device_id": 123123,
_56
"device_type": "authy",
_56
"last_sync_date": 1540576768,
_56
"os_type": "desktop",
_56
"registration_device_id": null,
_56
"registration_method": "sms",
_56
"enabled_unlock_methods": "",
_56
"last_unlock_method_used": "unknown",
_56
"last_unlock_date": "unknown"
_56
},
_56
{
_56
"creation_date": 1540594738,
_56
"device_id": 456456,
_56
"device_type": "authy",
_56
"last_sync_date": 1540601752,
_56
"os_type": "ios",
_56
"registration_device_id": null,
_56
"registration_method": "sms",
_56
"enabled_unlock_methods": "pin, fingerprint",
_56
"last_unlock_method_used": "pin",
_56
"last_unlock_date": 1540601752
_56
}
_56
],
_56
"deleted_devices": [
_56
{
_56
"creation_date": 1540481558,
_56
"deletion_date": 1540481571,
_56
"device_id": 789789,
_56
"device_type": "authy",
_56
"last_sync_date": 1540481560,
_56
"os_type": "desktop",
_56
"registration_device_id": 123123,
_56
"registration_method": "push"
_56
}
_56
],
_56
},
_56
"message": "User status.",
_56
"success": true
_56
}

(warning)

Warning

The user status endpoint will only return a subset of the information for a given user, until that user has verified a token or approved/denied a OneTouch request.

Once a user is created and registered with your application, you can request information on that user from Twilio. Using the User status call, you will receive:

Response ParameterDescription
country_codeCountry code of the phone number.
phone_numberLast 4 digits of phone number (XXX-XXX-1234). None if the user was registered without providing phone number.
emailEmail provided when the user was added. None If user was added without email this field will be empty.
devicesList of devices, options are: android, android_tablet, ios, iphone, iphone_sdk, chrome, authy_chrome, sms, android_sdk
detailed_devicesList of devices including detailed registration information. See Detailed Devices below.
deleted_devicesUseful for determining a chain of trust. See Authy trust-chain for added devices(link takes you to an external page) for more information. Devices deleted before June 15th 2019 won't be returned.
multidevice_updated_atUnix timestamp of the last time the user changed the multidevice toggle status (true/false) on any device
mutidevice_enabledtrue if multidevice is enabled, false if multidevice is disabled.
registeredtrue when the Authy Mobile/Desktop App was registered.
confirmedtrue when the user has used a valid code before.

Trust-chain for Added Devices and detailed device response fields

trust-chain-for-added-devices-and-detailed-device-response-fields page anchor

Determine which end-user apps to trust for authentication. Our API records uniquely identifiable numbers for every installed app, as well as the sequence of app installs and the methods of installation. More information in our blog post: Authy trust-chain for added devices(link takes you to an external page).

Information returned in the detailed_device section of the user status endpoint includes:

  • registration_method : how the device was added ( sms , call , push ).
  • last_sync_date : Unix timestamp of last time the device was synced with Authy servers.
  • registration_device_id : device ID of the approving device if registration_method is push . New as of 2019-06-15, devices added before this date will be null . See Authy trust-chain for added devices(link takes you to an external page) for more information
  • enabled_unlock_methods: one or more of pin, faceid, fingerprint, password, none, unknown. Refers to the unlock method for the entire app, not just the settings page.

    • Only available for iOS app version 22.8+, Android app version 23.9.3+, and Desktop app version v1.8.0+
    • Not available for Chrome app
    • If an unlock method is enabled for iOS app, the linked Apple Watch app will still display non-transactional TOTP codes without requiring an unlock, but it will not allow a user to accept a push request.
  • last_unlock_method : enabled method last used.
  • last_unlock_date : Unix timestamp of last time the device was unlocked.

_10
GET https://api.authy.com/protected/{FORMAT}/users/{AUTHY_ID}/status

NameDescription
FORMAT StringThe format to expect back from the REST API call. json or xml.
AUTHY_ID IntegerThe Authy ID of the user. Create an Authy ID by registering a user. Note that password delivery may be upgraded to use the Authy application; see response parameters below.
NameDescription
user_ip StringIP of the user requesting to see the application details. Optional. (📇 PII )
NameDescription
status HashInformation about the user. (🏢 not PII )
message StringA message indicating the result of the operation. (🏢 not PII )
success BooleanTrue if the request was successful. (🏢 not PII )
Python
C#
Java
PHP
Ruby
curl

_11
# Download the helper library from https://github.com/twilio/authy-python
_11
from authy.api import AuthyApiClient
_11
_11
# Your API key from twilio.com/console/authy/applications
_11
# DANGER! This is insecure. See http://twil.io/secure
_11
authy_api = AuthyApiClient('api_key')
_11
_11
deleted = authy_api.users.delete(authy_id)
_11
_11
if deleted.ok():
_11
print deleted.content

Output

_10
{
_10
"message": "User removed from application",
_10
"success": true
_10
}

If you want to remove a user from your application you can use the Remove API. Note: removing a user will immediately disable token verifications.

Best practice is to remove a user if they disable Two-factor Authentication or remove an account with your App. If you accidentally remove a user, you can recover users through the Console - but we suggest that you instead go through your registration flow again.


_10
curl -X POST https://api.authy.com/protected/{FORMAT}/users/{USER ID}/remove -H "X-Authy-API-Key: {KEY}"

NameTypeDescription
user_ipString (optional)The ip requesting to remove the user (📇 PII )
NameTypeDescription
successBooleanTrue if the user was scheduled for deletion. (🏢 not PII )
messageStringA messaging indicating the result of the operation. (🏢 not PII )

Rate this page: