POST
/
store
/
customers
/
me
/
addresses
/
{address_id}
JS SDK
import Medusa from "@medusajs/js-sdk"

let MEDUSA_BACKEND_URL = "http://localhost:9000"

if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
  MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL
}

export const sdk = new Medusa({
  baseUrl: MEDUSA_BACKEND_URL,
  debug: process.env.NODE_ENV === "development",
  publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
})

sdk.store.customer.updateAddress(
  "caddr_123",
  {
    country_code: "us"
  }
)
.then(({ customer }) => {
  console.log(customer)
})
{
"customer": {
"id": "<string>",
"email": "jsmith@example.com",
"default_billing_address_id": "<string>",
"default_shipping_address_id": "<string>",
"company_name": "<string>",
"first_name": "<string>",
"last_name": "<string>",
"addresses": [
{
"id": "<string>",
"address_name": "<string>",
"is_default_shipping": true,
"is_default_billing": true,
"customer_id": "<string>",
"company": "<string>",
"first_name": "<string>",
"last_name": "<string>",
"address_1": "<string>",
"address_2": "<string>",
"city": "<string>",
"country_code": "usd",
"province": "us-ca",
"postal_code": "<string>",
"phone": "<string>",
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
],
"phone": "<string>",
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}
}

Authorizations

connect.sid
string
cookie
required

Headers

x-publishable-api-key
string
required

Publishable API Key created in the Medusa Admin.

Path Parameters

address_id
string
required

The address's ID.

Query Parameters

fields
string

Comma-separated fields that should be included in the returned data. if a field is prefixed with + it will be added to the default fields, using - will remove it from the default fields. without prefix it will replace the entire default fields. This API route restricts the fields that can be selected. Learn how to override the retrievable fields in the Retrieve Custom Links documentation.

Body

application/json

The properties to update in the address.

first_name
string

The customer's first name.

last_name
string

The customer's last name.

phone
string

The customer's phone.

company
string

The address's company.

address_1
string

The address's first line.

address_2
string

The address's second line.

city
string

The address's city.

country_code
string

The address's country code.

province
string

The address's ISO 3166-2 province code. Must be lower-case.

Example:

"us-ca"

postal_code
string

The address's postal code.

address_name
string

The address's name.

is_default_shipping
boolean

Whether the address is used by default for shipping during checkout.

is_default_billing
boolean

Whether the address is used by default for billing during checkout.

metadata
object

Holds custom key-value pairs.

Response

OK

The customer's details.

customer
object
required

The customer's details.