Menu

Expand
Rate this page:

Verify Phone Verification API V1

Verify v1 API has reached End of Sale. It 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. v2 has an improved developer experience and new features, including:

Existing customers will not be impacted at this time until Verify v1 API has reached End of Life. For more information about migration, see Migrating from 1.x to 2.x.

The Twilio Verify REST API allows you to verify that a user has a claimed device in their possession. The API lets you request a verification code to be sent to the user and to check that a received code is valid.

Phone verification is an important first step in your online relationship with a user. To learn more about best practices and recommended registration flows, please consult Twilio Verify Best Practices.

Send a Verification Code

To verify a user's phone number, you will start by requesting to send a verification code to their device. Each verification code is valid for 10 minutes. Subsequent calls to the API before the code has expired will send the same verification code. You cannot modify the amount of time a verification code is valid. You can query the status endpoint to check if a verification code is still valid.

Note that you may use dashes, periods, spaces or nothing to format a phone number.

POST https://api.authy.com/protected/{FORMAT}/phones/verification/start

URL

Name Type Description
FORMAT String The format to expect back from the REST API call. json or xml.

PARAMETERS

Name Type Description
via String The method of delivering the code to the user. sms or call. (🏢 not PII )
country_code Integer The phone's country code. (🏢 not PII )
phone_number String The phone number to send the verification code. (📇 PII )
locale String (recommended) The language of the message received by user. If no region is given (or supported) there will be a default by country. Depending on the country, this will either be the official language of the country or English. We highly recommend that you test your region or use the locale parameter to ensure that your desired language is used. See supported languages for a list of available options. (🏢 not PII )
code_length Integer (optional) Optional value to change the number of verification digits sent. Default value is 4. Allowed values are 4-10. (🏢 not PII )
custom_code Integer (optional) Pass in a pre-generated code. Code length can be between 4-10 characters. Contact Twilio Sales to have this feature enabled. (🏢 not PII )
Loading Code Sample...
        
        

        Start a phone verification

        Please note: For some regions, we are unable to return carrier and cellphone data by default. You need to contact our support team to switch on those regions. More information on our support site.

        Supported Languages (Recommended)

        Please reference Supported Languages for full documentation. We support the format country-region as described in IETF's BPC 47. If no region is given (or supported) there will be a default by country. Supported languages for the locale parameter are af, ar, ca, zh, zh-CN, zh-HK, hr, cs, da, nl, en, fi, fr, de, el, he, hi, hu, id, it, ja, ko, ms, nb, pl, pt-BR, pt, ro, ru, es, sv, tl, th, tr, vi.

        For more information, please reference our full guide to Supported Languages.

        Custom Verification Codes (Optional)

        If you already have token generation and validation logic and would like to keep those systems in place, you can do so. We have a feature where you can submit your code to us and utilize our pre-screened message templates and localizations for both text and voice.

        With this modified setup, you will be charged on each attempted customer verification (requests for a verification code). Due to situations like abandoned requests and users who eagerly request multiple codes, we typically see 30% more /start verifications than /check verifications. This means that you can expect to pay 30% more for this feature. Keep this in mind as you are considering your options.

        If you're using custom verification codes you must also provide feedback that lets us know whether or not the user verified the code. This allows us to proactively monitor our global routing and stay operational. You can send feedback to our system with the Verify Feedback API.

        Contact Twilio Sales and we'll help you enable this option.

        Loading Code Sample...
              
              

              Start a phone verification with custom code

              Following a request using custom_code you will then submit a request to our Feedback API. Head over to the Feedback API docs for example requests.


              Check a Verification Code

              To check if a verification code is correct, pass the code along with the phone number to the API.

              GET https://api.authy.com/protected/{FORMAT}/phones/verification/check

              URL

              Name Type Description
              FORMAT String The format to expect back from the REST API call. json, or xml.

              PARAMETERS

              Name Type Description
              country_code Integer The phone's country code. (🏢 not PII )
              phone_number String The phone number to send the verification code. (📇 PII )
              verification_code String The verification code from the user that is being validated. (🏢 not PII )
              Loading Code Sample...
                    
                    

                    Check a Verification Code

                    Get the Status of a Verification Code Sent to the User

                    Each verification code is valid for 10 minutes. Subsequent calls to the API before the code has expired will send the same verification code. Use this status API to determine how much time remains for an active or pending verification request.

                    GET https://api.authy.com/protected/{FORMAT}/phones/verification/status
                    
                    Name Type Description
                    FORMAT String The format to expect back from the REST API call. json, or xml.

                    PARAMETERS

                    Name Type Description
                    uuid String The uuid from the original request. (🏢 not PII )
                    country_code Integer (Optional) The phone's country code. Alternative to uuid when combined with phone_number. (🏢 not PII )
                    phone_number String (Optional) The phone number to send the verification code. Alternative to uuid when combined with country_code. (📇 PII )

                    Response

                    Name Type Description
                    status String The status of the original request to the user. expired, verified or pending. (🏢 not PII )
                    seconds_to_expire Integer The amount of time in seconds remaining before the verification code expires. (🏢 not PII )
                    success Boolean Returns true if the request was successful. (🏢 not PII )
                    message String A message indicating what happened with the request. (🏢 not PII )
                    Loading Code Sample...
                          
                          

                          Check Verification Status using Verification UUID

                          This example checks the status of the request using country_code and phone_number.

                          Loading Code Sample...
                                
                                

                                Check Verification Status using Phone Number

                                Rate this page:

                                Need some help?

                                We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.

                                Loading Code Sample...
                                      
                                      
                                      

                                      Thank you for your feedback!

                                      Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

                                      Sending your feedback...
                                      🎉 Thank you for your feedback!
                                      Something went wrong. Please try again.

                                      Thanks for your feedback!

                                      thanks-feedback-gif