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 regulation, 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 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
Resource Properties in REST API format | |
---|---|
account_sid
|
The SID of the Account that is responsible for the Address resource. |
city
|
The city in which the address is located. |
customer_name
|
The name associated with the address.This property has a maximum length of 16 4-byte characters, or 21 3-byte characters. |
date_created
|
The date and time in GMT that the resource was created specified in RFC 2822 format. |
date_updated
|
The date and time in GMT that the resource was last updated specified in RFC 2822 format. |
friendly_name
|
The string that you assigned to describe the resource. |
iso_country
|
The ISO country code of the address. |
postal_code
|
The postal code of the address. |
region
|
The state or region of the address. |
sid
|
The unique string that that we created to identify the Address resource. |
street
|
The number and street address of the address. |
uri
|
The URI of the resource, relative to |
emergency_enabled
|
Whether emergency calling has been enabled on this number. |
validated
|
Whether the address has been validated to comply with local regulation. In countries that require valid addresses, an invalid address will not be accepted. |
verified
|
Whether the address has been verified to comply with regulation. In countries that require valid addresses, an invalid address will not be accepted. |
street_secondary
|
The additional number and street address of the address. |
Create an Address resource
https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Addresses.json
Creates a new Address within your account.
Parameters
Parameters in REST API format | |
---|---|
account_sid
Path
|
The SID of the Account that will be responsible for the new Address resource. |
customer_name
Required
|
The name to associate with the new address. |
street
Required
|
The number and street address of the new address. |
city
Required
|
The city of the new address. |
region
Required
|
The state or region of the new address. |
postal_code
Required
|
The postal code of the new address. |
iso_country
Required
|
The ISO country code of the new address. |
friendly_name
Optional
|
A descriptive string that you create to describe the new address. It can be up to 64 characters long. |
emergency_enabled
Optional
|
Whether to enable emergency calling on the new address. Can be: |
auto_correct_address
Optional
|
Whether we should automatically correct the address. Can be: |
street_secondary
Optional
|
The additional number and street address of the address. |
Example 1
If successful, Twilio will respond with a representation of the new address.
Address Validation Related Errors
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 which 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. |
Fetch an Address resource
https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Addresses/{Sid}.json
Parameters
Parameters in REST API format | |
---|---|
account_sid
Path
|
The SID of the Account that is responsible for the Address resource to fetch. |
sid
Path
|
The Twilio-provided string that uniquely identifies the Address resource to fetch. |
Example 1
Read multiple Address resources
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].
Parameters
Parameters in REST API format | |
---|---|
account_sid
Path
|
The SID of the Account that is responsible for the Address resource to read. |
customer_name
Optional
|
The |
friendly_name
Optional
|
The string that identifies the Address resources to read. |
iso_country
Optional
|
The ISO country code of the Address resources to read. |
Example 1
Example 2
Example 3
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
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 which satisfy the requirement on a given phone number, this subresource will not return the phone number in the list.
Paging
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
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 that all fields but IsoCountry
can be updated using a POST request.
To update the IsoCountry
, a new Address must be created.
Parameters
Parameters in REST API format | |
---|---|
account_sid
Path
|
The SID of the Account that is responsible for the Address resource to update. |
sid
Path
|
The Twilio-provided string that uniquely identifies the Address resource to update. |
friendly_name
Optional
|
A descriptive string that you create to describe the address. It can be up to 64 characters long. |
customer_name
Optional
|
The name to associate with the address. |
street
Optional
|
The number and street address of the address. |
city
Optional
|
The city of the address. |
region
Optional
|
The state or region of the address. |
postal_code
Optional
|
The postal code of the address. |
emergency_enabled
Optional
|
Whether to enable emergency calling on the address. Can be: |
auto_correct_address
Optional
|
Whether we should automatically correct the address. Can be: |
street_secondary
Optional
|
The additional number and street address of the address. |
Example 1
Delete an Address resource
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.
Parameters
Parameters in REST API format | |
---|---|
account_sid
Path
|
The SID of the Account that is responsible for the Address resource to delete. |
sid
Path
|
The Twilio-provided string that uniquely identifies the Address resource to delete. |
Example 1
Need some help?
We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.