REST API: Addresses
An Address instance resource represents your or your customer's physical
location within a country. Around the world, some local authorities require
the name and address of the user to be on file with Twilio to purchase and own
a phone number. Address requirements are exposed as a property on the AvailablePhoneNumber resource.
Addresses contain the name of your company or your customer's
company in addition to location information and an optional friendly name. Each
Address created on an account or subaccount can be used for any phone numbers
purchased on that account. After creating an address, it can be used to satisfy
the requirements for multiple phone numbers and phone numbers with address
requirements can be purchased using the IncomingPhoneNumber resource.
In some countries, to comply with local regulations, addresses are validated to ensure the integrity and accuracy of the data provided. In those countries, if the address you provide does not pass validation, it is not accepted as an Address and the error code 21628 is returned. If the address submitted is not an exact match but is similar to a valid address, we'll create the Address using the valid address we found, unless you include the AutoCorrectAddress=false parameter in the request. In that case, we'll provide it as a suggested address in error code 21629. If the suggested address is indeed the address of your company or your customer's company, then use the suggested format to create a valid Address.
The Address list resource represents all of the Addresses that you have created
on your account within Twilio. You can POST
to Addresses to create a new
address or modify an existing address.
Property nameTypePIIDescription
The SID of the Account that is responsible for the Address resource.
Pattern: ^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The city in which the address is located.
The name associated with the address.This property has a maximum length of 16 4-byte characters, or 21 3-byte characters.
date_createdstring<date-time-rfc-2822>
date_updatedstring<date-time-rfc-2822>
The string that you assigned to describe the resource.
iso_countrystring<iso-country-code> The ISO country code of the address.
The postal code of the address.
The state or region of the address.
The unique string that that we created to identify the Address resource.
Pattern: ^AD[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The number and street address of the address.
The URI of the resource, relative to https://api.twilio.com
.
Whether emergency calling has been enabled on this number.
Whether the address has been validated to comply with local regulation. In countries that require valid addresses, an invalid address will not be accepted. true
indicates the Address has been validated. false
indicate the country doesn't require validation or the Address is not valid.
Whether the address has been verified to comply with regulation. In countries that require valid addresses, an invalid address will not be accepted. true
indicates the Address has been verified. false
indicate the country doesn't require verified or the Address is not valid.
The additional number and street address of the address.
POST https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Addresses.json
Creates a new Address within your account.
Property nameTypeRequiredPIIDescription
AccountSidSID<AC>required The SID of the Account that will be responsible for the new Address resource.
Pattern: ^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Property nameTypeRequiredPIIDescription
CustomerNamestringrequired The name to associate with the new address.
The number and street address of the new address.
The city of the new address.
The state or region of the new address.
The postal code of the new address.
IsoCountrystring<iso-country-code>required The ISO country code of the new address.
FriendlyNamestringOptional A descriptive string that you create to describe the new address. It can be up to 64 characters long.
EmergencyEnabledbooleanOptional Whether to enable emergency calling on the new address. Can be: true
or false
.
AutoCorrectAddressbooleanOptional Whether we should automatically correct the address. Can be: true
or false
and the default is true
. If empty or true
, we will correct the address you provide if necessary. If false
, we won't alter the address you provide.
StreetSecondarystringOptional The additional number and street address of the address.
_24// Download the helper library from https://www.twilio.com/docs/node/install
_24const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_24// Find your Account SID and Auth Token at twilio.com/console
_24// and set the environment variables. See http://twil.io/secure
_24const accountSid = process.env.TWILIO_ACCOUNT_SID;
_24const authToken = process.env.TWILIO_AUTH_TOKEN;
_24const client = twilio(accountSid, authToken);
_24async function createAddress() {
_24 const address = await client.addresses.create({
_24 customerName: "customer_name",
_24 postalCode: "postal_code",
_24 streetSecondary: "street_secondary",
_24 console.log(address.accountSid);
_18 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18 "customer_name": "customer_name",
_18 "date_created": "Tue, 18 Aug 2015 17:07:30 +0000",
_18 "date_updated": "Tue, 18 Aug 2015 17:07:30 +0000",
_18 "emergency_enabled": false,
_18 "friendly_name": null,
_18 "postal_code": "postal_code",
_18 "sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_18 "street_secondary": "street_secondary",
_18 "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
If successful, Twilio will respond with a representation of the new address.
Error Code | Error Name | Error Description |
---|
21615 | Phone Number Requires a Local Address | To purchase this number you must have an Address on your account that satisfies the local address requirements. |
21628 | Address Validation Error | The address you have provided cannot be validated. |
21629 | Address Validation Error - Check Suggested Address | The address you have provided cannot be validated. A similar address has been found to be valid. The suggested address is included in the error message body. |
GET https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Addresses/{Sid}.json
Property nameTypeRequiredPIIDescription
AccountSidSID<AC>required The SID of the Account that is responsible for the Address resource to fetch.
Pattern: ^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The Twilio-provided string that uniquely identifies the Address resource to fetch.
Pattern: ^AD[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
_18// Download the helper library from https://www.twilio.com/docs/node/install
_18const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18// Find your Account SID and Auth Token at twilio.com/console
_18// and set the environment variables. See http://twil.io/secure
_18const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18const authToken = process.env.TWILIO_AUTH_TOKEN;
_18const client = twilio(accountSid, authToken);
_18async function fetchAddress() {
_18 const address = await client
_18 .addresses("ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
_18 console.log(address.accountSid);
_18 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18 "customer_name": "name",
_18 "date_created": "Tue, 18 Aug 2015 17:07:30 +0000",
_18 "date_updated": "Tue, 18 Aug 2015 17:07:30 +0000",
_18 "emergency_enabled": false,
_18 "friendly_name": null,
_18 "postal_code": "94019",
_18 "sid": "ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18 "street_secondary": null,
_18 "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
GET https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Addresses.json
Returns a list of Address resource representations, each representing an
address within your account. The list includes [paging information][paging-info].
Property nameTypeRequiredPIIDescription
AccountSidSID<AC>required The SID of the Account that is responsible for the Address resource to read.
Pattern: ^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Property nameTypeRequiredPIIDescription
CustomerNamestringOptional The customer_name
of the Address resources to read.
FriendlyNamestringOptional The string that identifies the Address resources to read.
IsoCountrystring<iso-country-code>Optional The ISO country code of the Address resources to read.
How many resources to return in each list page. The default is 50, and the maximum is 1000.
Minimum: 1
Maximum: 1000
The page index. This value is simply for client state.
Minimum: 0
The page token. This is provided by the API.
_16// Download the helper library from https://www.twilio.com/docs/node/install
_16const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_16// Find your Account SID and Auth Token at twilio.com/console
_16// and set the environment variables. See http://twil.io/secure
_16const accountSid = process.env.TWILIO_ACCOUNT_SID;
_16const authToken = process.env.TWILIO_AUTH_TOKEN;
_16const client = twilio(accountSid, authToken);
_16async function listAddress() {
_16 const addresses = await client.addresses.list({ limit: 20 });
_16 addresses.forEach((a) => console.log(a.accountSid));
_33 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_33 "customer_name": "name",
_33 "date_created": "Tue, 18 Aug 2015 17:07:30 +0000",
_33 "date_updated": "Tue, 18 Aug 2015 17:07:30 +0000",
_33 "emergency_enabled": false,
_33 "friendly_name": null,
_33 "postal_code": "94019",
_33 "sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_33 "street_secondary": null,
_33 "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
_33 "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses.json?PageSize=50&Page=0",
_33 "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses.json?PageSize=50&Page=0",
_33 "next_page_uri": null,
_33 "previous_page_uri": null,
_33 "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses.json?PageSize=50&Page=0"
_19// Download the helper library from https://www.twilio.com/docs/node/install
_19const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_19// Find your Account SID and Auth Token at twilio.com/console
_19// and set the environment variables. See http://twil.io/secure
_19const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19const authToken = process.env.TWILIO_AUTH_TOKEN;
_19const client = twilio(accountSid, authToken);
_19async function listAddress() {
_19 const addresses = await client.addresses.list({
_19 customerName: "Customer 123",
_19 addresses.forEach((a) => console.log(a.accountSid));
_33 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_33 "customer_name": "name",
_33 "date_created": "Tue, 18 Aug 2015 17:07:30 +0000",
_33 "date_updated": "Tue, 18 Aug 2015 17:07:30 +0000",
_33 "emergency_enabled": false,
_33 "friendly_name": null,
_33 "postal_code": "94019",
_33 "sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_33 "street_secondary": null,
_33 "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
_33 "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses.json?PageSize=50&Page=0",
_33 "last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses.json?PageSize=50&Page=0",
_33 "next_page_uri": null,
_33 "previous_page_uri": null,
_33 "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses.json?PageSize=50&Page=0"
Show all phone numbers on your account that require the address AD2a0747eba6abf96b7e3c3ff0b4530f6e
_18// Download the helper library from https://www.twilio.com/docs/node/install
_18const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18// Find your Account SID and Auth Token at twilio.com/console
_18// and set the environment variables. See http://twil.io/secure
_18const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18const authToken = process.env.TWILIO_AUTH_TOKEN;
_18const client = twilio(accountSid, authToken);
_18async function listDependentPhoneNumber() {
_18 const dependentPhoneNumbers = await client
_18 .addresses("AD2a0747eba6abf96b7e3c3ff0b4530f6e")
_18 .dependentPhoneNumbers.list({ limit: 20 });
_18 dependentPhoneNumbers.forEach((d) => console.log(d.sid));
_18listDependentPhoneNumber();
_42 "dependent_phone_numbers": [
_42 "sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_42 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_42 "friendly_name": "3197004499318",
_42 "phone_number": "+3197004499318",
_42 "voice_method": "POST",
_42 "voice_fallback_url": null,
_42 "voice_fallback_method": "POST",
_42 "voice_caller_id_lookup": false,
_42 "date_created": "Thu, 23 Feb 2017 10:26:31 -0800",
_42 "date_updated": "Thu, 23 Feb 2017 10:26:31 -0800",
_42 "sms_method": "POST",
_42 "sms_fallback_url": "",
_42 "sms_fallback_method": "POST",
_42 "address_requirements": "any",
_42 "status_callback": "",
_42 "status_callback_method": "POST",
_42 "api_version": "2010-04-01",
_42 "voice_application_sid": null,
_42 "sms_application_sid": "",
_42 "emergency_status": "Inactive",
_42 "emergency_address_sid": null,
_42 "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
_42 "first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/DependentPhoneNumbers.json?Page=0&PageSize=50",
_42 "next_page_uri": null,
_42 "previous_page_uri": null,
_42 "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/DependentPhoneNumbers.json"
_10GET https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Addresses/{AddressSid}/DependentPhoneNumbers.json
Returns a list of IncomingPhoneNumbers on your account that require the
specified address.
Each Address instance resource supports a subresource for viewing which phone
numbers are dependent on your existing addresses. In the case that you have two
addresses that satisfy the requirement on a given phone number, this
subresource will not return the phone number in the list.
The list includes paging information. If you plan on requesting more records
than will fit on a single page, you should use the provided nextpageuri rather
than incrementing through the pages by page number. Using the nextpageuri helps
to ensure that your next request picks up where it left off and can prevent you
from retrieving duplicate data if you are actively creating addresses.
POST https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Addresses/{Sid}.json
A POST
request attempts to update an individual Address instance and returns
the updated resource representation if successful. A successful returned
response is identical to that of the HTTP GET
.
Note that all fields but IsoCountry
can be updated using a POST
request.
To update the IsoCountry
, a new Address must be created.
Property nameTypeRequiredPIIDescription
AccountSidSID<AC>required The SID of the Account that is responsible for the Address resource to update.
Pattern: ^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The Twilio-provided string that uniquely identifies the Address resource to update.
Pattern: ^AD[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Property nameTypeRequiredPIIDescription
FriendlyNamestringOptional A descriptive string that you create to describe the address. It can be up to 64 characters long.
CustomerNamestringOptional The name to associate with the address.
The number and street address of the address.
The state or region of the address.
The postal code of the address.
EmergencyEnabledbooleanOptional Whether to enable emergency calling on the address. Can be: true
or false
.
AutoCorrectAddressbooleanOptional Whether we should automatically correct the address. Can be: true
or false
and the default is true
. If empty or true
, we will correct the address you provide if necessary. If false
, we won't alter the address you provide.
StreetSecondarystringOptional The additional number and street address of the address.
Update the customer name and street to ‘Customer 456' and ‘2 Hasselhoff Lane'.
_21// Download the helper library from https://www.twilio.com/docs/node/install
_21const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_21// Find your Account SID and Auth Token at twilio.com/console
_21// and set the environment variables. See http://twil.io/secure
_21const accountSid = process.env.TWILIO_ACCOUNT_SID;
_21const authToken = process.env.TWILIO_AUTH_TOKEN;
_21const client = twilio(accountSid, authToken);
_21async function updateAddress() {
_21 const address = await client
_21 .addresses("AD2a0747eba6abf96b7e3c3ff0b4530f6e")
_21 customerName: "Customer 456",
_21 street: "2 Hasselhoff Lane",
_21 console.log(address.accountSid);
_18 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18 "customer_name": "Customer 456",
_18 "date_created": "Tue, 18 Aug 2015 17:07:30 +0000",
_18 "date_updated": "Tue, 18 Aug 2015 17:07:30 +0000",
_18 "emergency_enabled": false,
_18 "friendly_name": null,
_18 "postal_code": "94019",
_18 "sid": "AD2a0747eba6abf96b7e3c3ff0b4530f6e",
_18 "street": "2 Hasselhoff Lane",
_18 "street_secondary": null,
_18 "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
DELETE https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Addresses/{Sid}.json
Deletes this address from your account.
If this address is required for any active IncomingPhoneNumbers, it cannot be
deleted and you will receive Error [21625][21625]. However, if you have a
second address that fulfills the AddressRequirement, the address will be
successfully deleted. The DependentPhoneNumbers Instance Subresource will allow
you to see which IncomingPhoneNumbers require a given address.
If the delete is successful, Twilio will return an HTTP 204 response with no
body.
Property nameTypeRequiredPIIDescription
AccountSidSID<AC>required The SID of the Account that is responsible for the Address resource to delete.
Pattern: ^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The Twilio-provided string that uniquely identifies the Address resource to delete.
Pattern: ^AD[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
_14// Download the helper library from https://www.twilio.com/docs/node/install
_14const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_14// Find your Account SID and Auth Token at twilio.com/console
_14// and set the environment variables. See http://twil.io/secure
_14const accountSid = process.env.TWILIO_ACCOUNT_SID;
_14const authToken = process.env.TWILIO_AUTH_TOKEN;
_14const client = twilio(accountSid, authToken);
_14async function deleteAddress() {
_14 await client.addresses("ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").remove();