Skip to contentSkip to navigationSkip to topbar
On this page

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.


Address Properties

address-properties page anchor
Property nameTypeRequiredDescriptionChild properties
account_sidSID<AC>

Optional

Not PII

The SID of the Account that is responsible for the Address resource.

Pattern: ^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34

citystring

Optional

The city in which the address is located.


customer_namestring

Optional

PII MTL: 30 days

The name associated with the address.This property has a maximum length of 16 4-byte characters, or 21 3-byte characters.


date_updatedstring<date-time-rfc-2822>

Optional

The date and time in GMT that the resource was last updated specified in RFC 2822(link takes you to an external page) format.


friendly_namestring

Optional

The string that you assigned to describe the resource.


iso_countrystring<iso-country-code>

Optional

The ISO country code of the address.


postal_codestring

Optional

The postal code of the address.


regionstring

Optional

The state or region of the address.


sidSID<AD>

Optional

The unique string that that we created to identify the Address resource.

Pattern: ^AD[0-9a-fA-F]{32}$Min length: 34Max length: 34

streetstring

Optional

The number and street address of the address.


uristring

Optional

The URI of the resource, relative to https://api.twilio.com.


emergency_enabledboolean

Optional

Whether emergency calling has been enabled on this number.


validatedboolean

Optional

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.


verifiedboolean

Optional

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.


street_secondarystring

Optional

The additional number and street address of the address.


Create an Address resource

create-an-address-resource page anchor
POST https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Addresses.json

Creates a new Address within your account.

Path parameters

path-parameters page anchor
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: 34Max length: 34
Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
CustomerNamestringrequired

The name to associate with the new address.


Streetstringrequired

The number and street address of the new address.


Citystringrequired

The city of the new address.


Regionstringrequired

The state or region of the new address.


PostalCodestringrequired

The postal code of the new address.


IsoCountrystring<iso-country-code>required

The ISO country code of the new address.


FriendlyNamestring

Optional

A descriptive string that you create to describe the new address. It can be up to 64 characters long.


EmergencyEnabledboolean

Optional

Whether to enable emergency calling on the new address. Can be: true or false.


AutoCorrectAddressboolean

Optional

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.


StreetSecondarystring

Optional

The additional number and street address of the address.

Create an AddressLink to code sample: Create an Address
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function createAddress() {
11
const address = await client.addresses.create({
12
city: "city",
13
customerName: "customer_name",
14
isoCountry: "US",
15
postalCode: "postal_code",
16
region: "region",
17
street: "street",
18
streetSecondary: "street_secondary",
19
});
20
21
console.log(address.accountSid);
22
}
23
24
createAddress();

Output

1
{
2
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
3
"city": "city",
4
"customer_name": "customer_name",
5
"date_created": "Tue, 18 Aug 2015 17:07:30 +0000",
6
"date_updated": "Tue, 18 Aug 2015 17:07:30 +0000",
7
"emergency_enabled": false,
8
"friendly_name": null,
9
"iso_country": "US",
10
"postal_code": "postal_code",
11
"region": "region",
12
"sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
13
"street": "street",
14
"street_secondary": "street_secondary",
15
"validated": false,
16
"verified": false,
17
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
18
}

If successful, Twilio will respond with a representation of the new address.

Address Validation Related Errors

av-errors page anchor
Error CodeError NameError Description
21615Phone Number Requires a Local AddressTo purchase this number you must have an Address on your account that satisfies the local address requirements.
21628Address Validation ErrorThe address you have provided cannot be validated.
21629Address Validation Error - Check Suggested AddressThe 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.

Fetch an Address resource

fetch-an-address-resource page anchor
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: 34Max length: 34

SidSID<AD>required

The Twilio-provided string that uniquely identifies the Address resource to fetch.

