--- displayed_sidebar: jsClientSidebar slug: /references/js-client/CustomersResource --- import ParameterTypes from "@site/src/components/ParameterTypes" # CustomersResource This class is used to send requests to [Store Customer API Routes](https://docs.medusajs.com/api/store#customers\_postcustomers). 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](https://docs.medusajs.com/modules/customers/storefront/implement-customer-profiles). ## 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 ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.customers .create({ first_name: "Alec", last_name: "Reynolds", email: "user@example.com", password: "supersecret", }) .then(({ customer }) => { console.log(customer.id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "orders", "type": "[Order](../internal/classes/internal.Order.mdx)[]", "description": "The details of the orders this customer placed.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "phone", "type": "`string`", "description": "The customer's phone number", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "shipping_addresses", "type": "[Address](../internal/classes/internal.Address.mdx)[]", "description": "The details of the shipping addresses associated with the customer.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### generatePasswordToken Create a reset password token to be used when sending a request with the [resetPassword](CustomersResource.mdx#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 ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.customers .generatePasswordToken({ email: "user@example.com", }) .then(() => { // successful }) .catch(() => { // failed }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns ___ ### listOrders 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](AuthResource.mdx#authenticate). #### Example ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged medusa.customers.listOrders().then(({ orders, limit, offset, count }) => { console.log(orders) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "no_notification", "type": "`boolean`", "description": "Flag for describing whether or not notifications related to this should be send.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "paid_total", "type": "`number`", "description": "The total amount paid", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "payment_status", "type": "[PaymentStatus](../internal/enums/internal.PaymentStatus.mdx)", "description": "The order's payment status", "optional": false, "defaultValue": "not_paid", "expandable": false, "children": [] }, { "name": "payments", "type": "[Payment](../internal/classes/internal.Payment.mdx)[]", "description": "The details of the payments used in the order.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "raw_discount_total", "type": "`number`", "description": "The total of discount", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "refundable_amount", "type": "`number`", "description": "The amount that can be refunded", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "refunded_total", "type": "`number`", "description": "The total amount refunded if the order is returned.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "refunds", "type": "[Refund](../internal/classes/internal.Refund.mdx)[]", "description": "The details of the refunds created for the order.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "region", "type": "[Region](../internal/classes/internal.Region.mdx)", "description": "The details of the region this order was created in.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "region_id", "type": "`string`", "description": "The ID of the region this order was created in.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "returnable_items", "type": "[LineItem](../internal/classes/internal.LineItem.mdx)[]", "description": "The details of the line items that are returnable as part of the order, swaps, or claims", "optional": true, "defaultValue": "", "expandable": true, "children": [] }, { "name": "returns", "type": "[Return](../internal/classes/internal.Return.mdx)[]", "description": "The details of the returns created for the order.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "sales_channel", "type": "[SalesChannel](../internal/classes/internal.SalesChannel.mdx)", "description": "The details of the sales channel this order belongs to.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "sales_channel_id", "type": "``null`` \\| `string`", "description": "The ID of the sales channel this order belongs to.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "shipping_address", "type": "[Address](../internal/classes/internal.Address.mdx)", "description": "The details of the shipping address associated with the order.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "shipping_address_id", "type": "`string`", "description": "The ID of the shipping address associated with the order", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "shipping_methods", "type": "[ShippingMethod](../internal/classes/internal.ShippingMethod-4.mdx)[]", "description": "The details of the shipping methods used in the order.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "shipping_tax_total", "type": "``null`` \\| `number`", "description": "The tax total applied on shipping", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "shipping_total", "type": "`number`", "description": "The total of shipping", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "status", "type": "[OrderStatus](../internal/enums/internal.OrderStatus.mdx)", "description": "The order's status", "optional": false, "defaultValue": "pending", "expandable": false, "children": [] }, { "name": "subtotal", "type": "`number`", "description": "The subtotal of the order", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "swaps", "type": "[Swap](../internal/classes/internal.Swap.mdx)[]", "description": "The details of the swaps created for the order.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "tax_rate", "type": "``null`` \\| `number`", "description": "The order's tax rate", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "tax_total", "type": "``null`` \\| `number`", "description": "The total of tax", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "total", "type": "`number`", "description": "The total amount of the order", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### resetPassword Reset a customer's password using a password token created by a previous request using the [generatePasswordToken](CustomersResource.mdx#generatepasswordtoken) method. If the password token expired, you must create a new one. #### Example ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) medusa.customers .resetPassword({ email: "user@example.com", password: "supersecret", token: "supersecrettoken", }) .then(({ customer }) => { console.log(customer.id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "orders", "type": "[Order](../internal/classes/internal.Order.mdx)[]", "description": "The details of the orders this customer placed.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "phone", "type": "`string`", "description": "The customer's phone number", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "shipping_addresses", "type": "[Address](../internal/classes/internal.Address.mdx)[]", "description": "The details of the shipping addresses associated with the customer.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### retrieve Retrieve the logged-in customer's details. This method requires [customer authentication](AuthResource.mdx#authenticate). #### Example ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged medusa.customers.retrieve().then(({ customer }) => { console.log(customer.id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "orders", "type": "[Order](../internal/classes/internal.Order.mdx)[]", "description": "The details of the orders this customer placed.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "phone", "type": "`string`", "description": "The customer's phone number", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "shipping_addresses", "type": "[Address](../internal/classes/internal.Address.mdx)[]", "description": "The details of the shipping addresses associated with the customer.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### update Update the logged-in customer's details. This method requires [customer authentication](AuthResource.mdx#authenticate). #### Example ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged medusa.customers .update({ first_name: "Laury", }) .then(({ customer }) => { console.log(customer.id) }) ``` #### Parameters `", "description": "Additional custom data about the customer.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "password", "type": "`string`", "description": "The customer's password.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "phone", "type": "`string`", "description": "The customer's phone number.", "optional": true, "defaultValue": "", "expandable": false, "children": [] } ] }, { "name": "customHeaders", "type": "`Record`", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "orders", "type": "[Order](../internal/classes/internal.Order.mdx)[]", "description": "The details of the orders this customer placed.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "phone", "type": "`string`", "description": "The customer's phone number", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "shipping_addresses", "type": "[Address](../internal/classes/internal.Address.mdx)[]", "description": "The details of the shipping addresses associated with the customer.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} />