Get started with Toll-Free Verification Compliance Embed
Compliance Embed in Public Beta
Compliance Embed is currently available for this program as a Public Beta product and the information contained in this document is subject to change. This means that some features are not yet implemented and others may be changed before the product is declared as Generally Available. Public Beta products are not covered by a Twilio SLA.
To use the Compliance Embeddable API, request access.
Before sending messages to toll-free numbers that use the North American Numbering Plan (NANP), mobile carriers must approve these numbers. This process is called Toll-Free Verification (TFV). Carriers might filter or block unverified toll-free numbers.
To allow the end customers of an Independent Software Vendor (ISV) to comply with regulations, Twilio provides the Compliance Embed solution. The Compliance Embed provides an unbranded, self-service solution designed to integrate seamlessly into an ISV-hosted web app. This solution starts a session with Twilio that manages the registration form rendering and data collection for an ISV. The ISV then renders this self-service form to their end customer through their own web app. The end customer completes the form in the web app which sends the compliance data and request to Twilio.
To allow the end customers of an Independent Software Vendor (ISV) to comply with regulations, Twilio provides the Compliance Embed solution. The Compliance Embed provides an unbranded, self-service solution designed to integrate seamlessly into an ISV-hosted web app.
To create this self-service experience, ISVs complete the following activities:
- From their servers, the ISV calls the Twilio ComplianceInquiry Initialize API resource. This returns a session token and session ID.
- In their web app, the ISV creates a React component or JavaScript instance that renders a form in an
iframetag. This form connects to the compliance inquiry in Twilio through the ID and token. - The end customer completes and submits their compliance request through the ISV web app.
- If it succeeds, the end customer can send messages. If it fails, the end customer can, in most cases, resubmit their request through the ISV's web app.
Before you begin, complete the following tasks:
- Create a paid Twilio account, if needed. You can't use a trial account.
- Get an approved Trust Hub Primary Customer Profile in the Twilio Console with a Business Identity of ISV or Reseller.
- Add Persona to the allow list on your firewall. To manage compliance, Twilio uses this service.
- Create a Content Security Policy (CSP) for your web app as another layer of security.
You must authenticate all requests using Twilio's REST API credentials with HTTP Basic Auth.
- Use your account SID as the username and your token as the password.
- The account SID can be either your primary Twilio Account SID or a subaccount SID.
After your ComplianceInquiry completes, the TFV registration ID contains the Account SID that you provided in your credentials. This binds this TFV to that Account.
This request initializes a ComplianceInquiry and returns a session ID and token. To authenticate subsequent end customer submissions, you add this session and token into your web app that renders a submission form.
To initialize a TFV ComplianceInquiry, make an HTTPS POST request to the following API resource:
POST https://trusthub.twilio.com/v1/ComplianceInquiries/Tollfree/Initialize
If you provide any optional parameters, their values appear in the subsequent forms in the end customer's web app.
When using this API resource, include two optional parameters: BusinessRegistrationAuthority and BusinessCountry. These set default registration information for your end customers. Depending on your country, use the following parameters:
| Country of origin | US-based entities | Canada-based entities |
|---|---|---|
| Registration Authority | Employer Identification Number (EIN) | Canadian Business Number (CBN) |
BusinessRegistrationAuthority | EIN | CBN |
BusinessCountry | US | CA |
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createComplianceTollfreeInquiry() {11const complianceTollfreeInquiry =12await client.trusthub.v1.complianceTollfreeInquiries.create({13businessCountry: "US",14businessRegistrationAuthority: "EIN",15notificationEmail: "dean@twilio.com",16tollfreePhoneNumber: "+800445566",17});1819console.log(complianceTollfreeInquiry.inquiryId);20}2122createComplianceTollfreeInquiry();
Response
1{2"inquiry_id": "inq_aaaaaaaaaaaaaaaaaaaaaaaa",3"inquiry_session_token": "new.session.token",4"registration_id": "tri1.us1.trusthub.ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.tollfree.PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",5"url": "https://trusthub.twilio.com/v1/ComplianceInquiries/Tollfree/Initialize"6}
The value of the id property contains two SIDs: tri1.us1.account.{$TWILIO_ACCOUNT_SID}.registration.{$TF_PHONE_NUMBER_SID}.
If the id property returns a value of tri1.us1.account.ACaa..aa.registration.PNnn..nn, this means this registration links to both the Account SID ACaa..aa and the Toll-Free Phone Number SID PNnn..nn.
When you check the status of this registration, search for an tollfree_phone_number_sid that matches PNnn..nn.
To check the status of a TFV request, make a GET request and retrieve a list of TFV requests.
A brand or campaign registration moves through the following statuses. In certain statuses, you can resubmit a failed registration or resume an in-progress registration.
What you can do with a registration, including whether the Compliance Embed will let you resume or resubmit it, depends on its current status:
| Status value | Registration progress | Can resume? | Can resubmit? |
|---|---|---|---|
DRAFT | Started, but not submitted for review. | Yes | No |
PENDING or PENDING_REVIEW | Submitted. | No | No |
IN_REVIEW | Submitted and Twilio, TCR, or both are reviewing the registration. | No | No |
APPROVED or TWILIO_APPROVED | Passed review. | No | No |
REJECTED or TWILIO_REJECTED | Failed review for a correctable reason. | No | Yes |
To find the needed TFV request, make an HTTPS GET request to the TFV resource in the Messaging API. This request returns all TFV requests attached to the Account SID in the API credentials.
GET https://messaging.twilio.com/v1/Tollfree/Verifications
This list includes all TFV requests, including their phone number SIDs in the tollfree_phone_number_sid property.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID at twilio.com/console5// Provision API Keys at twilio.com/console/runtime/api-keys6// and set the environment variables. See http://twil.io/secure7// For local testing, you can use your Account SID and Auth token8const accountSid = process.env.TWILIO_ACCOUNT_SID;9const apiKey = process.env.TWILIO_API_KEY;10const apiSecret = process.env.TWILIO_API_SECRET;11const client = twilio(apiKey, apiSecret, { accountSid: accountSid });1213async function listTollfreeVerification() {14const tollfreeVerifications =15await client.messaging.v1.tollfreeVerifications.list({ limit: 20 });1617tollfreeVerifications.forEach((t) => console.log(t.sid));18}1920listTollfreeVerification();
Response
1{2"meta": {3"page": 0,4"page_size": 50,5"first_page_url": "https://messaging.twilio.com/v1/Tollfree/Verifications?Status=TWILIO_APPROVED&ExternalReferenceId=abc123xyz567&TollfreePhoneNumberSid=PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&IncludeSubAccounts=false&PageSize=50&Page=0",6"previous_page_url": null,7"next_page_url": null,8"key": "verifications",9"url": "https://messaging.twilio.com/v1/Tollfree/Verifications?Status=TWILIO_APPROVED&ExternalReferenceId=abc123xyz567&TollfreePhoneNumberSid=PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&IncludeSubAccounts=false&PageSize=50&Page=0"10},11"verifications": [12{13"sid": "HHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",15"customer_profile_sid": "BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",16"trust_product_sid": "BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",17"regulated_item_sid": "RAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",18"date_created": "2021-01-27T14:18:35Z",19"date_updated": "2021-01-27T14:18:36Z",20"business_name": "Owl, Inc.",21"business_street_address": "123 Main Street",22"business_street_address2": "Suite 101",23"business_city": "Anytown",24"business_state_province_region": "AA",25"business_postal_code": "11111",26"business_country": "US",27"business_website": "http://www.company.com",28"business_contact_first_name": "firstname",29"business_contact_last_name": "lastname",30"business_contact_email": "email@company.com",31"business_contact_phone": "+11231231234",32"notification_email": "support@company.com",33"use_case_categories": [34"TWO_FACTOR_AUTHENTICATION",35"MARKETING"36],37"use_case_summary": "This number is used to send out promotional offers and coupons to the customers of John's Coffee Shop",38"production_message_sample": "lorem ipsum",39"opt_in_image_urls": [40"https://testbusiness.com/images/image1.jpg",41"https://testbusiness.com/images/image2.jpg"42],43"opt_in_type": "VERBAL",44"message_volume": "1,000",45"additional_information": "see our privacy policy here www.johnscoffeeshop.com/privacypolicy",46"tollfree_phone_number_sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",47"status": "TWILIO_APPROVED",48"url": "https://messaging.twilio.com/v1/Tollfree/Verifications/HHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",49"rejection_reason": null,50"error_code": null,51"edit_expiration": null,52"edit_allowed": null,53"rejection_reasons": null,54"resource_links": {55"customer_profile": "https://trusthub.twilio.com/v1/CustomerProfiles/BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",56"trust_product": "https://trusthub.twilio.com/v1/TrustProducts/BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",57"channel_endpoint_assignment": "https://trusthub.twilio.com/v1/TrustProducts/BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ChannelEndpointAssignments/RAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"58},59"external_reference_id": "abc123xyz567",60"business_registration_number": "123456789",61"business_registration_authority": "EIN",62"business_registration_country": "US",63"business_type": "PRIVATE_PROFIT",64"business_registration_phone_number": "+13023334444",65"doing_business_as": "Toms Widgets",66"age_gated_content": false,67"help_message_sample": "For help, reply HELP or visit our website.",68"opt_in_confirmation_message": "Thank you for opting in!",69"opt_in_keywords": [70"START"71],72"privacy_policy_url": "https://www.example.com/privacy",73"terms_and_conditions_url": "https://www.example.com/terms",74"tollfree_phone_number": "+18003334444",75"vetting_id": null,76"vetting_id_expiration": null,77"vetting_provider": null78}79]80}
To learn more about query parameters for filtering results, see the [TFV request API][get-brand-list].
If you know the TFV request you need, make an HTTPS GET request that includes the TFV request SID to the Toll-Free Verifications resource in the Messaging API.
GET https://messaging.twilio.com/v1/Tollfree/Verifications/{Sid}
This request returns one TFV request as a JSON document.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID at twilio.com/console5// Provision API Keys at twilio.com/console/runtime/api-keys6// and set the environment variables. See http://twil.io/secure7// For local testing, you can use your Account SID and Auth token8const accountSid = process.env.TWILIO_ACCOUNT_SID;9const apiKey = process.env.TWILIO_API_KEY;10const apiSecret = process.env.TWILIO_API_SECRET;11const client = twilio(apiKey, apiSecret, { accountSid: accountSid });1213async function fetchTollfreeVerification() {14const tollfreeVerification = await client.messaging.v115.tollfreeVerifications("HHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")16.fetch();1718console.log(tollfreeVerification.sid);19}2021fetchTollfreeVerification();
Response
1{2"sid": "HHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"customer_profile_sid": "BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",5"trust_product_sid": "BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",6"regulated_item_sid": "RAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",7"date_created": "2021-01-27T14:18:35Z",8"date_updated": "2021-01-27T14:18:36Z",9"business_name": "Owl, Inc.",10"business_street_address": "123 Main Street",11"business_street_address2": "Suite 101",12"business_city": "Anytown",13"business_state_province_region": "AA",14"business_postal_code": "11111",15"business_country": "US",16"business_website": "http://www.company.com",17"business_contact_first_name": "firstname",18"business_contact_last_name": "lastname",19"business_contact_email": "email@company.com",20"business_contact_phone": "+11231231234",21"notification_email": "support@company.com",22"use_case_categories": [23"TWO_FACTOR_AUTHENTICATION",24"MARKETING"25],26"use_case_summary": "This number is used to send out promotional offers and coupons to the customers of John's Coffee Shop",27"production_message_sample": "lorem ipsum",28"opt_in_image_urls": [29"https://testbusiness.com/images/image1.jpg",30"https://testbusiness.com/images/image2.jpg"31],32"opt_in_type": "VERBAL",33"message_volume": "2000",34"additional_information": "see our privacy policy here www.johnscoffeeshop.com/privacypolicy",35"tollfree_phone_number_sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",36"status": "TWILIO_APPROVED",37"rejection_reason": null,38"error_code": null,39"edit_expiration": null,40"edit_allowed": null,41"rejection_reasons": null,42"resource_links": {43"customer_profile": "https://trusthub.twilio.com/v1/CustomerProfiles/BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",44"trust_product": "https://trusthub.twilio.com/v1/TrustProducts/BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",45"channel_endpoint_assignment": "https://trusthub.twilio.com/v1/TrustProducts/BUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ChannelEndpointAssignments/RAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"46},47"url": "https://messaging.twilio.com/v1/Tollfree/Verifications/HHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",48"external_reference_id": "abc123xyz567",49"business_registration_number": "123456789",50"business_registration_authority": "EIN",51"business_registration_country": "US",52"business_type": "PRIVATE_PROFIT",53"business_registration_phone_number": "+13023334444",54"doing_business_as": "Toms Widgets",55"age_gated_content": false,56"help_message_sample": "For help, reply HELP or visit our website.",57"opt_in_confirmation_message": "Thank you for opting in!",58"opt_in_keywords": [59"START"60],61"privacy_policy_url": "https://www.example.com/privacy",62"terms_and_conditions_url": "https://www.example.com/terms",63"tollfree_phone_number": "+18003334444",64"vetting_id": null,65"vetting_id_expiration": null,66"vetting_provider": null67}
POST https://trusthub.twilio.com/v1/ComplianceInquiries/Tollfree/Initialize
The Initialize API resource supports both fresh submissions and resumption of existing submissions.
When you make a request for a toll-free number that has an existing incomplete or rejected ComplianceInquiry, the response updates the inquiry_session_token and might update the inquiry_id.
Re-initialize the SDK with the inquiry_id and inquiry_session_token from the latest response. Previously entered data is retained and pre-populated in the form.
If your end customer has a rejected TFV that they can resubmit, have your web app server make another request to the Initialize API resource.
In this request, your end customer can edit their submission and correct any issues.
The embedded form displays any previously accepted data. This allows targeted corrections rather than requiring them to re-enter everything.
If a verification is already in progress, approved, or rejected with an error that cannot be resubmitted, the API returns an error response.
Twilio validates the data in these fields.
- To learn more about these validation rules, see the Toll-Free Verification Guide.
- To get TFV status change notifications, use Twilio Event Streams.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createComplianceTollfreeInquiry() {11const complianceTollfreeInquiry =12await client.trusthub.v1.complianceTollfreeInquiries.create({13businessName: "Twilio",14businessRegistrationAuthority: "EIN",15businessRegistrationCountry: "US",16businessRegistrationNumber: "12-3456789",17businessType: "PRIVATE_PROFIT",18businessWebsite: "https://www.twilio.com",19notificationEmail: "dean@twilio.com",20tollfreePhoneNumber: "+800445566",21});2223console.log(complianceTollfreeInquiry.inquiryId);24}2526createComplianceTollfreeInquiry();
Response
1{2"inquiry_id": "inq_aaaaaaaaaaaaaaaaaaaaaaaa",3"inquiry_session_token": "new.session.token",4"registration_id": "tri1.us1.trusthub.ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.tollfree.PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",5"url": "https://trusthub.twilio.com/v1/ComplianceInquiries/Tollfree/Initialize"6}
A successful request returns a JSON response body.
The TFV Initialize API resource returns the following errors.
| HTTP status | Cause |
|---|---|
| 400 | TollfreePhoneNumber is missing from the request. |
| 400 | TollfreePhoneNumber isn't a toll-free number. |
| 400 | TollfreePhoneNumber doesn't belong to your account. |
| 400 | TollfreePhoneNumber isn't in use on your account. |
| 400 | NotificationEmail is missing from the request. |
| 400 | The account is a trial account. |
| 400 | The account isn't active. |
| 400 | CustomerProfileSid doesn't exist, isn't TWILIO_APPROVED, is a Starter profile, is your own Primary Customer Profile, or has no Business Identity set. |
| 409 | The verification isn't eligible for re-submission. It's already in progress, or it was rejected with an error that can't be resubmitted. |
| 500 | You've reached the session limit of 50 session tokens per inquiry_id, or validating the customer profile failed. |
After you initialize the ComplianceInquiry, embed the form in your app using the Twilio React SDK or the Twilio JavaScript SDK.