Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Hosted Number Orders - API Quickstart


(warning)

Warning

This API is currently in Developer Preview

The Twilio Hosted Numbers API makes it easy for customers to enable Twilio's Programmable SMS with their existing US & Canada voice landline and toll-free numbers. The voice traffic will remain with the current voice provider, while Twilio's SMS routing profile will be applied for inbound and outbound SMS traffic on Twilio. As well as providing the capability to send outbound voice calls from the same number.

The Hosted Number Orders API provides a way to SMS enable a number and host on Twilio without having to purchase or port a number to Twilio. The API enables the ability to host a number using a structured API that provides a low-touch and secure workflow for you and your customers.

The Hosted Number Orders API is in Developer Preview and works for US & Canada landline and toll-free numbers that are not currently enabled for messaging. Hosted Numbers costs $0.50 a month. Request early access to the Hosted Numbers SMS Enablement developer preview(link takes you to an external page) to get your account access.

Create new Hosted Number Order

create-new-hosted-number-order page anchor
curl

_10
curl -X POST https://preview.twilio.com/HostedNumbers/HostedNumberOrders \
_10
-d "PhoneNumber=+18444905863" \
_10
-d "SmsCapability=true" \
_10
-d "FriendlyName=MyHostedNumberSmsOrder" \
_10
-d "StatusCallbackUrl=http://example.com/callback" \
_10
-d "StatusCallbackMethod=POST" \
_10
-u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'

Output

_25
{
_25
"status": "twilio-processing",
_25
"date_updated": "2018-01-21T21:40:55Z",
_25
"verification_code": null,
_25
"incoming_phone_number_sid": "PN876a18805574a952ffb73907b24205f0",
_25
"failure_reason": null,
_25
"verification_attempts": 0,
_25
"verification_type": "phone-call",
_25
"capabilities": {
_25
"voice": false,
_25
"mms": false,
_25
"sms": true
_25
},
_25
"sid": "HR36f3f0c7c8d5d9210114fdcd8b6bcf19",
_25
"phone_number": "+18444905863",
_25
"call_delay": 0,
_25
"signing_document_sid": null,
_25
"verification_document_sid": null,
_25
"verification_call_sids": [],
_25
"extension": null,
_25
"url": "https://preview.twilio.com/HostedNumbers/HostedNumberOrders/HR36f3f0c7c8d5d9210114fdcd8b6bcf19",
_25
"friendly_name": "MyHostedNumberSmsOrder",
_25
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_25
"date_created": "2018-01-21T21:40:55Z"
_25
}


Quick Start Tutorial

quick-start-tutorial page anchor

The Hosted Number Orders API allows you to: submit an SMS enablement request, get immediate hosting eligibility validation of the number, track Hosted Number Order status transitions, and automate configuring a Hosted Number before the number is active on Twilio's Super Network.

Suppose you wanted to SMS enable your number +18444905863 and host on Twilio. Your first step would be to create a new Hosted Number Order with the phone number in +E.164 format.

Twilio will check if the number meets the criteria for SMS enablement and, if valid, will create the Hosted Number Order and return a JSON resource of the instance resource:

Verify Ownership with Phone Call

verify-ownership-with-phone-call page anchor
curl

_10
curl -XPOST https://preview.twilio.com/HostedNumbers/HostedNumberOrders/HR36f3f0c7c8d5d9210114fdcd8b6bcf19 \
_10
-u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token' \
_10
-d "VerificationType=phone-call" \
_10
-d "Status=pending-verification"

Output

_27
{
_27
"status": "pending-verification",
_27
"date_updated": "2018-01-21T22:31:43Z",
_27
"verification_code": "310001",
_27
"incoming_phone_number_sid": "PN876a18805574a952ffb73907b24205f0",
_27
"failure_reason": "",
_27
"verification_attempts": 1,
_27
"verification_type": "phone-call",
_27
"capabilities": {
_27
"voice": false,
_27
"mms": false,
_27
"sms": true
_27
},
_27
"sid": "HR36f3f0c7c8d5d9210114fdcd8b6bcf19",
_27
"phone_number": "+18444905863",
_27
"call_delay": 0,
_27
"signing_document_sid": null,
_27
"verification_document_sid": "RI2ad9942e6daa7d8e87a154f6f675f3f8",
_27
"verification_call_sids": [
_27
"CA83f7aa47a1760188e892fe8c2ba86749"
_27
],
_27
"extension": null,
_27
"url": "https://preview.twilio.com/HostedNumbers/HostedNumberOrders/HR36f3f0c7c8d5d9210114fdcd8b6bcf19",
_27
"friendly_name": "My_Sms_Hosted_Number_Order",
_27
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27
"date_created": "2018-01-21T21:40:55Z"
_27
}


Once a number has passed the pre-validation check and is moved to the received status, the next phase will be to move the number to pending-verification where Twilio will call the number and ask for a security token. The phone call will prompt for the token four times before the call hangs up, and up to three verifications can be performed before the number moves to action-required, when a Twilio admin must be involved. If in action-required for more than 7 days, the Hosted Number Order will be marked as failed and a new Hosted Number Order will need to be created to go through the process again.

Twilio must verify that the end-user answering the phone call is the one requesting the text provisioning on the phone number. This verification step ensures that all requests are from legitimate end-users to ensure the authenticity of ownership.

To navigate pass IVRs, you can include an Extension parameter along with a w. Each 'w' character tells Twilio to wait 0.5 seconds instead of playing a digit. This lets you adjust the timing of when the digits begin playing to suit the phone system you are dialing.

