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:

curl --location --request POST 'https://api.digitalriver.com/v1/shoppers/me/addresses' \
--header 'authorization: bearer [Your_Access_Token]'\
...
--data-raw '{
  "address": {
    "nickName": "test",
    "isDefault": "true",
    "firstName": "Jon",
    "lastName": "Doe",
    "companyName": "Digital River",
    "line1": "10380 Bren Road West",
    "line2": "string",
    "line3": "string",
    "city": "Minnetonka",
    "countrySubdivision": "MN",
    "postalCode": "55343",
    "country": "US",
    "countryName": "United States",
    "countyName": "Hennepin",
    "phoneNumber": "555-253-1234",
    "phoneticFirstName": "クリス",
    "phoneticLastName": "ミラー",
    "division": "製品開発"
  }
}

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:

curl --location --request GET 'https://api.digitalriver.com/v1/shoppers/addresses/{addressId}' \
--header 'authorization: bearer [Your_Access_Token]'\
...

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:

curl --location --request GET 'https://api.digitalriver.com/v1/shoppers/addresses' \
--header 'authorization: bearer [Your_Access_Token]'\
...

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:

curl --location --request DELETE 'https://api.digitalriver.com/v1/shoppers/addresses/{addressId}' \
--header 'authorization: bearer [Your_Access_Token]'\
...De

You will receive a 204 No Content response.

Last updated