Skip to main content
Skip to main content

AddressesResource

This class is used to send requests to Address API Routes part of the Store Customer API Routes. All its method are available in the JS Client under the medusa.customers.addresses property.

All methods in this class require authentication.

Methods

addAddress

Add an address to the logged-in customer's saved addresses.

Example

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged
medusa.customers.addresses.addAddress({
address: {
first_name: "Celia",
last_name: "Schumm",
address_1: "225 Bednar Curve",
city: "Danielville",
country_code: "US",
postal_code: "85137",
phone: "981-596-6748 x90188",
company: "Wyman LLC",
province: "Georgia",
}
})
.then(({ customer }) => {
console.log(customer.id);
})

Parameters

The address to add.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<StoreCustomersRes>Required
Resolves to the customer's details, including the customer's addresses in the shipping_addresses attribute.

deleteAddress

Delete an address of the logged-in customer.

Example

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged
medusa.customers.addresses.deleteAddress(addressId)
.then(({ customer }) => {
console.log(customer.id);
})

Parameters

address_idstringRequired
The ID of the address to delete.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<StoreCustomersRes>Required
Resolves to the customer's details, including the customer's addresses in the shipping_addresses attribute.

updateAddress

Update an address of the logged-in customer.

Example

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged
medusa.customers.addresses.updateAddress(addressId, {
first_name: "Gina"
})
.then(({ customer }) => {
console.log(customer.id);
})

Parameters

address_idstringRequired
The address's ID.
The attributes to update in the address.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<StoreCustomersRes>Required
Resolves to the customer's details, including the customer's addresses in the shipping_addresses attribute.
Was this section helpful?