For example, the extension "wwww2wwwwww5wwwwww9″ waits two seconds before sending the digit 2, followed by a three-second wait before sending the 5, and finally another three-second wait before sending a 9. You will need to tune the extension to the IVR system to be able to programmatically verify numbers behind IVR menus.

Create new Authorization Document

create-new-authorization-document page anchor
curl

_10
$ curl -X POST https://preview.twilio.com/HostedNumbers/AuthorizationDocuments \
_10
-u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token' \
_10
-d "HostedNumberOrderSids=HR7e42fbbfb47d17baaae45d94c34ec4c3" \
_10
-d "HostedNumberOrderSids=HR18b3fc4bb26c368ceff1587ec26bf892" \
_10
-d "HostedNumberOrderSids=HR842cc9ce52ce257da378c2972f88fecc" \
_10
-d "HostedNumberOrderSids=HRc401d83d7d66901d2b65a4700457272d" \
_10
-d "AddressSid=AD1e20d20a7772e157c8ddbaba36aefef0" \
_10
-d "Email=owner@example.com" \
_10
-d "CcEmails=person1@example.com&CcEmails=person2@example.com"

Output

_13
{
_13
"status": "signing",
_13
"date_updated": "2017-10-16T23:54:59Z",
_13
"cc_emails": [
_13
"person1@example.com",
_13
"person2@example.com"
_13
],
_13
"url": "https://preview.twilio.com/HostedNumbers/AuthorizationDocuments/PX5b7889b420ec6bca465c068f5bc2b67e",
_13
"address_sid": "AD1e20d20a7772e157c8ddbaba36aefef0",
_13
"sid": "PX5b7889b420ec6bca465c068f5bc2b67e",
_13
"date_created": "2017-10-16T23:54:58Z",
_13
"email": "owner@example.com"
_13
}


Carriers require a signed Letter of Authorization (LOA) by the authorized end user of the phone number to enable SMS capabilities. Twilio will generate this document with the address information and phone numbers you passed, to be sent for your or your customer's review and signature. To trigger the LOA email, issue a POST request to the Hosted Numbers Authorization Documents list resource with the required information. The new Authorization Document will be moved to signing, along with the Hosted Number Orders attached to the Authorization Document moving to pending-loa.

A Document SID is provided to you in the response. By performing a GET on the HostedNumberOrders endpoint, you can keep up-to-date status to track the Hosted Number Order during the signature process with the Hosted Number Order SID.

Update the Phone Number Configuration

update-the-phone-number-configuration page anchor
curl

_10
$ curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IncomingPhoneNumbers/PN9c45b3eb69d07536c60a621891420bfc.json \
_10
-d "SmsUrl=https://demo.twilio.com/welcome/sms/reply/" \
_10
-d "FriendlyName=something new"
_10
-u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'

Output

_38
{
_38
"sid": "PN9c45b3eb69d07536c60a621891420bfc",
_38
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_38
"friendly_name": "something new",
_38
"phone_number": "+18444725974",
_38
"voice_url": null,
_38
"voice_method": null,
_38
"voice_fallback_url": null,
_38
"voice_fallback_method": null,
_38
"voice_caller_id_lookup": false,
_38
"date_created": "Wed, 25 Oct 2017 22:54:16 +0000",
_38
"date_updated": "Wed, 25 Oct 2017 23:43:35 +0000",
_38
"sms_url": "https://demo.twilio.com/welcome/sms/reply/",
_38
"sms_method": null,
_38
"sms_fallback_url": null,
_38
"sms_fallback_method": null,
_38
"address_requirements": "none",
_38
"beta": false,
_38
"capabilities": {
_38
"voice": false,
_38
"sms": true,
_38
"mms": false,
_38
"fax": false
_38
},
_38
"voice_receive_mode": "voice",
_38
"status_callback": null,
_38
"status_callback_method": null,
_38
"api_version": "2010-04-01",
_38
"voice_application_sid": null,
_38
"sms_application_sid": null,
_38
"origin": "hosted",
_38
"trunk_sid": null,
_38
"emergency_status": "Inactive",
_38
"emergency_address_sid": null,
_38
"address_sid": null,
_38
"identity_sid": null,
_38
"uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IncomingPhoneNumbers/PN9c45b3eb69d07536c60a621891420bfc.json"
_38
}


You don't have to wait for the Hosted Number Order to complete in order to configure your number with an incoming SMS webhook. The Incoming Phone Numbers API provides a programmatic way to pre-configure the number with the Incoming Phone Number SID.

Release a hosted number from your active numbers

release-a-hosted-number-from-your-active-numbers page anchor

_10
$ curl -DELETE https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IncomingPhoneNumbers/PN9c45b3eb69d07536c60a621891420bfc.json \
_10
-u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token'


Remove Hosted Number from your inventory and remove Twilio's SMS Routing Profile

remove-hosted-number-from-your-inventory-and-remove-twilios-sms-routing-profile page anchor

When you no longer want to host your phone number for SMS on Twilio, you can send a DELETE request to the phone number instance on the Incoming Phone Numbers resource. The Hosted Number takes 3 days before fully retiring from our system. If you accidentally released your Hosted Number, please write to hostedsms@twilio.com to request restoration. After 3 days, Twilio will unregister the number for SMS, and the number will turn into a landline or Toll-Free with no SMS routing.

Thanks for reading! Sign up for early access here(link takes you to an external page).


Rate this page: