Version 2 of the Verify API is now available! V2 has an improved developer experience and new features. Some of the features of the V2 API include:
- PSD2 Secure Customer Authentication Support
- Improved Visibility and Insights
You are currently viewing Version 1. V1 of the API will be maintained for the time being, but any new features and development will be on Version 2. We encourage you to do any new development with API V2. Check out the migration guide or the API Reference for more information.
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.
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.
|via||文字列||The method of delivering the code to the user.
|country_code||integer||The phone's country code. (🏢 not PII )|
|phone_number||文字列||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||整数（オプション）||Optional value to change the number of verification digits sent. Default value is 4. Allowed values are 4-10. (🏢 not PII )|
|custom_code||整数（オプション）||Pass in a pre-generated code. Code length can be between 4-10 characters. Contact Twilio Sales to have this feature enabled. (🏢 not PII )|
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
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.
To check if a verification code is correct, pass the code along with the phone number to the API.
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.
|uuid||文字列||The uuid from the original request. (🏢 not PII )|
|country_code||整数（オプション）||The phone's country code. Alternative to
|phone_number||文字列（オプション）||The phone number to send the verification code. Alternative to
|status||文字列||The status of the original request to the user.
|seconds_to_expire||integer||The amount of time in seconds remaining before the verification code expires. (🏢 not PII )|
|message||文字列||A message indicating what happened with the request. (🏢 not PII )|
This example checks the status of the request using