CustomersResource
This class is used to send requests to Store Customer API Routes. All its method
are available in the JS Client under the medusa.customers
property.
A customer can register and manage their information such as addresses, orders, payment methods, and more.
Related Guide: How to implement customer profiles in your storefront.
Properties
Methods
create
Register a new customer. This will also automatically authenticate the customer and set their login session in the response Cookie header. Subsequent requests sent with the JS client are sent with the Cookie session automatically.
Example
Parameters
The details of the customer to be created.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<StoreCustomersRes>RequiredResolves to the created customer's details.
ResponsePromise
ResponsePromise<StoreCustomersRes>Requiredretrieve
Retrieve the logged-in customer's details. This method requires customer authentication.
Example
Parameters
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<StoreCustomersRes>RequiredResolves to the logged-in customer's details.
ResponsePromise
ResponsePromise<StoreCustomersRes>Requiredupdate
Update the logged-in customer's details. This method requires customer authentication.
Example
Parameters
The attributes to update in the logged-in customer.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<StoreCustomersRes>RequiredResolves to the logged-in customer's details.
ResponsePromise
ResponsePromise<StoreCustomersRes>RequiredlistOrders
Retrieve a list of the logged-in customer's orders. The orders can be filtered by fields such as status
or fulfillment_status
. The orders can also be paginated.
This method requires customer authentication.
Example
Parameters
customHeaders
Record<string, any>RequiredDefault: {}
Filters and pagination configurations to apply on the retrieved orders.
Returns
ResponsePromise
ResponsePromise<StoreCustomersListOrdersRes>RequiredResolves to the list of orders with pagination fields.
ResponsePromise
ResponsePromise<StoreCustomersListOrdersRes>RequiredresetPassword
Reset a customer's password using a password token created by a previous request using the generatePasswordToken method. If the password token expired, you must create a new one.
Example
Parameters
The necessary details to reset the password.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<StoreCustomersRes>RequiredResolves to the customer's details.
ResponsePromise
ResponsePromise<StoreCustomersRes>RequiredgeneratePasswordToken
Create a reset password token to be used when sending a request with the resetPassword method. This emits the event customer.password_reset
. If a notification provider is
installed in the Medusa backend and is configured to handle this event, a notification to the customer, such as an email, may be sent with reset instructions.
Example
Parameters
The necessary details to create the reset password token.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromiseRequired