SDKs overview
Twilio Authy offers a suite of Software Development Kits (SDKs) designed to facilitate the integration of multi-factor authentication (MFA) capabilities into various applications and services. These SDKs abstract the underlying REST API, providing language-specific interfaces and helper functions that streamline common authentication workflows, such as user registration, token verification, and managing one-time passwords (OTPs) and push authentications Twilio Authy API reference. By utilizing an SDK, developers can reduce the boilerplate code required to interact directly with the Authy API, improving development velocity and reducing potential error points.
The available SDKs support popular programming languages, ensuring broad compatibility with existing tech stacks. Each SDK is maintained by Twilio, providing official support and adherence to the latest API versions and security practices. The primary goal of these SDKs is to enable developers to add a robust layer of security to user accounts without requiring deep expertise in cryptographic protocols or secure communication methods Twilio Authy homepage. The SDKs generally provide methods for:
- Registering users for 2FA.
- Sending verification tokens via SMS or voice.
- Verifying OTPs received from the Authy mobile app or generated via SMS/voice.
- Managing Authy OneTouch push authentication requests.
- Checking the status of verification requests.
These tools are crucial for implementing security measures like those recommended by organizations such as the FIDO Alliance for strong authentication FIDO Alliance standards.
Official SDKs by language
Twilio maintains official SDKs for several programming languages, providing robust and well-documented tools for integrating Authy functionality. These SDKs ensure compatibility with the Authy API, offering a consistent development experience across different environments. The table below outlines the officially supported SDKs, their respective package identifiers, typical installation commands, and maturity status.
| Language | Package Name/Identifier | Install Command Example | Maturity |
|---|---|---|---|
| Node.js | twilio (includes Authy) |
npm install twilio |
Stable |
| Python | twilio (includes Authy) |
pip install twilio |
Stable |
| Ruby | twilio-ruby (includes Authy) |
gem install twilio-ruby |
Stable |
| PHP | twilio/sdk (includes Authy) |
composer require twilio/sdk |
Stable |
| Java | com.twilio.sdk:twilio (Maven) |
Add to pom.xml: <dependency><groupId>com.twilio.sdk</groupId><artifactId>twilio</artifactId><version>X.Y.Z</version></dependency> |
Stable |
| C# | Twilio (NuGet) |
dotnet add package Twilio |
Stable |
Installation
Installing the Twilio SDKs, which encompass the Authy functionalities, is typically done using the standard package manager for each respective language. For detailed instructions and specific version requirements, developers should consult the official Twilio Authy documentation.
Node.js
The Twilio Node.js SDK includes support for Authy. Install it via npm:
npm install twilio
Python
The Twilio Python SDK supports Authy integration. Install it using pip:
pip install twilio
Ruby
The Twilio Ruby SDK provides Authy features. Install it via RubyGems:
gem install twilio-ruby
PHP
For PHP projects, the Twilio PHP SDK includes Authy functionality. Install it with Composer:
composer require twilio/sdk
Java
The Twilio Java SDK, which contains Authy APIs, can be integrated using Maven or Gradle. For Maven, add the dependency to your pom.xml:
<dependency>
<groupId>com.twilio.sdk</groupId>
<artifactId>twilio</artifactId>
<version>9.x.x</version>
</dependency>
Replace 9.x.x with the latest stable version as found in the Twilio Java library documentation.
C#
For .NET applications, the Twilio C# SDK offers Authy support. Install it using NuGet Package Manager:
dotnet add package Twilio
Or via the NuGet Package Manager Console:
Install-Package Twilio
Quickstart example
This example demonstrates how to register a user for Authy and send a verification token using the Node.js SDK. This snippet illustrates creating a new Authy user and requesting an SMS verification. You will need your Twilio Account SID and Authy API Key for this example. Find these credentials in your Twilio console or Authy settings.
const twilio = require('twilio');
// Your Account SID and Auth Token from twilio.com/console
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const authyApiKey = process.env.AUTHY_API_KEY;
const client = new twilio(accountSid, authToken);
const authy = client.authy;
// Example: Registering a user and requesting an SMS token
async function registerUserAndSendToken(email, countryCode, phoneNumber) {
try {
// 1. Register a user with Authy
const newUser = await authy.users.create({
email: email,
countryCode: countryCode,
phone: phoneNumber,
});
console.log('Authy User registered with ID:', newUser.id);
// 2. Request an SMS verification token for the registered user
const smsRequest = await authy.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') // Replace with your Authy service SID
.verifications
.create({
to: `+${countryCode}${phoneNumber}`,
channel: 'sms'
});
console.log('SMS token sent, status:', smsRequest.status);
// You would then prompt the user to enter the token and verify it
// using authy.services('...').verificationChecks.create({ to: ..., code: ... });
} catch (error) {
console.error('Error:', error.message);
}
}
// Replace with actual user data
registerUserAndSendToken('[email protected]', '1', '5551234567');
This code registers a new user with Authy using their email and phone number, then initiates an SMS-based verification by sending a token to the provided phone number. Developers would then typically implement a verification step where the user enters the received token, and the application calls the Authy API to validate it. The ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX placeholder should be replaced with an actual Twilio Verify Service SID, which is part of the Twilio Verify API suite for more granular control over verification channels Twilio Verify API documentation.
Community libraries
While Twilio provides official SDKs, the open-source community sometimes develops additional libraries or wrappers that extend functionality, offer alternative abstractions, or cater to specific frameworks not directly covered by the official offerings. These community-contributed libraries can range from simple API wrappers to full-fledged integrations with popular web frameworks. However, it is important to note that community libraries may not always receive the same level of maintenance, security auditing, or direct support as official SDKs. Developers considering community solutions should evaluate the project's activity, documentation quality, and community support before integration.
Twilio's status as a widely adopted API provider means that various developers and organizations have created and shared tools that interface with its services. These can often be found on platforms like GitHub, npm, PyPI, or other language-specific package repositories. For example, developers might find community contributions for framework-specific integrations (e.g., a Django package for Authy, or a Rails gem for Authy features) or tools for niche use cases beyond the core functionality of verification codes, such as custom UI components for Authy. Always consult the official Twilio Authy documentation for the most up-to-date and officially supported integration methods.