# Customer Address

        <p>The Customer Address resource represents addresses that a customer has added. Each customer can have multiple addresses associated with them.</p>
        <p>For more information about the Customer resource, see <a href="/docs/admin-api/rest/reference/customers/customer"><i>Customer</i></a>.</p>

## Resource Properties

### Customer Address

* address1: The customer's mailing address
  * Type: x-string
  * Example: "1 Rue des Carrieres"
* address2: An additional field for the customer's mailing address.
  * Type: x-string
  * Example: "Suite 1234"
* city: The customer's city, town, or village.
  * Type: x-string
  * Example: "Montreal"
* country: The customer's country.
  * Type: x-string
  * Example: "Canada"
* country_code: The two-letter country code corresponding to the customer's country.
  * Type: x-string
  * Example: "CA"
* country_name: The customer’s normalized country name.
  * Type: x-string
  * Example: "Canada"
* company: The customer’s company.
  * Type: x-string
  * Example: "Fancy Co."
* customer_id: The unique identifier for the customer.
  * Type: x-string
  * Example: {"id"=>1073339470}
* first_name: The customer’s first name.
  * Type: x-string
  * Example: "Samuel"
* id: The unique identifier for the address.
  * Type: x-string
  * Example: 207119551
* last_name: The customer’s last name.
  * Type: x-string
  * Example: "de Champlain"
* name: The customer’s first and last names.
  * Type: x-string
  * Example: "Samuel de Champlain"
* phone: The customer’s phone number at this address.
  * Type: x-string
  * Example: "819-555-5555"
* province: The customer’s region name. Typically a province, a state, or a prefecture.
  * Type: x-string
  * Example: "Quebec"
* province_code: The alphanumeric code for the customer’s region.
  * Type: x-string
  * Example: "QC"
* zip: The customer’s postal code, also known as zip, postcode, Eircode, etc.
  * Type: x-string
  * Example: "G1R 4P5"
## Retrieves a list of addresses for a customer

Retrieves a list of addresses for a customer. <strong>Note:</strong> This endpoint implements pagination by using links that are provided in the response header. To learn more, refer to <a href='/api/usage/pagination-rest'>Make paginated requests to the REST Admin API</a>.

### Endpoint
/admin/api/#{api_version}/customers/{customer_id}/addresses.json?limit=1 (GET)

### Parameters
* api_version (required): 
* customer_id (required): 

### Responses
#### 200
Retrieves a list of addresses for a customer

Examples:
##### Retrieve a limited number of addresses for a customer
Request:
```
GET /admin/api/unstable/customers/207119551/addresses.json
```

Response:
```
HTTP/1.1 200 OK
{"addresses":[{"id":207119551,"customer_id":207119551,"first_name":null,"last_name":null,"company":null,"address1":"Chestnut Street 92","address2":"","city":"Louisville","province":"Kentucky","country":"United States","zip":"40202","phone":"555-625-1199","name":"","province_code":"KY","country_code":"US","country_name":"United States","default":true}]}
```
##### Retrieve all of a customer’s addresses
Request:
```
GET /admin/api/unstable/customers/207119551/addresses.json
```

Response:
```
HTTP/1.1 200 OK
{"addresses":[{"id":207119551,"customer_id":207119551,"first_name":null,"last_name":null,"company":null,"address1":"Chestnut Street 92","address2":"","city":"Louisville","province":"Kentucky","country":"United States","zip":"40202","phone":"555-625-1199","name":"","province_code":"KY","country_code":"US","country_name":"United States","default":true}]}
```
## Retrieves details for a single customer address

Retrieves details for a single customer address.

### Endpoint
/admin/api/#{api_version}/customers/{customer_id}/addresses/{address_id}.json (GET)

### Parameters
* address_id (required): 
* api_version (required): 
* customer_id (required): 

### Responses
#### 200
Retrieves details for a single customer address

Examples:
##### Retrieve a single customer address
Request:
```
GET /admin/api/unstable/customers/207119551/addresses/207119551.json
```

Response:
```
HTTP/1.1 200 OK
{"customer_address":{"id":207119551,"customer_id":207119551,"first_name":null,"last_name":null,"company":null,"address1":"Chestnut Street 92","address2":"","city":"Louisville","province":"Kentucky","country":"United States","zip":"40202","phone":"555-625-1199","name":"","province_code":"KY","country_code":"US","country_name":"United States","default":true}}
```
## Updates an existing customer address

Updates an existing customer address.

### Endpoint
/admin/api/#{api_version}/customers/{customer_id}/addresses/{address_id}.json (PUT)

### Parameters
* address_id (required): 
* api_version (required): 
* customer_id (required): 

### Responses
#### 200
Updates an existing customer address

Examples:
##### Update the postal code of a customer address
Request:
```
PUT /admin/api/unstable/customers/207119551/addresses/207119551.json
{"address":{"id":207119551,"zip":"90210"}}
```

