Skip to main content

Customer Address

Version: 1.0

A customer address resource instance represents one of the many addresses a customer may have

For more information about Customers, see the Customer API Documentation

What can you do with CustomerAddress?

The haravan API lets you do the following with the CustomerAddress resource. More detailed versions of these general actions may be available:

CustomerAddress Properties


address1 : string

"address1": "1 Rue des Carrieres"

address2 : string

"address2": "Suite 1234"

city : string

"city": "Montreal"

company : string

"company": "Fancy Co."

Company name associated with address (optional)

first_name : string

"first_name": "Samuel"

last_name : string

"last_name": "de Champlain"

phone : string

"phone": "819-555-5555"

province : string

"province": "province"

country : string

"country": "Canada"

zip : string

"zip": "G1R 4P5"

name : string

"name": "Samuel de Champlain"

province_code : string

"province_code": "QC"

country_code : string

"country_code": "CA"

Country Code in ISO 3166-1 (alpha-2) format. See Current ISO Codes

country_name : string

"country_name": "Canada"

Receive a list of all CustomerAddresses.

GET
/com/customers/#{id}/addresses.json

Retrieve all addresses for a customer


page

Page to show(default: 1)


limit

Amount of results(default: 50) (maximum: 250)


Get all of a customers addresses

  • GET /com/customers/207119551/addresses.json

Response:

Details
HTTP/1.1 200 OK
{
"addresses": [
{
"address1": "Chestnut Street 92",
"address2": "",
"city": "Louisville",
"company": null,
"country": "United States",
"first_name": null,
"id": 207119551,
"last_name": null,
"phone": "555-625-1199",
"province": "Kentucky",
"zip": "40202",
"name": "",
"province_code": "KY",
"country_code": "US",
"country_name": "United States",
"default": true
}
]
}

Get a limited number of addresses for a customer

  • GET /com/customers/207119551/addresses.json?limit=1&page=1

Response:

Details
HTTP/1.1 200 OK
{
"addresses": [
{
"address1": "Chestnut Street 92",
"address2": "",
"city": "Louisville",
"company": null,
"country": "United States",
"first_name": null,
"id": 207119551,
"last_name": null,
"phone": "555-625-1199",
"province": "Kentucky",
"zip": "40202",
"name": "",
"province_code": "KY",
"country_code": "US",
"country_name": "United States",
"default": true
}
]
}

Receive a single CustomerAddress.

GET
/com/customers/#{id}/addresses/#{id}.json

Retrieve details for one of a customers addresses

  • GET /com/customers/207119551/addresses/207119551.json

Response:

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

Create a new CustomerAddress.

POST
/com/customers/#{id}/addresses.json

Creating a new address for a customer

  • POST /com/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:

Details
HTTP/1.1 201 Created
{
"customer_address": {
"address1": "1 Rue des Carrieres",
"address2": "Suite 1234",
"city": "Montreal",
"company": "Fancy Co.",
"country": "Canada",
"first_name": "Samuel",
"id": 1053317286,
"last_name": "de Champlain",
"phone": "819-555-5555",
"province": "Quebec",
"zip": "G1R 4P5",
"name": "Samuel de Champlain",
"province_code": "QC",
"country_code": "CA",
"country_name": "Canada",
"default": false
}
}

Modify an existing CustomerAddress.

PUT
/com/customers/#{id}/addresses/#{id}.json

Updating a customers postal code

  • PUT /com/customers/207119551/addresses/207119551.json
{
"address": {
"id": 207119551,
"zip": "H0H 0H0"
}
}
Details
HTTP/1.1 200 OK
{
"customer_address": {
"address1": "Chestnut Street 92",
"address2": "",
"city": "Louisville",
"company": null,
"country": "United States",
"first_name": null,
"id": 207119551,
"last_name": null,
"phone": "555-625-1199",
"province": "Kentucky",
"zip": "H0H 0H0",
"name": "",
"province_code": "KY",
"country_code": "US",
"country_name": "United States",
"default": true
}
}

Remove a CustomerAddress from the database.

DELETE
/com/customers/#{id}/addresses/#{id}.json

Removes an address from the customers address list

Removing a customers address

  • DELETE /com/customers/207119551/addresses/1053317288.json

Response:

Details
HTTP/1.1 200 OK
{}

Trying to remove a customers default address results in a failure

  • DELETE /com/customers/207119551/addresses/1053317288.json

Response:

Details
HTTP/1.1 422 Unprocessable Entity
{
"errors": {
"base": [
"Cannot delete the customers default address"
]
}
}

Perform bulk operations against a number of addresses.

PUT
/com/customers/#{id}/addresses/set.json

Destroying multiple customer addresses

  • PUT /com/customers/207119551/addresses/set.json?address_ids[]=1053317289&operation=destroy

Response:

Details
HTTP/1.1 200 OK
{}

Sets default address for a customer.

PUT
/com/customers/#{id}/addresses/#{id}/default.json

Assigning a new default address to a customer

  • PUT /com/customers/207119551/addresses/1053317287/default.json

Response:

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