Ahoy logo
Ahoy logo

Twilio developer hub

Tutorials, best practices, code samples, and inspiration to build all your communications experiences and digital engagement solutions on Twilio.
   

Explore resources by product

Find sample code and step-by-step guides to help you tackle your next project with Twilio.

Identity and verification

Set up SMS or voice verifications to quickly authenticate users, fight fraud, and protect user accounts.

  • Add user verification over SMS, Voice, WhatsApp, Email, and other channels – or create TOTPs for authenticator apps

  • Query real-time phone intelligence data with our Lookup API to reduce fraud risk and increase deliverability

  • Twilio Verify Fraud Guard stops artificially inflated traffic attacks before they happen

  • 4.8B+ verifications per year

Send a verification token

// Download the helper library from https://www.twilio.com/docs/node/install
// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = require('twilio')(accountSid, authToken);

client.verify.v2.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                .verifications
                .create({to: '+15017122661', channel: 'sms'})
                .then(verification => console.log(verification.status));
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client


# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ['TWILIO_ACCOUNT_SID']
auth_token = os.environ['TWILIO_AUTH_TOKEN']
client = Client(account_sid, auth_token)

verification = client.verify \
                     .v2 \
                     .services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                     .verifications \
                     .create(to='+15017122661', channel='sms')

print(verification.status)
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Verify.V2.Service;


class Program
{
    static void Main(string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var verification = VerificationResource.Create(
            to: "+15017122661",
            channel: "sms",
            pathServiceSid: "VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        );

        Console.WriteLine(verification.Status);
    }
}
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.verify.v2.service.Verification;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Verification verification = Verification.creator(
                "VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                "+15017122661",
                "sms")
            .create();

        System.out.println(verification.getStatus());
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$verification = $twilio->verify->v2->services("VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                   ->verifications
                                   ->create("+15017122661", "sms");

print($verification->status);
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

verification = @client.verify
                      .v2
                      .services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                      .verifications
                      .create(to: '+15017122661', channel: 'sms')

puts verification.status
twilio api:verify:v2:services:verifications:create \
    --service-sid VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
    --to +15017122661 \
    --channel sms
curl -X POST "https://verify.twilio.com/v2/Services/VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Verifications" \
--data-urlencode "To=+15017122661" \
--data-urlencode "Channel=sms" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
Personalized Twilio console

Start building with a free trial

Sign up for a free account with a small trial balance so you can begin experimenting with Twilio APIs.

Join the Twilio community

Connect with the Twilio developer community to see what we’re building, where we're meeting, and how to get support for your project.

Man smiling at laptop with Twilio code and graphs on screen.

Personalization at scale - redefine how you build with Twilio

Developers are the foundation of Twilio, whether working at a startup, employed at an enterprise, or building their first app. Twilio’s platform enables building intelligent personalized communications experiences at scale via channel APIs, a customer data platform, and the ability to integrate with the latest emerging technologies and partners.

Using AI solutions and a wealth of data, you can uncover the insights and intelligence necessary to create meaningful connections with your data that drive how and what you develop. By connecting the dots between communications, AI, and data, Twilio’s unified range of products, integrations, and reliable partnerships empower you as a developer to do what you do best: build.

Trainings


Level up your skills

Level Up with Generative AI: Elevate Your Communication Channels

 

Generative AI is a powerful tool for simplifying many everyday tasks that require reasoning and creativity, including some types of communication. With the right context and knowledge, you can take advantage of this technology to uplevel your conversations across all channels.You’ll leave this event equipped to integrate Generative AI into your voice and email applications. You’ll understand how to initiate an outbound call with Twilio voice and how to use audio files in your voice calls. We’ll cover SendGrid’s Inbound Parse to integrate with a large language model, and we’ll make use of Dynamic Templates to generate programmatic content from the AI response. And of course, we’ll talk about some tips and tricks for prompt engineering to get the best response from Generative AI.

 

Start the training 

Twilio Startup Labs: Enter the Metrics

 

Take a trip down the rabbit hole of customer engagement with us.In this Twilio Startup Labs we will be diving into the metrics of customer engagement and talk about how to run meaningful experiments. You will have a myriad of “I know Kung Fu” moments, such as:- Which metrics matter for customer engagement

- How to measure these metrics across multiple channels
- Ideas for experiments to test your strategy
- Lessons from industry experts and other entrepreneurs on building awesome customer experiences.

 

Start the training 

Superclass Live: Dive Into Developing with Twilio

 

Are you a developer new to Twilio who is feeling a little bit stuck? Do you have an idea you can’t wait to build but you just aren’t sure how to get started? Are you curious about what you can do with Twilio, now that you’ve signed up for an account?If your answer to any of those questions is “yes”, then Superclass is right for you! Start with any of our three on-demand courses that guide you through the fundamentals of Voice, Messaging, and Email. And then join us for an interactive Superclass Live to see an inspiring demo, ask questions, and start to build with the support of Twilio product experts.

 

Save your seat

 

Helpful links


Twilio resources

  • Docs

    Start here to see API reference documentation, SDKs in your language, and sample apps.

  • Twilio CodeExchange logo
    CodeExchange

    Prebuilt tutorials to get started with common use cases.

  • A newspaper article
    Blog

    Explore how to use Segment and Twilio Programmable Messaging to send a personalized SMS campaign to customers.

  • Twilio CLI logo
    CLI

    The Twilio Command-Line Interface lets you manage Twilio resources from your terminal or command prompt.

  • A document with a checkmark
    API status

    Check on the current status of Twilio API.

  • Spreadsheet document
    Changelog

    Subscribe to see updates to Twilio products and services.

  • Document Lined
    The Twilio Collective on Stack Overflow

    Ask questions and get answers from the broader twilio community.

  • Twilio Support Center logo
    Support

    View help center articles for answers to common questions.

Get started


Start building

Only pay for what you use with no subscriptions. Additional volume and committed-use discounts are available as you scale.