Pattern: ^AD[0-9a-fA-F]{32}$Min length: 34Max length: 34
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function fetchAddress() {
11
const address = await client
12
.addresses("ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
13
.fetch();
14
15
console.log(address.accountSid);
16
}
17
18
fetchAddress();

Output

1
{
2
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
3
"city": "SF",
4
"customer_name": "name",
5
"date_created": "Tue, 18 Aug 2015 17:07:30 +0000",
6
"date_updated": "Tue, 18 Aug 2015 17:07:30 +0000",
7
"emergency_enabled": false,
8
"friendly_name": null,
9
"iso_country": "US",
10
"postal_code": "94019",
11
"region": "CA",
12
"sid": "ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
13
"street": "4th",
14
"street_secondary": null,
15
"validated": false,
16
"verified": false,
17
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
18
}

Read multiple Address resources

read-multiple-address-resources page anchor
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: 34Max length: 34
Property nameTypeRequiredPIIDescription
CustomerNamestring

Optional

The customer_name of the Address resources to read.


FriendlyNamestring

Optional

The string that identifies the Address resources to read.


IsoCountrystring<iso-country-code>

Optional

The ISO country code of the Address resources to read.


PageSizeinteger

Optional

How many resources to return in each list page. The default is 50, and the maximum is 1000.

Minimum: 1Maximum: 1000

Pageinteger

Optional

The page index. This value is simply for client state.

Minimum: 0

PageTokenstring

Optional

The page token. This is provided by the API.

1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function listAddress() {
11
const addresses = await client.addresses.list({ limit: 20 });
12
13
addresses.forEach((a) => console.log(a.accountSid));
14
}
15
16
listAddress();

Output

1
{
2
"addresses": [
3
{
4
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
5
"city": "SF",
6
"customer_name": "name",
7
"date_created": "Tue, 18 Aug 2015 17:07:30 +0000",
8
"date_updated": "Tue, 18 Aug 2015 17:07:30 +0000",
9
"emergency_enabled": false,
10
"friendly_name": null,
11
"iso_country": "US",
12
"postal_code": "94019",
13
"region": "CA",
14
"sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
15
"street": "4th",
16
"street_secondary": null,
17
"validated": false,
18
"verified": false,
19
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
20
}
21
],
22
"end": 0,
23
"first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses.json?PageSize=50&Page=0",
24
"last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses.json?PageSize=50&Page=0",
25
"next_page_uri": null,
26
"num_pages": 1,
27
"page": 0,
28
"page_size": 50,
29
"previous_page_uri": null,
30
"start": 0,
31
"total": 1,
32
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses.json?PageSize=50&Page=0"
33
}
Show all addresses matching the Customer Name 'Customer 123'Link to code sample: Show all addresses matching the Customer Name 'Customer 123'
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function listAddress() {
11
const addresses = await client.addresses.list({
12
customerName: "Customer 123",
13
limit: 20,
14
});
15
16
addresses.forEach((a) => console.log(a.accountSid));
17
}
18
19
listAddress();

Output

1
{
2
"addresses": [
3
{
4
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
5
"city": "SF",
6
"customer_name": "name",
7
"date_created": "Tue, 18 Aug 2015 17:07:30 +0000",
8
"date_updated": "Tue, 18 Aug 2015 17:07:30 +0000",
9
"emergency_enabled": false,
10
"friendly_name": null,
11
"iso_country": "US",
12
"postal_code": "94019",
13
"region": "CA",
14
"sid": "ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
15
"street": "4th",
16
"street_secondary": null,
17
"validated": false,
18
"verified": false,
19
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
20
}
21
],
22
"end": 0,
23
"first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses.json?PageSize=50&Page=0",
24
"last_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses.json?PageSize=50&Page=0",
25
"next_page_uri": null,
26
"num_pages": 1,
27
"page": 0,
28
"page_size": 50,
29
"previous_page_uri": null,
30
"start": 0,
31
"total": 1,
32
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses.json?PageSize=50&Page=0"
33
}
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function listDependentPhoneNumber() {
11
const dependentPhoneNumbers = await client
12
.addresses("AD2a0747eba6abf96b7e3c3ff0b4530f6e")
13
.dependentPhoneNumbers.list({ limit: 20 });
14
15
dependentPhoneNumbers.forEach((d) => console.log(d.sid));
16
}
17
18
listDependentPhoneNumber();

Output

1
{
2
"dependent_phone_numbers": [
3
{
4
"sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
5
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
6
"friendly_name": "3197004499318",
7
"phone_number": "+3197004499318",
8
"voice_url": null,
9
"voice_method": "POST",
10
"voice_fallback_url": null,
11
"voice_fallback_method": "POST",
12
"voice_caller_id_lookup": false,
13
"date_created": "Thu, 23 Feb 2017 10:26:31 -0800",
14
"date_updated": "Thu, 23 Feb 2017 10:26:31 -0800",
15
"sms_url": "",
16
"sms_method": "POST",
17
"sms_fallback_url": "",
18
"sms_fallback_method": "POST",
19
"address_requirements": "any",
20
"capabilities": {
21
"Voice": false,
22
"SMS": true,
23
"MMS": false
24
},
25
"status_callback": "",
26
"status_callback_method": "POST",
27
"api_version": "2010-04-01",
28
"voice_application_sid": null,
29
"sms_application_sid": "",
30
"trunk_sid": null,
31
"emergency_status": "Inactive",
32
"emergency_address_sid": null,
33
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IncomingPhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
34
}
35
],
36
"first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/DependentPhoneNumbers.json?Page=0&PageSize=50",
37
"next_page_uri": null,
38
"page": 0,
39
"page_size": 50,
40
"previous_page_uri": null,
41
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/DependentPhoneNumbers.json"
42
}

Read multiple Address Subresources

instance-subresources page anchor
GET 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.

Dependent Phone Numbers Instance Subresource

list-dependent-pns page anchor

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.

Paging

paging page anchor

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.


Update an Address resource

update-an-address-resource page anchor
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: 34Max length: 34

SidSID<AD>required

The Twilio-provided string that uniquely identifies the Address resource to update.

Pattern: ^AD[0-9a-fA-F]{32}$Min length: 34Max length: 34
Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
FriendlyNamestring

Optional

A descriptive string that you create to describe the address. It can be up to 64 characters long.


CustomerNamestring

Optional

The name to associate with the address.


Streetstring

Optional

The number and street address of the address.


Citystring

Optional

The city of the address.


Regionstring

Optional

The state or region of the address.


PostalCodestring

Optional

The postal code of the address.


EmergencyEnabledboolean

Optional

Whether to enable emergency calling on the address. Can be: true or false.


AutoCorrectAddressboolean

Optional

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.


StreetSecondarystring

Optional

The additional number and street address of the address.

1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function updateAddress() {
11
const address = await client
12
.addresses("AD2a0747eba6abf96b7e3c3ff0b4530f6e")
13
.update({
14
customerName: "Customer 456",
15
street: "2 Hasselhoff Lane",
16
});
17
18
console.log(address.accountSid);
19
}
20
21
updateAddress();

Output

1
{
2
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
3
"city": "SF",
4
"customer_name": "Customer 456",
5
"date_created": "Tue, 18 Aug 2015 17:07:30 +0000",
6
"date_updated": "Tue, 18 Aug 2015 17:07:30 +0000",
7
"emergency_enabled": false,
8
"friendly_name": null,
9
"iso_country": "US",
10
"postal_code": "94019",
11
"region": "CA",
12
"sid": "AD2a0747eba6abf96b7e3c3ff0b4530f6e",
13
"street": "2 Hasselhoff Lane",
14
"street_secondary": null,
15
"validated": false,
16
"verified": false,
17
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Addresses/ADaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
18
}

Delete an Address resource

delete-an-address-resource page anchor
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: 34Max length: 34

SidSID<AD>required

The Twilio-provided string that uniquely identifies the Address resource to delete.

Pattern: ^AD[0-9a-fA-F]{32}$Min length: 34Max length: 34
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function deleteAddress() {
11
await client.addresses("ADXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").remove();
12
}
13
14
deleteAddress();

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.