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.
customHeadersRecord<string, any>RequiredDefault: {}
Returns
ResponsePromiseResponsePromise<StoreCustomersRes>RequiredResolves to the created customer's details.
ResponsePromiseResponsePromise<StoreCustomersRes>Requiredretrieve
Retrieve the logged-in customer's details. This method requires customer authentication.
Example
Parameters
customHeadersRecord<string, any>RequiredDefault: {}
Returns
ResponsePromiseResponsePromise<StoreCustomersRes>RequiredResolves to the logged-in customer's details.
ResponsePromiseResponsePromise<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.
customHeadersRecord<string, any>RequiredDefault: {}
Returns
ResponsePromiseResponsePromise<StoreCustomersRes>RequiredResolves to the logged-in customer's details.
ResponsePromiseResponsePromise<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
customHeadersRecord<string, any>RequiredDefault: {}
Filters and pagination configurations to apply on the retrieved orders.
Returns
ResponsePromiseResponsePromise<StoreCustomersListOrdersRes>RequiredResolves to the list of orders with pagination fields.
ResponsePromiseResponsePromise<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.
customHeadersRecord<string, any>RequiredDefault: {}
Returns
ResponsePromiseResponsePromise<StoreCustomersRes>RequiredResolves to the customer's details.
ResponsePromiseResponsePromise<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.
customHeadersRecord<string, any>RequiredDefault: {}
Returns
ResponsePromiseResponsePromiseRequired