Managing a shopper's address
Learn how to manage addresses.
Managing a shopper's address is crucial to ensuring a smooth and efficient shopping experience. Whether adding a new address or updating an existing one, the Commerce API allows you to handle address data for individual shoppers easily. This document outlines the steps to create or update a shopper's address using the API, including necessary HTTP requests, endpoint details, and required fields.
Creating or updating a shopper's address
To manage a shopper's address, you can either create a new address or update an existing one using the Commerce API. This process involves sending a POST
request to the appropriate endpoint with the required address details and your access token. By providing a unique nickname for the address, you ensure that the system can distinguish between creating a new address and updating an existing one.
To create or update a shopper's address, send a POST /v1/shoppers/me/addresses
request and include your access token. Ensure you provide a unique nickname for the address entry. An existing address with the same nickname will be updated; otherwise, a new address will be created. See Addresses query parameters for a description of the query parameters.
The address object contains several parameters to describe the shopper's address:
nickName
(string): A unique nickname for the address entry. Ensures distinction between new and existing addresses.isDefault
(boolean): Indicates if the address is the default shipping address.firstName
(string): The first name of the shopper.lastName
(string): The last name of the shopper.companyName
(string): The name of the company, if applicable.line1
(string): The first line of the address.line2
(string): The second line of the address, if necessary.line3
(string): The third line of the address, if necessary.city
(string): The city name.countrySubdivision
(string): The subdivision of the country (e.g., state or province).postalCode
(string): The postal code.country
(string): The two-letter country code.countryName
(string): The full name of the country.countyName
(string): The county name.phoneNumber
(string): The phone number.phoneticFirstName
(string): The phonetic spelling of the first name is useful for some languages.phoneticLastName
(string): The phonetic spelling of the last name.division
(string): The division within the company, if applicable.
Here’s an example using cURL:
You will receive a 204 No Content
response.
Getting an address by identifier
To retrieve specific address information associated with a shopper, use the unique addressId
. This can be particularly useful for verifying details or making targeted updates. Follow the instructions below to send a request to Commerce API and get the desired address data.
To get an address by identifier, send a GET /v1/shoppers/me/addresses/{addressId}
request.
Include the addressId
in the endpoint URL and your access token in the request header. Here's an example cURL command:
You will receive a 200 OK
response.
Getting all shopper addresses
To efficiently manage and review all addresses associated with a shopper, the Commerce API provides an endpoint to retrieve this data. By fetching all addresses, you can ensure complete visibility over the shopper's address records, facilitating easier updates and accuracy in order processing.
To get all shopper addresses, send a GET /v1/shoppers/me/addresses
request. Include your access token in the request header. Here's an example cURL command:
Deleting a shopper's address
You may need to delete outdated or incorrect addresses to manage your shopper address list. The Commerce API lets you remove a shopper’s address by issuing a DELETE
request. This ensures your address records remain accurate and up-to-date.
To delete a shopper's address, send a DELETE /v1/shoppers/me/addresses/{addressId}
request with the address identifier (addressId
) and include your access token in the request header. Here is an example cURL command:
You will receive a 204 No Content
response.
Last updated