This documentation provides a reference to the sdk.store.customer
set of methods used to send requests to Medusa's Store API routes.
This method registers a customer. It sends a request to the Register Customer API route.
You must use the Auth.register method first to retrieve a registration token. Then, pass that
registration token in the headers
parameter of this method as an authorization bearer header.
Related guide: How to register customer in storefront
1const token = await sdk.auth.register("customer", "emailpass", {2 "email": "customer@gmail.com",3 "password": "supersecret"4})5 6sdk.store.customer.create(7 {8 "email": "customer@gmail.com"9 },10 {},11 {12 Authorization: `Bearer ${token}`13 }14)15.then(({ customer }) => {16 console.log(customer)17})
Promise
Promise<StoreCustomerResponse>This method updates the logged-in customer's details. The customer must be logged in first with the Auth.login method.
It sends a request to the Update Customer API route.
Related guide: How to edit customer's profile in the storefront.
Promise
Promise<StoreCustomerResponse>This method retrieves the logged-in customer's details. The customer must be logged in first with the Auth.login method.
It sends a request to the Get Logged-In Customer API route.
Promise
Promise<StoreCustomerResponse>This method creates an address for the logged-in customer. The customer must be logged in first with the Auth.login method.
It sends a request to the Create Address API route.
Related guides: How to manage customer's addresses in the storefront
Promise
Promise<StoreCustomerResponse>This method updates the address of the logged-in customer. The customer must be logged in first with the Auth.login method.
It sends a request to the Update Address API route.
Related guides: How to manage customer's addresses in the storefront
addressId
stringPromise
Promise<StoreCustomerResponse>This method retrieves the logged-in customer's address. The customer must be logged in first with the Auth.login method.
It sends a request to the List Customer's Address API route.
Related guides: How to manage customer's addresses in the storefront
To retrieve the list of addresses:
To configure the pagination, pass the limit
and offset
query parameters.
For example, to retrieve only 10 items and skip 10 items:
Using the fields
query parameter, you can specify the fields and relations to retrieve
in each address:
Learn more about the fields
property in the API reference.
Promise
Promise<StoreCustomerAddressListResponse>This method retrieves an address of the logged-in customer. The customer must be logged in first with the Auth.login method.
It sends a request to the Get Address API route.
Related guides: How to manage customer's addresses in the storefront
To retrieve an address by its ID:
To specify the fields and relations to retrieve:
Learn more about the fields
property in the API reference.
addressId
stringPromise
Promise<StoreCustomerAddressResponse>This method deletes an address of the logged-in customer. The customer must be logged in first with the Auth.login method.
It sends a request to the Remove Address API route.
Related guides: How to manage customer's addresses in the storefront
addressId
stringPromise
Promise<StoreCustomerAddressDeleteResponse>