POST
/
admin
/
customers
/
{id}
/
addresses
JS SDK
import Medusa from "@medusajs/js-sdk"

export const sdk = new Medusa({
  baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
  debug: import.meta.env.DEV,
  auth: {
    type: "session",
  },
})

sdk.admin.customer.createAddress("cus_123", {
  address_1: "123 Main St",
  city: "Anytown",
  country_code: "US",
  postal_code: "12345"
})
.then(({ customer }) => {
  console.log(customer)
})
{
"customer": {
"id": "<string>",
"has_account": true,
"groups": [
{
"id": "<string>",
"name": "<string>",
"customers": [
{}
],
"metadata": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
],
"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": "us",
"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_by": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

id
string
required

The customer'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 address's details.

address_name
string
required

The name of the address.

company
string
required

The address's company.

first_name
string
required

The address's first name.

last_name
string
required

The address's last name.

address_1
string
required

The address's first line.

address_2
string
required

The address's second line.

city
string
required

The address's city.

country_code
string
required

The address's country code.

province
string
required

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

Example:

"us-ca"

postal_code
string
required

The address's postal code.

phone
string
required

The address's phone.

metadata
object
required

The address's metadata.

is_default_shipping
boolean

Whether this address is used by default for shipping when placing an order.

is_default_billing
boolean

Whether this address is used by default for billing when placing an order.

additional_data
object

Pass additional custom data to the API route. This data is passed to the underlying workflow under the additional_data parameter.

Response

OK

The customer's details.

customer
object
required

The customer's details.