This Hosted Number Order Resource API will be discontinued from developer preview. All documentation and support will be retired by the end of 2024. A new version of this API is currently in Pilot and will be released as a Public Beta product in the second half of 2024. If you are interested in getting early access to the new version of the API and its documentation, please complete our interest form and we'll be in touch!
The Hosted Number Orders product allows an account to request for their phone numbers to be hosted on Twilio for SMS. Start the Hosted Number onboarding process by sending a POST
to the list resource, which will create a new request to host a phone number, or move the Hosted Number Order along the onboarding process by updating the status of the Hosted Number Orders Instance Resource. Upon creation of a Hosted Number Order instance resource, a corresponding IncomingPhoneNumbers instance resource will also be created. Currently, Twilio only has the ability to onboard landline or toll-free US & Canada numbers that are not currently SMS enabled.
After the number's ownership has been verified, the user will then need to create a new Authorization Document that is electronically signed, giving Twilio permission to route SMS to and from Twilio's network. To see how to interact with the Authorization Documents resource, please visit the Public API reference.
Once the process is completed, users will be able to answer phone calls on their existing infrastructure and leverage the same number identity for two-way SMS on Twilio's platform.
A 34 character string that uniquely identifies this HostedNumberOrder.
^HR[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
A 34 character string that uniquely identifies the account.
^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
A 34 character string that uniquely identifies the IncomingPhoneNumber resource that represents the phone number being hosted.
^PN[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
A 34 character string that uniquely identifies the Address resource that represents the address of the owner of this phone number.
^AD[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
A 34 character string that uniquely identifies the Authorization Document the user needs to sign.
^PX[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Phone number to be hosted. This must be in E.164 format, e.g., +16175551212
Set of booleans describing the capabilities hosted on Twilio's platform. SMS is currently only supported.
A 64 character string that is a human-readable text that describes this resource.
Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
Status of this resource. It can hold one of the values: 1. Twilio Processing 2. Received, 3. Pending LOA, 4. Carrier Processing, 5. Completed, 6. Action Required, 7. Failed. See the HostedNumberOrders Status Values section for more information on each of these statuses.
received
pending-verification
verified
pending-loa
carrier-processing
testing
completed
failed
action-required
A message that explains why a hosted_number_order went to status "action-required"
The date this resource was created, given as GMT RFC 2822 format.
The date that this resource was updated, given as GMT RFC 2822 format.
The number of attempts made to verify ownership of the phone number that is being hosted.
0
A list of emails that LOA document for this HostedNumberOrder will be carbon copied to.
The type of ownership verification required to move the number to a verified
state. The verification methods are phone-call
or phone-bill
.
phone-call
phone-bill
A 34 character string that uniquely identifies the Identity Document resource that represents the document for verifying ownership of the number to be hosted.
^RI[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
A numerical extension to be used when making the ownership verification call.
A value between 0-30 specifying the number of seconds to delay initiating the ownership verification call.
0
A verification code provided in the response for a user to enter when they pick up the phone call.
A list of 34 character strings that are unique identifiers for the calls placed as part of ownership verification.
Status | Description |
---|---|
twilio-processing | Twilio is processing your request and will either send to the failed status if the number is not eligible to be hosted, or move the number to received status. |
received | Twilio has received the HostedNumberOrder request and determined that the phone number in the request can be hosted on Twilio's platform. |
pending-verification | Twilio is awaiting the Hosted Number Order to be verified by the end-user by picking up the phone and listening to a security token. The verification code is valid for 10 minutes. Subsequent calls to the API within the expiration time will send the same verification code. There can be a max of three verification attempts before the status changes to action_required. |
verified | Twilio has confirmed with a security token that the person answering the phone has verified their request for Hosted SMS. |
pending-loa | LOA for the HostedNumberOrder has been generated, but the document has not yet been signed by the email recipient specified on the HostedNumberOrder. |
carrier-processing | LOA for the HostedNumberOrder has been signed, and the phone number has been submitted to Twilio's underlying provider/carrier to enable the specified capabilities. |
testing | The phone number is undergoing capability testing for the capabilities specified in this order. |
completed | HostedNumberOrder onboarding has completed and the phone number is ready for use. |
action-required | HostedNumberOrder onboarding encountered a failure. An operations specialist will investigate the failure. |
failed | The Hosted Number Order failed because the number is currently SMS enabled or has been idle for more than 30 days. At this point, it is no longer possible to re-submit the request for the failed Hosted Number Order. However, a new Hosted Number Order can be created for the same phone number once SMS registration has been deactivated on the phone number or the previous Hosted Number Order has failed due to being idle. |
When a Hosted Number Order changes status, Twilio will make an asynchronous HTTP request to the StatusCallback URL if you provided one in your API request. By capturing this request, you can determine when the Hosted Number Order changes status.
The Hosted Number Orders status callback request passes the parameters listed in the table below:
Status | Description |
---|---|
Status | The new status of the Hosted Number Order |
HostedNumberOrderSid | The unique sid of the Hosted Number Order |
PhoneNumber | The [+E.164][e164] format of the Hosted Number Order |
POST https://preview.twilio.com/HostedNumbers/HostedNumberOrders
Creates a new Hosted Number Order for the specified capability. Currently, only SMS is a supported capability.
application/x-www-form-urlencoded
Used to specify that the SMS capability will be hosted on Twilio's platform.
This defaults to the AccountSid of the authorization the user is using. This can be provided to specify a subaccount to add the HostedNumberOrder to.
^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
A 64 character string that is a human readable text that describes this resource.
Optional. Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
Optional. A list of emails that the LOA document for this HostedNumberOrder will be carbon copied to.
The URL that Twilio should request when somebody sends an SMS to the phone number. This will be copied onto the IncomingPhoneNumber resource.
The HTTP method that should be used to request the SmsUrl. Must be either GET
or POST
. This will be copied onto the IncomingPhoneNumber resource.
GET
POST
A URL that Twilio will request if an error occurs requesting or executing the TwiML defined by SmsUrl. This will be copied onto the IncomingPhoneNumber resource.
The HTTP method that should be used to request the SmsFallbackUrl. Must be either GET
or POST
. This will be copied onto the IncomingPhoneNumber resource.
GET
POST
Optional. The Status Callback URL attached to the IncomingPhoneNumber resource.
Optional. The Status Callback Method attached to the IncomingPhoneNumber resource.
GET
POST
Optional. The 34 character sid of the application Twilio should use to handle SMS messages sent to this number. If a SmsApplicationSid
is present, Twilio will ignore all of the SMS urls above and use those set on the application.
^AP[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Optional. A 34 character string that uniquely identifies the Address resource that represents the address of the owner of this phone number.
^AD[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Optional. Email of the owner of this phone number that is being hosted.
Optional. The method used for verifying ownership of the number to be hosted. One of phone-call (default) or phone-bill.
phone-call
phone-bill
Optional. The unique sid identifier of the Identity Document that represents the document for verifying ownership of the number to be hosted. Required when VerificationType is phone-bill.
^RI[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
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 createHostedNumbersHostedNumberOrder() {11const hostedNumberOrder =12await client.preview.hosted_numbers.hostedNumberOrders.create({13phoneNumber: "+15017122661",14smsCapability: true,15});1617console.log(hostedNumberOrder.sid);18}1920createHostedNumbersHostedNumberOrder();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"address_sid": "AD11111111111111111111111111111111",4"call_delay": 0,5"capabilities": {6"sms": true,7"voice": false8},9"cc_emails": [],10"date_created": "2017-03-28T20:06:39Z",11"date_updated": "2017-03-28T20:06:39Z",12"email": "test@twilio.com",13"extension": null,14"failure_reason": "",15"friendly_name": null,16"incoming_phone_number_sid": "PN11111111111111111111111111111111",17"phone_number": "+15017122661",18"sid": "HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",19"signing_document_sid": null,20"status": "received",21"unique_name": null,22"url": "https://preview.twilio.com/HostedNumbers/HostedNumberOrders/HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",23"verification_attempts": 0,24"verification_call_sids": null,25"verification_code": null,26"verification_document_sid": null,27"verification_type": "phone-call"28}
GET https://preview.twilio.com/HostedNumbers/HostedNumberOrders/{Sid}
Returns a single, existing Hosted Number Orders instance resource specified by the requested Hosted Number Orders instance resource SID.
A 34 character string that uniquely identifies this HostedNumberOrder.
^HR[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
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 fetchHostedNumbersHostedNumberOrder() {11const hostedNumberOrder = await client.preview.hosted_numbers12.hostedNumberOrders("HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.fetch();1415console.log(hostedNumberOrder.sid);16}1718fetchHostedNumbersHostedNumberOrder();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"address_sid": "AD11111111111111111111111111111111",4"call_delay": 15,5"capabilities": {6"sms": true,7"voice": false8},9"cc_emails": [10"aaa@twilio.com",11"bbb@twilio.com"12],13"date_created": "2017-03-28T20:06:39Z",14"date_updated": "2017-03-28T20:06:39Z",15"email": "test@twilio.com",16"extension": "5105",17"failure_reason": "",18"friendly_name": "friendly_name",19"incoming_phone_number_sid": "PN11111111111111111111111111111111",20"phone_number": "+14153608311",21"sid": "HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",22"signing_document_sid": "PX11111111111111111111111111111111",23"status": "received",24"unique_name": "foobar",25"url": "https://preview.twilio.com/HostedNumbers/HostedNumberOrders/HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",26"verification_attempts": 0,27"verification_call_sids": [28"CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",29"CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab"30],31"verification_code": "8794",32"verification_document_sid": null,33"verification_type": "phone-call"34}
GET https://preview.twilio.com/HostedNumbers/HostedNumberOrders
The Status of this HostedNumberOrder. One of received
, pending-verification
, verified
, pending-loa
, carrier-processing
, testing
, completed
, failed
, or action-required
.
received
pending-verification
verified
pending-loa
carrier-processing
testing
completed
failed
action-required
An E164 formatted phone number hosted by this HostedNumberOrder.
A 34 character string that uniquely identifies the IncomingPhoneNumber resource created by this HostedNumberOrder.
^PN[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
A human readable description of this resource, up to 64 characters.
Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
How many resources to return in each list page. The default is 50, and the maximum is 1000.
1
Maximum: 1000
The page token. This is provided by the API.
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 listHostedNumbersHostedNumberOrder() {11const hostedNumberOrders =12await client.preview.hosted_numbers.hostedNumberOrders.list({ limit: 20 });1314hostedNumberOrders.forEach((h) => console.log(h.sid));15}1617listHostedNumbersHostedNumberOrder();
1{2"meta": {3"first_page_url": "https://preview.twilio.com/HostedNumbers/HostedNumberOrders?Status=completed&FriendlyName=example&PhoneNumber=%2B19193608000&UniqueName=something123&IncomingPhoneNumberSid=PNzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz&PageSize=50&Page=0",4"key": "items",5"next_page_url": null,6"page": 0,7"page_size": 50,8"previous_page_url": null,9"url": "https://preview.twilio.com/HostedNumbers/HostedNumberOrders?Status=completed&FriendlyName=example&PhoneNumber=%2B19193608000&UniqueName=something123&IncomingPhoneNumberSid=PNzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz&PageSize=50&Page=0"10},11"items": []12}
POST https://preview.twilio.com/HostedNumbers/HostedNumberOrders/{Sid}
Tries to update a single, existing Hosted Number Orders instance resource's properties and returns the updated resource representation if successful. The returned response is identical to that returned above when fetching.
A 34 character string that uniquely identifies this HostedNumberOrder.
^HR[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
application/x-www-form-urlencoded
A 64 character string that is a human readable text that describes this resource.
Provides a unique and addressable name to be assigned to this HostedNumberOrder, assigned by the developer, to be optionally used in addition to SID.
Optional. A list of emails that LOA document for this HostedNumberOrder will be carbon copied to.
User can only post to pending-verification
status to transition the HostedNumberOrder to initiate a verification call or verification of ownership with a copy of a phone bill.
received
pending-verification
verified
pending-loa
carrier-processing
testing
completed
failed
action-required
A verification code that is given to the user via a phone call to the phone number that is being hosted.
Optional. The method used for verifying ownership of the number to be hosted. One of phone-call (default) or phone-bill.
phone-call
phone-bill
Optional. The unique sid identifier of the Identity Document that represents the document for verifying ownership of the number to be hosted. Required when VerificationType is phone-bill.
^RI[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The number of seconds, between 0 and 60, to delay before initiating the verification call. Defaults to 0.
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 updateHostedNumbersHostedNumberOrder() {11const hostedNumberOrder = await client.preview.hosted_numbers12.hostedNumberOrders("HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.update({ friendlyName: "My important hosted number order" });1415console.log(hostedNumberOrder.sid);16}1718updateHostedNumbersHostedNumberOrder();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"address_sid": "AD11111111111111111111111111111111",4"call_delay": 15,5"capabilities": {6"sms": true,7"voice": false8},9"cc_emails": [10"test1@twilio.com",11"test2@twilio.com"12],13"date_created": "2017-03-28T20:06:39Z",14"date_updated": "2017-03-28T20:06:39Z",15"email": "test+hosted@twilio.com",16"extension": "1234",17"failure_reason": "",18"friendly_name": "My important hosted number order",19"incoming_phone_number_sid": "PN11111111111111111111111111111111",20"phone_number": "+14153608311",21"sid": "HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",22"signing_document_sid": "PX11111111111111111111111111111111",23"status": "pending-loa",24"unique_name": "new unique name",25"url": "https://preview.twilio.com/HostedNumbers/HostedNumberOrders/HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",26"verification_attempts": 1,27"verification_call_sids": [28"CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",29"CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab"30],31"verification_code": "8794",32"verification_document_sid": null,33"verification_type": "phone-call"34}
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 updateHostedNumbersHostedNumberOrder() {11const hostedNumberOrder = await client.preview.hosted_numbers12.hostedNumberOrders("HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.update({14status: "pending-verification",15verificationType: "phone-call",16});1718console.log(hostedNumberOrder.sid);19}2021updateHostedNumbersHostedNumberOrder();
1{2"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"address_sid": "AD11111111111111111111111111111111",4"call_delay": 15,5"capabilities": {6"sms": true,7"voice": false8},9"cc_emails": [10"test1@twilio.com",11"test2@twilio.com"12],13"date_created": "2017-03-28T20:06:39Z",14"date_updated": "2017-03-28T20:06:39Z",15"email": "test+hosted@twilio.com",16"extension": "1234",17"failure_reason": "",18"friendly_name": "new friendly name",19"incoming_phone_number_sid": "PN11111111111111111111111111111111",20"phone_number": "+14153608311",21"sid": "HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",22"signing_document_sid": "PX11111111111111111111111111111111",23"status": "pending-verification",24"unique_name": "new unique name",25"url": "https://preview.twilio.com/HostedNumbers/HostedNumberOrders/HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",26"verification_attempts": 1,27"verification_call_sids": [28"CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",29"CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab"30],31"verification_code": "8794",32"verification_document_sid": null,33"verification_type": "phone-call"34}
Ownership Verification is a security measure to host the number with Twilio for SMS to ensure the authenticity of the request.
DELETE https://preview.twilio.com/HostedNumbers/HostedNumberOrders/{Sid}
Cancels the Hosted Number Order, and consequently, deletes the corresponding Incoming Phone Number.
You can only issue the DELETE
request when the HostedNumberOrder status is in received
, pending-verification
, verified
or pending-loa
. If the Hosted Number Order is completed
, you can off-board the Twilio platform by issuing a DELETE
request to the corresponding IncomingPhoneNumbers. If the Hosted Number Order is in a failed
state due to either current SMS enablement or idle timeout, a new Hosted Number Order can be created. Please note that the Hosted Number Order will keep failing if SMS enablement is not removed from the number.
A 34 character string that uniquely identifies this HostedNumberOrder.
^HR[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
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 deleteHostedNumbersHostedNumberOrder() {11await client.preview.hosted_numbers12.hostedNumberOrders("HRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.remove();14}1516deleteHostedNumbersHostedNumberOrder();