Response:
```
HTTP/1.1 200 OK
{"customer_address":{"customer_id":207119551,"zip":"90210","country":"United States","province":"Kentucky","city":"Louisville","address1":"Chestnut Street 92","address2":"","first_name":null,"last_name":null,"company":null,"phone":"555-625-1199","id":207119551,"name":"","province_code":"KY","country_code":"US","country_name":"United States","default":true}}
```
##### Update the street address of a customer address
Request:
```
PUT /admin/api/unstable/customers/207119551/addresses/207119551.json
{"address":{"id":207119551,"address1":"Apartment 23","address2":"Chestnut Street 92"}}
```

Response:
```
HTTP/1.1 200 OK
{"customer_address":{"customer_id":207119551,"address1":"Apartment 23","address2":"Chestnut Street 92","country":"United States","province":"Kentucky","zip":"40202","city":"Louisville","first_name":null,"last_name":null,"company":null,"phone":"555-625-1199","id":207119551,"name":"","province_code":"KY","country_code":"US","country_name":"United States","default":true}}
```
## Removes an address from a customer’s address list

Removes an address from a customer’s address list.

### Endpoint
/admin/api/#{api_version}/customers/{customer_id}/addresses/{address_id}.json (DELETE)

### Parameters
* address_id (required): 
* api_version (required): 
* customer_id (required): 

### Responses
#### 200
Removes an address from a customer’s address list

Examples:
##### Remove a customer address
Request:
```
DELETE /admin/api/unstable/customers/207119551/addresses/1053317310.json
```

Response:
```
HTTP/1.1 200 OK
{}
```
#### 422
Removes an address from a customer’s address list

Examples:
##### Removing a customer’s default address fails and returns an error
Request:
```
DELETE /admin/api/unstable/customers/207119551/addresses/207119551.json
```

Response:
```
HTTP/1.1 422 Unprocessable Entity
{"errors":{"base":["Cannot delete the customer’s default address"]}}
```
## Creates a new address for a customer

Creates a new address for a customer.

### Endpoint
/admin/api/#{api_version}/customers/{customer_id}/addresses.json (POST)

### Parameters
* api_version (required): 
* customer_id (required): 

### Responses
#### 201
Creates a new address for a customer

Examples:
##### Create a new address for a customer
Request:
```
POST /admin/api/unstable/customers/207119551/addresses.json
{"address":{"address1":"1 Rue des Carrieres","address2":"Suite 1234","city":"Montreal","company":"Fancy Co.","first_name":"Samuel","last_name":"de Champlain","phone":"819-555-5555","province":"Quebec","country":"Canada","zip":"G1R 4P5","name":"Samuel de Champlain","province_code":"QC","country_code":"CA","country_name":"Canada"}}
```

Response:
```
HTTP/1.1 201 Created
{"customer_address":{"id":1053317309,"customer_id":207119551,"first_name":"Samuel","last_name":"de Champlain","company":"Fancy Co.","address1":"1 Rue des Carrieres","address2":"Suite 1234","city":"Montreal","province":"Quebec","country":"Canada","zip":"G1R 4P5","phone":"819-555-5555","name":"Samuel de Champlain","province_code":"QC","country_code":"CA","country_name":"Canada","default":false}}
```
## Performs bulk operations for multiple customer addresses

Performs bulk operations for multiple customer addresses.

### Endpoint
/admin/api/#{api_version}/customers/{customer_id}/addresses/set.json?address_ids[]=1053317311&operation=destroy (PUT)

### Parameters
* address_ids[] (required): Performs bulk operations on a list of customer address IDs. Format: <code>address_ids[]=1&amp;address_ids[]=2&amp;address_ids[]=3</code>.
* api_version (required): 
* customer_id (required): 
* operation (required): Operation to perform by keyword (for example, destroy)

### Responses
#### 200
Performs bulk operations for multiple customer addresses

Examples:
##### Destroy multiple customer addresses
Request:
```
PUT /admin/api/unstable/customers/207119551/addresses/set.json
```

Response:
```
HTTP/1.1 200 OK
{}
```
## Sets the default address for a customer

Sets the default address for a customer.

### Endpoint
/admin/api/#{api_version}/customers/{customer_id}/addresses/{address_id}/default.json (PUT)

### Parameters
* address_id (required): 
* api_version (required): 
* customer_id (required): 

### Responses
#### 200
Sets the default address for a customer

Examples:
##### Set a default address for a customer
Request:
```
PUT /admin/api/unstable/customers/207119551/addresses/1053317312/default.json
```

Response:
```
HTTP/1.1 200 OK
{"customer_address":{"id":1053317312,"customer_id":207119551,"first_name":"Bob","last_name":"Norman","company":null,"address1":"Chestnut Street 92","address2":"","city":"Louisville","province":"Kentucky","country":"United States","zip":"40202","phone":"555-625-1199","name":"Bob Norman","province_code":"KY","country_code":"US","country_name":"United States","default":true}}
```