chore: reorganize docs apps (#7228)

* reorganize docs apps

* add README

* fix directory

* add condition for old docs
This commit is contained in:
Shahed Nasser authored and GitHub committed 2024-05-03 17:36:38 +03:00
1 parent 224ebb2154
commit 4fe28f5a95
6187 files changed
+601447 -598226

No files matched your search

@@ -0,0 +1,100 @@
---
slug: /references/js-client/AddressesResource
---
import { TypeList } from "docs-ui"
# AddressesResource
This class is used to send requests to Address API Routes part of the [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.addresses` property.
All methods in this class require [authentication](../../../modules/customer/page.mdx).
## Methods
### addAddress
Add an address to the logged-in customer's saved addresses.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged
medusa.customers.addresses.addAddress({
address: {
first_name: "Celia",
last_name: "Schumm",
address_1: "225 Bednar Curve",
city: "Danielville",
country_code: "US",
postal_code: "85137",
phone: "981-596-6748 x90188",
company: "Wyman LLC",
province: "Georgia",
}
})
.then(({ customer }) => {
console.log(customer.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[StorePostCustomersCustomerAddressesReq](../../../medusa/classes/medusa.StorePostCustomersCustomerAddressesReq/page.mdx)","description":"The address to add.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"address","type":"[AddressCreatePayload](../../../medusa/classes/medusa.AddressCreatePayload/page.mdx)","description":"The Address to add to the Customer's saved addresses.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"first_name","type":"`string`","description":"First name","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`string`","description":"Last name","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`string`","description":"Phone Number","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`object`","description":"An optional key-value map with additional details","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`string`","description":"Address line 1","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`string`","description":"Address line 2","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`string`","description":"City","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"The 2 character ISO code of the country in lower case","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`string`","description":"Province","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`string`","description":"Postal Code","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addAddress"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCustomersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer's details, including the customer's addresses in the `shipping_addresses` attribute.","expandable":false,"children":[{"name":"StoreCustomersRes","type":"[StoreCustomersRes](../../../medusa/types/medusa.StoreCustomersRes/page.mdx)","optional":false,"defaultValue":"","description":"The customer's details.","expandable":false,"children":[{"name":"customer","type":"Omit&#60;Customer, \"password_hash\"&#62;","description":"Customer details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"groups","type":"Collection&#60;[CustomerGroup](../../../customer_models/classes/customer_models.CustomerGroup/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customers","type":"Collection&#60;[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]}]},{"name":"addresses","type":"Collection&#60;[Address](../../../customer_models/classes/customer_models.Address/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[EntityDateColumns](../../../types/DAL/types/types.DAL.EntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customer","type":"[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","descriptionLine truncated
### deleteAddress
Delete an address of the logged-in customer.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged
medusa.customers.addresses.deleteAddress(addressId)
.then(({ customer }) => {
console.log(customer.id);
})
```
#### Parameters
<TypeList types={[{"name":"address_id","type":"`string`","description":"The ID of the address to delete.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteAddress"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCustomersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer's details, including the customer's addresses in the `shipping_addresses` attribute.","expandable":false,"children":[{"name":"StoreCustomersRes","type":"[StoreCustomersRes](../../../medusa/types/medusa.StoreCustomersRes/page.mdx)","optional":false,"defaultValue":"","description":"The customer's details.","expandable":false,"children":[{"name":"customer","type":"Omit&#60;Customer, \"password_hash\"&#62;","description":"Customer details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"groups","type":"Collection&#60;[CustomerGroup](../../../customer_models/classes/customer_models.CustomerGroup/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customers","type":"Collection&#60;[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]}]},{"name":"addresses","type":"Collection&#60;[Address](../../../customer_models/classes/customer_models.Address/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[EntityDateColumns](../../../types/DAL/types/types.DAL.EntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customer","type":"[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","descriptionLine truncated
### updateAddress
Update an address of the logged-in customer.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged
medusa.customers.addresses.updateAddress(addressId, {
first_name: "Gina"
})
.then(({ customer }) => {
console.log(customer.id);
})
```
#### Parameters
<TypeList types={[{"name":"address_id","type":"`string`","description":"The address's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[StorePostCustomersCustomerAddressesAddressReq](../../../medusa/classes/medusa.StorePostCustomersCustomerAddressesAddressReq/page.mdx)","description":"The attributes to update in the address.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"first_name","type":"`string`","description":"First name","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`string`","description":"Last name","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`string`","description":"Phone Number","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional key-value map with additional details","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`string`","description":"Company","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_1","type":"`string`","description":"Address line 1","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`string`","description":"Address line 2","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`string`","description":"City","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"The 2 character ISO code of the country in lower case","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`string`","description":"Province","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`string`","description":"Postal Code","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateAddress"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCustomersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer's details, including the customer's addresses in the `shipping_addresses` attribute.","expandable":false,"children":[{"name":"StoreCustomersRes","type":"[StoreCustomersRes](../../../medusa/types/medusa.StoreCustomersRes/page.mdx)","optional":false,"defaultValue":"","description":"The customer's details.","expandable":false,"children":[{"name":"customer","type":"Omit&#60;Customer, \"password_hash\"&#62;","description":"Customer details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"groups","type":"Collection&#60;[CustomerGroup](../../../customer_models/classes/customer_models.CustomerGroup/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customers","type":"Collection&#60;[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]}]},{"name":"addresses","type":"Collection&#60;[Address](../../../customer_models/classes/customer_models.Address/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[EntityDateColumns](../../../types/DAL/types/types.DAL.EntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customer","type":"[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","descriptionLine truncated
@@ -0,0 +1,14 @@
---
slug: /references/js-client/Admin
---
import { TypeList } from "docs-ui"
# Admin
This class includes properties used to send requests to the [Admin API Routes](https://docs.medusajs.com/api/admin). All its properties
are available in the JS Client under the `medusa.admin` property.
## Properties
<TypeList types={[{"name":"auth","type":"[AdminAuthResource](../js_client.AdminAuthResource/page.mdx)","description":"An instance of [AdminAuthResource](../js_client.AdminAuthResource/page.mdx) used to send requests to [Admin Auth API Routes](https://docs.medusajs.com/api/admin#auth).","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"batchJobs","type":"[AdminBatchJobsResource](../js_client.AdminBatchJobsResource/page.mdx)","description":"An instance of [AdminBatchJobsResource](../js_client.AdminBatchJobsResource/page.mdx) used to send requests to [Admin Batch Job API Routes](https://docs.medusajs.com/api/admin#batch-jobs).","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customers","type":"[AdminCustomersResource](../js_client.AdminCustomersResource/page.mdx)","description":"An instance of [AdminCustomersResource](../js_client.AdminCustomersResource/page.mdx) used to send requests to [Admin Customer API Routes](https://docs.medusajs.com/api/admin#customers).","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customerGroups","type":"[AdminCustomerGroupsResource](../js_client.AdminCustomerGroupsResource/page.mdx)","description":"An instance of [AdminCustomerGroupsResource](../js_client.AdminCustomerGroupsResource/page.mdx) used to send requests to [Admin Customer Group API Routes](https://docs.medusajs.com/api/admin#customer-groups).","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discounts","type":"[AdminDiscountsResource](../js_client.AdminDiscountsResource/page.mdx)","description":"An instance of [AdminDiscountsResource](../js_client.AdminDiscountsResource/page.mdx) used to send requests to [Admin Discount API Routes](https://docs.medusajs.com/api/admin#discounts).","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currencies","type":"[AdminCurrenciesResource](../js_client.AdminCurrenciesResource/page.mdx)","description":"An instance of [AdminCurrenciesResource](../js_client.AdminCurrenciesResource/page.mdx) used to send requests to [Admin Currency API Routes](https://docs.medusajs.com/api/admin#currencies\\_getcurrencies).","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collections","type":"[AdminCollectionsResource](../js_client.AdminCollectionsResource/page.mdx)","description":"An instance of [AdminCollectionsResource](../js_client.AdminCollectionsResource/page.mdx) used to send requests to [Admin Product Collection API Routes](https://docs.medusajs.com/api/admin#product-collections).","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"draftOrders","type":"[AdminDraftOrdersResource](../js_client.AdminDraftOrdersResource/page.mdx)","description":"An instance of [AdminDraftOrdersResource](../js_client.AdminDraftOrdersResource/page.mdx) used to send requests to [Admin Draft Order API Routes](https://docs.medusajs.com/api/admin#draft-orders).","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"giftCards","type":"[AdminGiftCardsResource](../js_client.AdminGiftCardsResource/page.mdx)","description":"An instance of [AdminGiftCardsResource](../js_client.AdminGiftCardsResource/page.mdx) used to send requests to [Admin Gift Card API Routes](https://docs.medusajs.com/api/admin#gift-cards).","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"invites","type":"[AdminInvitesResource](../js_client.AdminInvitesResource/page.mdx)","description":"An instance of [AdminInvitesResource](../js_client.AdminInvitesResource/page.mdx) used to send requests to [Admin Invite API Routes](https://docs.medusajs.com/api/admin#invites).","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"inventoryItems","type":"[AdminInventoryItemsResource](../js_client.AdminInventoryItemsResource/page.mdx)","description":"An instance of [AdminInventoryItemsResource](../js_client.AdminInventoryItemsResource/page.mdx) used to send requests to [Admin Inventory Item API Routes](https://docs.medusajs.com/api/admin#inventory-items).","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"notes","type":"[AdminNotesResource](../js_client.AdminNotesResource/page.mdx)","description":"An instance of [AdminNotesResource](../js_client.AdminNotesResource/page.mdx) used to send requests to [Admin Note API Routes](https://docs.medusajs.com/api/admin#notes).","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"priceLists","type":"[AdminPriceListResource](../js_client.AdminPriceListResource/page.mdx)","description":"An instance of [AdminPriceListResource](../js_client.AdminPriceListResource/page.mdx) used to send requests to [Admin Price List API Routes](https://docs.medusajs.com/api/admin#price-lists).","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"[AdminProductsResource](../js_client.AdminPLine truncated
@@ -0,0 +1,117 @@
---
slug: /references/js-client/AdminAuthResource
---
import { TypeList } from "docs-ui"
# AdminAuthResource
This class is used to send requests to [Admin Auth API Routes](https://docs.medusajs.com/api/admin#auth\_getauth). All its method
are available in the JS Client under the `medusa.admin.auth` property.
The methods in this class allow admin users to manage their session, such as login or log out.
You can send authenticated requests for an admin user either using the Cookie header, their API token, or the JWT Token.
When you log the admin user in using the [createSession](page.mdx#createsession) method, the JS client will automatically attach the
cookie header in all subsequent requests.
Related Guide: [How to implement user profiles](https://docs.medusajs.com/modules/users/admin/manage-profile).
## Methods
### getSession
Get the currently logged in user's details. Can also be used to check if there is an authenticated user.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.auth.getSession()
.then(({ user }) => {
console.log(user.id);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getSession"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminAuthRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the logged-in user's details.","expandable":false,"children":[{"name":"AdminAuthRes","type":"[AdminAuthRes](../../../medusa/types/medusa.AdminAuthRes/page.mdx)","optional":false,"defaultValue":"","description":"The user's details.","expandable":false,"children":[{"name":"user","type":"Omit&#60;User, \"password_hash\"&#62;","description":"User details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"avatar_url","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`OptionalFields`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":true,"defaultValue":"null","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getSession"/>
### deleteSession
Log out the user and remove their authentication session. This will only work if you're using Cookie session for authentication. If the API token is still passed in the header,
the user is still authorized to perform admin functionalities in other API Routes.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in
medusa.admin.auth.deleteSession()
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteSession"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;void&#62;","optional":false,"defaultValue":"","description":"Resolves when user is logged out successfully.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteSession"/>
### createSession
Log a User in using their credentials. If the user is authenticated successfully, the cookie is automatically attached to subsequent requests sent with the JS Client.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.admin.AdminAuthResource.createSession({
email: "user@example.com",
password: "supersecret"
})
.then(({ user }) => {
console.log(user.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostAuthReq](../../../medusa/classes/medusa.AdminPostAuthReq/page.mdx)","description":"The credentials of the user.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"email","type":"`string`","description":"The user's email.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"password","type":"`string`","description":"The user's password.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createSession"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminAuthRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the user's details.","expandable":false,"children":[{"name":"AdminAuthRes","type":"[AdminAuthRes](../../../medusa/types/medusa.AdminAuthRes/page.mdx)","optional":false,"defaultValue":"","description":"The user's details.","expandable":false,"children":[{"name":"user","type":"Omit&#60;User, \"password_hash\"&#62;","description":"User details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"avatar_url","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`OptionalFields`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":true,"defaultValue":"null","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createSession"/>
### getToken
Authenticate the user and retrieve a JWT token to use for subsequent authenticated requests.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.admin.auth.getToken({
email: 'user@example.com',
password: 'supersecret'
})
.then(({ access_token }) => {
console.log(access_token);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostAuthReq](../../../medusa/classes/medusa.AdminPostAuthReq/page.mdx)","description":"The credentials of the user.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"email","type":"`string`","description":"The user's email.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"password","type":"`string`","description":"The user's password.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getToken"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminBearerAuthRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the access token of the user, if they're authenticated successfully.","expandable":false,"children":[{"name":"AdminBearerAuthRes","type":"[AdminBearerAuthRes](../../../medusa/types/medusa.AdminBearerAuthRes/page.mdx)","optional":false,"defaultValue":"","description":"The access token of the user, if they're authenticated successfully.","expandable":false,"children":[{"name":"access_token","type":"`string`","description":"Access token that can be used to send authenticated requests.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getToken"/>
@@ -0,0 +1,175 @@
---
slug: /references/js-client/AdminBatchJobsResource
---
import { TypeList } from "docs-ui"
# AdminBatchJobsResource
This class is used to send requests to [Admin Batch Job API Routes](https://docs.medusajs.com/api/admin#batch-jobs). All its method
are available in the JS Client under the `medusa.admin.batchJobs` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A batch job is a task that is performed by the Medusa backend asynchronusly. For example, the Import Product feature is implemented using batch jobs.
The methods in this class allow admins to manage the batch jobs and their state.
Related Guide: [How to import products](https://docs.medusajs.com/modules/products/admin/import-products).
## Methods
### create
Create a Batch Job to be executed asynchronously in the Medusa backend. If `dry_run` is set to `true`, the batch job will not be executed until the it is confirmed,
which can be done using the [confirm](page.mdx#confirm) method.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.batchJobs.create({
type: 'product-export',
context: {},
dry_run: false
}).then((({ batch_job }) => {
console.log(batch_job.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostBatchesReq](../../../medusa/classes/medusa.AdminPostBatchesReq/page.mdx)","description":"The data of the batch job to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"type","type":"`string`","description":"The type of batch job to start, which is defined by the `batchType` property of the associated batch job strategy.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"context","type":"`Record<string, unknown>`","description":"Additional infomration regarding the batch to be used for processing.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"dry_run","type":"`boolean`","description":"Set a batch job in dry\\_run mode, which would delay executing the batch job until it's confirmed.","optional":false,"defaultValue":"false","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminBatchJobRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the batch job's details.","expandable":false,"children":[{"name":"AdminBatchJobRes","type":"[AdminBatchJobRes](../../../medusa/types/medusa.AdminBatchJobRes/page.mdx)","optional":false,"defaultValue":"","description":"The batch job's details.","expandable":false,"children":[{"name":"batch_job","type":"`BatchJob`","description":"Batch job details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### list
Retrieve a list of Batch Jobs. The batch jobs can be filtered by fields such as `type` or `confirmed_at`. The batch jobs can also be sorted or paginated.
#### Example
To list batch jobs:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.batchJobs.list()
.then(({ batch_jobs, limit, offset, count }) => {
console.log(batch_jobs.length)
})
```
To specify relations that should be retrieved within the batch jobs:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.batchJobs.list({
expand: "created_by_user"
})
.then(({ batch_jobs, limit, offset, count }) => {
console.log(batch_jobs.length)
})
```
By default, only the first `10` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.batchJobs.list({
expand: "created_by_user",
limit,
offset
})
.then(({ batch_jobs, limit, offset, count }) => {
console.log(batch_jobs.length)
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetBatchParams](../../../medusa/classes/medusa.AdminGetBatchParams/page.mdx)","description":"Filters and pagination configurations to apply on the retrieved batch jobs.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":false,"defaultValue":"10","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":false,"defaultValue":"0","expandable":false,"children":[]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"IDs to filter batch jobs by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`string`[]","description":"Types to filter batch jobs by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"confirmed_at","type":"`null` \\| [DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the batch jobs' `confirmed_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"pre_processed_at","type":"`null` \\| [DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the batch jobs' `pre_processed_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"completed_at","type":"`null` \\| [DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the batch jobs' `completed_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"failed_at","type":"`null` \\| [DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the batch jobs' `failed_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"canceled_at","type":"`null` \\| [DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the batch jobs' `canceled_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the batch jobs' `created_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"updated_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the batch jobs' `updated_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandaLine truncated
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminBatchJobListRes&#62;","optional":false,"defaultValue":"","description":"The list of batch jobs with pagination fields.","expandable":false,"children":[{"name":"AdminBatchJobListRes","type":"[AdminBatchJobListRes](../../../medusa/types/medusa.AdminBatchJobListRes/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"batch_jobs","type":"`BatchJob`[]","description":"An array of batch job details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### cancel
Mark a batch job as canceled. When a batch job is canceled, the processing of the batch job doesn’t automatically stop.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.batchJobs.cancel(batchJobId)
.then(({ batch_job }) => {
console.log(batch_job.id);
})
```
#### Parameters
<TypeList types={[{"name":"batchJobId","type":"`string`","description":"The ID of the batch job.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancel"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminBatchJobRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the batch job's details.","expandable":false,"children":[{"name":"AdminBatchJobRes","type":"[AdminBatchJobRes](../../../medusa/types/medusa.AdminBatchJobRes/page.mdx)","optional":false,"defaultValue":"","description":"The batch job's details.","expandable":false,"children":[{"name":"batch_job","type":"`BatchJob`","description":"Batch job details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancel"/>
### confirm
When a batch job is created, it's not executed automatically if `dry_run` is set to `true`. This method confirms that the batch job should be executed.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.batchJobs.confirm(batchJobId)
.then(({ batch_job }) => {
console.log(batch_job.id);
})
```
#### Parameters
<TypeList types={[{"name":"batchJobId","type":"`string`","description":"The ID of the batch job.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="confirm"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminBatchJobRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the batch job's details.","expandable":false,"children":[{"name":"AdminBatchJobRes","type":"[AdminBatchJobRes](../../../medusa/types/medusa.AdminBatchJobRes/page.mdx)","optional":false,"defaultValue":"","description":"The batch job's details.","expandable":false,"children":[{"name":"batch_job","type":"`BatchJob`","description":"Batch job details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="confirm"/>
### retrieve
Retrieve the details of a batch job.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.batchJobs.retrieve(batchJobId)
.then(({ batch_job }) => {
console.log(batch_job.id);
})
```
#### Parameters
<TypeList types={[{"name":"batchJobId","type":"`string`","description":"The ID of the batch job.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminBatchJobRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the batch job's details.","expandable":false,"children":[{"name":"AdminBatchJobRes","type":"[AdminBatchJobRes](../../../medusa/types/medusa.AdminBatchJobRes/page.mdx)","optional":false,"defaultValue":"","description":"The batch job's details.","expandable":false,"children":[{"name":"batch_job","type":"`BatchJob`","description":"Batch job details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
@@ -0,0 +1,215 @@
---
slug: /references/js-client/AdminCollectionsResource
---
import { TypeList } from "docs-ui"
# AdminCollectionsResource
This class is used to send requests to [Admin Product Collection API Routes](https://docs.medusajs.com/api/admin#product-collections). All its method
are available in the JS Client under the `medusa.admin.collections` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A product collection is used to organize products for different purposes such as marketing or discount purposes. For example, you can create a Summer Collection.
## Methods
### create
Create a product collection.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.collections.create({
title: "New Collection"
})
.then(({ collection }) => {
console.log(collection.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostCollectionsReq](../../../medusa/classes/medusa.AdminPostCollectionsReq/page.mdx)","description":"The data of the product collection to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"title","type":"`string`","description":"The title of the collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"An optional handle to be used in slugs. If none is provided, the kebab-case version of the title will be used.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs to hold additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the created product collection's details.","expandable":false,"children":[{"name":"AdminCollectionsRes","type":"[AdminCollectionsRes](../../../medusa/types/medusa.AdminCollectionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The collection's details.","expandable":false,"children":[{"name":"collection","type":"[ProductCollection](../../../product_models/classes/product_models.ProductCollection/page.mdx)","description":"Product Collection details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"Collection&#60;[Product](../../../product_models/classes/product_models.Product/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection","type":"`null` \\| [ProductCollection](../../../product_models/classes/product_models.ProductCollection/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`null` \\| [ProductType](../../../product_models/classes/product_models.ProductType/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tags","type":"Collection&#60;[ProductTag](../../../product_models/classes/product_models.ProductTag/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"images","type":"Collection&#60;[Image](../../../product_models/classes/product_models.Image/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"categories","type":"Collection&#60;[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discountable","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`null` Line truncated
### update
Update a product collection's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.collections.update(collectionId, {
title: "New Collection"
})
.then(({ collection }) => {
console.log(collection.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostCollectionsCollectionReq](../../../medusa/classes/medusa.AdminPostCollectionsCollectionReq/page.mdx)","description":"The data to update in the product collection.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"title","type":"`string`","description":"The title of the collection.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"An optional handle to be used in slugs. If none is provided, the kebab-case version of the title will be used.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs to hold additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product collection's details.","expandable":false,"children":[{"name":"AdminCollectionsRes","type":"[AdminCollectionsRes](../../../medusa/types/medusa.AdminCollectionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The collection's details.","expandable":false,"children":[{"name":"collection","type":"[ProductCollection](../../../product_models/classes/product_models.ProductCollection/page.mdx)","description":"Product Collection details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"Collection&#60;[Product](../../../product_models/classes/product_models.Product/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection","type":"`null` \\| [ProductCollection](../../../product_models/classes/product_models.ProductCollection/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`null` \\| [ProductType](../../../product_models/classes/product_models.ProductType/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tags","type":"Collection&#60;[ProductTag](../../../product_models/classes/product_models.ProductTag/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"images","type":"Collection&#60;[Image](../../../product_models/classes/product_models.Image/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"categories","type":"Collection&#60;[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discountable","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`null` \\| `strLine truncated
### delete
Delete a product collection. This does not delete associated products.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.collections.delete(collectionId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation details.","expandable":false,"children":[{"name":"DeleteResponse","type":"[DeleteResponse](../../../medusa/interfaces/medusa.DeleteResponse/page.mdx)","optional":false,"defaultValue":"","description":"The response returned for a \n\n`DELETE`\n\n request.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the deleted item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the deleted item.","optional":false,"defaultValue":"product-collection","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether the item was deleted successfully.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### retrieve
Retrieve a product collection by its ID. The products associated with it are expanded and returned as well.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.collections.retrieve(collectionId)
.then(({ collection }) => {
console.log(collection.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product collection's details.","expandable":false,"children":[{"name":"AdminCollectionsRes","type":"[AdminCollectionsRes](../../../medusa/types/medusa.AdminCollectionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The collection's details.","expandable":false,"children":[{"name":"collection","type":"[ProductCollection](../../../product_models/classes/product_models.ProductCollection/page.mdx)","description":"Product Collection details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"Collection&#60;[Product](../../../product_models/classes/product_models.Product/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection","type":"`null` \\| [ProductCollection](../../../product_models/classes/product_models.ProductCollection/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`null` \\| [ProductType](../../../product_models/classes/product_models.ProductType/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tags","type":"Collection&#60;[ProductTag](../../../product_models/classes/product_models.ProductTag/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"images","type":"Collection&#60;[Image](../../../product_models/classes/product_models.Image/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"categories","type":"Collection&#60;[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discountable","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`null` \\| `strLine truncated
### list
Retrieve a list of product collections. The product collections can be filtered by fields such as `handle` or `title`. The collections can also be sorted or paginated.
#### Example
To list product collections:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.collections.list()
.then(({ collections, limit, offset, count }) => {
console.log(collections.length);
})
```
By default, only the first `10` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.collections.list({
limit,
offset
})
.then(({ collections, limit, offset, count }) => {
console.log(collections.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetCollectionsParams](../../../medusa/classes/medusa.AdminGetCollectionsParams/page.mdx)","description":"Filters and pagination configurations to apply on the retrieved product collections.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":false,"defaultValue":"10","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":false,"defaultValue":"0","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"Title to filter product collections by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"Handle to filter product collections by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the product collections' `created_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"updated_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the product collections' `updated_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"deleted_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the product collections' `deleted_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"q","type":"`string`","description":"Term to search product collections by their title and handle.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_condition_id","type":"`string`","description":"Filter product collections by their associated discount condition's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCollectionsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of product collections with pagination fields.","expandable":false,"children":[{"name":"AdminCollectionsListRes","type":"[AdminCollectionsListRes](../../../medusa/types/medusa.AdminCollectionsListRes/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collections","type":"[ProductCollection](../../../product_models/classes/product_models.ProductCollection/page.mdx)[]","description":"an array of collection details","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"Collection&#60;[Product](../../../product_models/classes/product_models.Product/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection","type":"`null` \\| [ProductCollection](../../../product_models/classes/product_models.ProductCollection/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`null` \\| [ProductType](../../../product_models/classes/product_models.ProductType/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tags","type":"Collection&#60;[ProductTag](../../../product_models/classes/product_models.ProductTag/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"images","type":"Collection&#60;[Image](../../../product_models/classes/product_models.Image/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"categories","type":"Collection&#60;[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discountable","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`nuLine truncated
### addProducts
Add products to collection.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.collections.addProducts(collectionId, {
product_ids: [
productId1,
productId2
]
})
.then(({ collection }) => {
console.log(collection.products)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostProductsToCollectionReq](../../../medusa/classes/medusa.AdminPostProductsToCollectionReq/page.mdx)","description":"The products to add.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"product_ids","type":"`string`[]","description":"An array of Product IDs to add to the Product Collection.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addProducts"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product collection's details.","expandable":false,"children":[{"name":"AdminCollectionsRes","type":"[AdminCollectionsRes](../../../medusa/types/medusa.AdminCollectionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The collection's details.","expandable":false,"children":[{"name":"collection","type":"[ProductCollection](../../../product_models/classes/product_models.ProductCollection/page.mdx)","description":"Product Collection details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"Collection&#60;[Product](../../../product_models/classes/product_models.Product/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection","type":"`null` \\| [ProductCollection](../../../product_models/classes/product_models.ProductCollection/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`null` \\| [ProductType](../../../product_models/classes/product_models.ProductType/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tags","type":"Collection&#60;[ProductTag](../../../product_models/classes/product_models.ProductTag/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"images","type":"Collection&#60;[Image](../../../product_models/classes/product_models.Image/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"categories","type":"Collection&#60;[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discountable","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`null` \\| `strLine truncated
### removeProducts
Remove a list of products from a collection. This would not delete the product, only the association between the product and the collection.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.collections.removeProducts(collectionId, {
product_ids: [
productId1,
productId2
]
})
.then(({ id, object, removed_products }) => {
console.log(removed_products)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"the ID of the product collection","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminDeleteProductsFromCollectionReq](../../../medusa/classes/medusa.AdminDeleteProductsFromCollectionReq/page.mdx)","description":"The products to remove from the collection.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"product_ids","type":"`string`[]","description":"An array of Product IDs to remove from the Product Collection.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeProducts"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDeleteProductsFromCollectionRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation details.","expandable":false,"children":[{"name":"AdminDeleteProductsFromCollectionRes","type":"[AdminDeleteProductsFromCollectionRes](../../../medusa/types/medusa.AdminDeleteProductsFromCollectionRes/page.mdx)","optional":false,"defaultValue":"","description":"Deletion operation details","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the collection","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of object the removal was executed on","optional":false,"defaultValue":"product-collection","expandable":false,"children":[]},{"name":"removed_products","type":"`string`[]","description":"The IDs of the products removed from the collection","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeProducts"/>
@@ -0,0 +1,86 @@
---
slug: /references/js-client/AdminCurrenciesResource
---
import { TypeList } from "docs-ui"
# AdminCurrenciesResource
This class is used to send requests to [Admin Currency API Routes](https://docs.medusajs.com/api/admin#currencies). All its method
are available in the JS Client under the `medusa.admin.currencies` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A store can use unlimited currencies, and each region must be associated with at least one currency.
Currencies are defined within the Medusa backend. The methods in this class allow admins to list and update currencies.
Related Guide: [How to manage currencies](https://docs.medusajs.com/modules/regions-and-currencies/admin/manage-currencies).
## Methods
### list
Retrieve a list of currencies. The currencies can be filtered by fields such as `code`. The currencies can also be sorted or paginated.
#### Example
To list currencies:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.currencies.list()
.then(({ currencies, count, offset, limit }) => {
console.log(currencies.length);
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.currencies.list({
limit,
offset
})
.then(({ currencies, count, offset, limit }) => {
console.log(currencies.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetCurrenciesParams](../../../medusa/classes/medusa.AdminGetCurrenciesParams/page.mdx)","description":"Filters and pagination configurations to apply on retrieved currencies.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"Code to filter currencies by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"q","type":"`string`","description":"Search parameter for currencies.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"includes_tax","type":"`boolean`","description":"Filter currencies by whether they include tax.","optional":true,"defaultValue":"","expandable":false,"featureFlag":"tax_inclusive_pricing","children":[]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.\nBy default, the returned currencies will be sorted by their `created_at` field.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":true,"defaultValue":"20","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCurrenciesListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of currencies with pagination fields.","expandable":false,"children":[{"name":"AdminCurrenciesListRes","type":"[AdminCurrenciesListRes](../../../medusa/types/medusa.AdminCurrenciesListRes/page.mdx)","optional":false,"defaultValue":"","description":"List of currencies with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currencies","type":"[Currency](../../../currency_models/classes/currency_models.Currency/page.mdx)[]","description":"An array of currency details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol_native","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"decimal_digits","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rounding","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_rounding","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### update
Update a Currency's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.currencies.update(code, {
includes_tax: true
})
.then(({ currency }) => {
console.log(currency.code);
})
```
#### Parameters
<TypeList types={[{"name":"code","type":"`string`","description":"The code of the currency to update.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostCurrenciesCurrencyReq](../../../medusa/classes/medusa.AdminPostCurrenciesCurrencyReq/page.mdx)","description":"The attributes to update in the currency.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"includes_tax","type":"`boolean`","description":"Tax included in prices of currency.","optional":true,"defaultValue":"","expandable":false,"featureFlag":"tax_inclusive_pricing","children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCurrenciesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the currency's details.","expandable":false,"children":[{"name":"AdminCurrenciesRes","type":"[AdminCurrenciesRes](../../../medusa/types/medusa.AdminCurrenciesRes/page.mdx)","optional":false,"defaultValue":"","description":"A currency's details.","expandable":false,"children":[{"name":"currency","type":"[Currency](../../../currency_models/classes/currency_models.Currency/page.mdx)","description":"Currency details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"symbol_native","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"decimal_digits","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rounding","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_rounding","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
@@ -0,0 +1,116 @@
---
slug: /references/js-client/AdminCustomResource
---
import { TypeList } from "docs-ui"
# AdminCustomResource
This class is used to send requests custom API Routes. All its method
are available in the JS Client under the `medusa.admin.custom` property.
## Methods
### get
Send a `GET` request to a custom API Route. The method accepts a tuple of type parameters: the first `TQuery` is the type of accepted query parameters,
which defaults to `Record<string, any>`; the second `TResponse` is the type of response, which defaults to `any`.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
type PostsResponse = {
posts: Post[]
}
// must be previously logged in or use api token
medusa.admin.custom.get<Record<string, any>, PostsResponse>(
"/blog/posts"
)
.then(({ posts }) => {
console.log(posts.length);
})
```
#### Type Parameters
<TypeList types={[{"name":"TQuery","type":"`Record<string, any>`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"TResponse","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="get"/>
#### Parameters
<TypeList types={[{"name":"path","type":"`string`","description":"The path of the custom API Route.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"TQuery","description":"Query path parameters to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`RequestOptions`","description":"Configurations to apply on the request.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="get"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;TResponse&#62;","optional":false,"defaultValue":"","description":"The response data.","expandable":false,"children":[{"name":"TResponse","type":"TResponse","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="get"/>
### post
Send a `POST` request to a custom API Route. The method accepts a tuple of type parameters: the first `TPayload` is the type of accepted body parameters,
which defaults to `Record<string, any>`; the second `TResponse` is the type of response, which defaults to `any`.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
type PostRequest = {
title: string
}
type PostResponse = {
post: Post
}
// must be previously logged in or use api token
medusa.admin.custom.post<PostRequest, PostResponse>(
"/blog/posts",
{
title: "My post",
}
)
.then(({ post }) => {
console.log(post.id);
})
```
#### Type Parameters
<TypeList types={[{"name":"TPayload","type":"`Record<string, any>`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"TResponse","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="post"/>
#### Parameters
<TypeList types={[{"name":"path","type":"`string`","description":"The path of the custom API Route.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"TPayload","description":"Body parameters to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`RequestOptions`","description":"Configurations to apply on the request.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="post"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;TResponse&#62;","optional":false,"defaultValue":"","description":"The response data.","expandable":false,"children":[{"name":"TResponse","type":"TResponse","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="post"/>
### delete
Send a `DELETE` request to a custom API Route. The method accepts a type parameters `TResponse` indicating the type of response, which defaults to `any`.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.custom.delete(
`/blog/posts/${postId}`
)
.then(() => {
// deleted successfully
})
```
#### Type Parameters
<TypeList types={[{"name":"TResponse","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Parameters
<TypeList types={[{"name":"path","type":"`string`","description":"The path of the custom API Route.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`RequestOptions`","description":"Configurations to apply on the request.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;TResponse&#62;","optional":false,"defaultValue":"","description":"The response data.","expandable":false,"children":[{"name":"TResponse","type":"TResponse","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
@@ -0,0 +1,227 @@
---
slug: /references/js-client/AdminCustomerGroupsResource
---
import { TypeList } from "docs-ui"
# AdminCustomerGroupsResource
This class is used to send requests to [Admin Customer Group API Routes](https://docs.medusajs.com/api/admin#customer-groups). All its method
are available in the JS Client under the `medusa.admin.customerGroups` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Customer Groups can be used to organize customers that share similar data or attributes into dedicated groups.
This can be useful for different purposes such as setting a different price for a specific customer group.
Related Guide: [How to manage customer groups](https://docs.medusajs.com/modules/customers/admin/manage-customer-groups).
## Methods
### create
Create a customer group.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customerGroups.create({
name: "VIP"
})
.then(({ customer_group }) => {
console.log(customer_group.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostCustomerGroupsReq](../../../medusa/classes/medusa.AdminPostCustomerGroupsReq/page.mdx)","description":"The data of the customer group to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"name","type":"`string`","description":"Name of the customer group","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"Metadata of the customer group.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCustomerGroupsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer group's details.","expandable":false,"children":[{"name":"AdminCustomerGroupsRes","type":"[AdminCustomerGroupsRes](../../../medusa/types/medusa.AdminCustomerGroupsRes/page.mdx)","optional":false,"defaultValue":"","description":"The customer group's details.","expandable":false,"children":[{"name":"customer_group","type":"[CustomerGroup](../../../medusa/classes/medusa.CustomerGroup/page.mdx)","description":"Customer group details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of a customer group","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### retrieve
Retrieve a customer group by its ID. You can expand the customer group's relations or select the fields that should be returned.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customerGroups.retrieve(customerGroupId)
.then(({ customer_group }) => {
console.log(customer_group.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the customer group.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetCustomerGroupsGroupParams](../../../medusa/classes/medusa.AdminGetCustomerGroupsGroupParams/page.mdx)","description":"Configurations to apply on the retrieved customer group.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCustomerGroupsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer group's details.","expandable":false,"children":[{"name":"AdminCustomerGroupsRes","type":"[AdminCustomerGroupsRes](../../../medusa/types/medusa.AdminCustomerGroupsRes/page.mdx)","optional":false,"defaultValue":"","description":"The customer group's details.","expandable":false,"children":[{"name":"customer_group","type":"[CustomerGroup](../../../medusa/classes/medusa.CustomerGroup/page.mdx)","description":"Customer group details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of a customer group","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### update
Update a customer group's details.
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the customer group.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostCustomerGroupsGroupReq](../../../medusa/classes/medusa.AdminPostCustomerGroupsGroupReq/page.mdx)","description":"The attributes to update in the customer group.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"name","type":"`string`","description":"Name of the customer group","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"Metadata of the customer group.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCustomerGroupsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer group's details.","expandable":false,"children":[{"name":"AdminCustomerGroupsRes","type":"[AdminCustomerGroupsRes](../../../medusa/types/medusa.AdminCustomerGroupsRes/page.mdx)","optional":false,"defaultValue":"","description":"The customer group's details.","expandable":false,"children":[{"name":"customer_group","type":"[CustomerGroup](../../../medusa/classes/medusa.CustomerGroup/page.mdx)","description":"Customer group details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of a customer group","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete a customer group. This doesn't delete the customers associated with the customer group.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customerGroups.delete(customerGroupId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the customer group.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation details.","expandable":false,"children":[{"name":"DeleteResponse","type":"[DeleteResponse](../../../medusa/interfaces/medusa.DeleteResponse/page.mdx)","optional":false,"defaultValue":"","description":"The response returned for a \n\n`DELETE`\n\n request.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the deleted item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the deleted item.","optional":false,"defaultValue":"product-collection","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether the item was deleted successfully.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### list
Retrieve a list of customer groups. The customer groups can be filtered by fields such as `name` or `id`. The customer groups can also be sorted or paginated.
#### Example
To list customer groups:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customerGroups.list()
.then(({ customer_groups, limit, offset, count }) => {
console.log(customer_groups.length);
})
```
To specify relations that should be retrieved within the customer groups:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customerGroups.list({
expand: "customers"
})
.then(({ customer_groups, limit, offset, count }) => {
console.log(customer_groups.length);
})
```
By default, only the first `10` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customerGroups.list({
"expand": "customers",
limit,
offset
})
.then(({ customer_groups, limit, offset, count }) => {
console.log(customer_groups.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetCustomerGroupsParams](../../../medusa/classes/medusa.AdminGetCustomerGroupsParams/page.mdx)","description":"Filters and pagination configurations to apply on the retrieved customer groups.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":true,"defaultValue":"10","expandable":false,"children":[]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"{@inheritDoc FindPaginationParams.fields}","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[] \\| [StringComparisonOperator](../../../medusa/classes/medusa.StringComparisonOperator/page.mdx)","description":"IDs to filter customer groups by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"q","type":"`string`","description":"Search term to search customer groups by their name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`[]","description":"Names to filter customer groups by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the customer groups' `update_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the customer groups' `created_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"discount_condition_id","type":"`string`","description":"Filter customer groups by their associated discount condition's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCustomerGroupsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of customer groups with pagination fields.","expandable":false,"children":[{"name":"AdminCustomerGroupsListRes","type":"[AdminCustomerGroupsListRes](../../../medusa/types/medusa.AdminCustomerGroupsListRes/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_groups","type":"[CustomerGroup](../../../medusa/classes/medusa.CustomerGroup/page.mdx)[]","description":"An array of customer group details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of a customer group","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### addCustomers
Add a list of customers to a customer group.
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the customer group.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostCustomerGroupsGroupCustomersBatchReq](../../../medusa/classes/medusa.AdminPostCustomerGroupsGroupCustomersBatchReq/page.mdx)","description":"The customers to add to the customer group.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"customer_ids","type":"[CustomerGroupsBatchCustomer](../../../medusa/classes/medusa.CustomerGroupsBatchCustomer/page.mdx)[]","description":"The ids of the customers to add","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"ID of the customer","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addCustomers"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCustomerGroupsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer group's details.","expandable":false,"children":[{"name":"AdminCustomerGroupsRes","type":"[AdminCustomerGroupsRes](../../../medusa/types/medusa.AdminCustomerGroupsRes/page.mdx)","optional":false,"defaultValue":"","description":"The customer group's details.","expandable":false,"children":[{"name":"customer_group","type":"[CustomerGroup](../../../medusa/classes/medusa.CustomerGroup/page.mdx)","description":"Customer group details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of a customer group","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addCustomers"/>
### removeCustomers
Remove a list of customers from a customer group. This doesn't delete the customer, only the association between the customer and the customer group.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customerGroups.removeCustomers(customerGroupId, {
customer_ids: [
{
id: customerId
}
]
})
.then(({ customer_group }) => {
console.log(customer_group.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the customer group.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminDeleteCustomerGroupsGroupCustomerBatchReq](../../../medusa/classes/medusa.AdminDeleteCustomerGroupsGroupCustomerBatchReq/page.mdx)","description":"The customers to remove from the customer group.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"customer_ids","type":"[CustomerGroupsBatchCustomer](../../../medusa/classes/medusa.CustomerGroupsBatchCustomer/page.mdx)[]","description":"The ids of the customers to remove","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"ID of the customer","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeCustomers"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCustomerGroupsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer group's details.","expandable":false,"children":[{"name":"AdminCustomerGroupsRes","type":"[AdminCustomerGroupsRes](../../../medusa/types/medusa.AdminCustomerGroupsRes/page.mdx)","optional":false,"defaultValue":"","description":"The customer group's details.","expandable":false,"children":[{"name":"customer_group","type":"[CustomerGroup](../../../medusa/classes/medusa.CustomerGroup/page.mdx)","description":"Customer group details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of a customer group","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeCustomers"/>
### listCustomers
Retrieve a list of customers in a customer group. The customers can be filtered by the `q` field. The customers can also be paginated.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customerGroups.listCustomers(customerGroupId)
.then(({ customers }) => {
console.log(customers.length);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the customer group.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetCustomersParams](../../../medusa/classes/medusa.AdminGetCustomersParams/page.mdx)","description":"Filters and pagination configurations to apply on the retrieved customers.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":false,"defaultValue":"50","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":false,"defaultValue":"0","expandable":false,"children":[]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"q","type":"`string`","description":"Search term used to search customers' email, first name, last name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"Filter customers by whether they have an account.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"groups","type":"`string`[]","description":"Filter customers by the customer's customer groups.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the customers' `created_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"updated_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the customers' `updated_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listCustomers"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCustomersListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of customers with pagination fields.","expandable":false,"children":[{"name":"AdminCustomersListRes","type":"[AdminCustomersListRes](../../../medusa/types/medusa.AdminCustomersListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of customers with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customers","type":"[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx)[]","description":"An array of customer details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"groups","type":"Collection&#60;[CustomerGroup](../../../customer_models/classes/customer_models.CustomerGroup/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customers","type":"Collection&#60;[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]}]},{"name":"addresses","type":"Collection&#60;[Address](../../../customer_models/classes/customer_models.Address/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[EntityDateColumns](../../../types/DAL/types/types.DAL.EntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"","optional":false,"defaultValue":"","exLine truncated
@@ -0,0 +1,153 @@
---
slug: /references/js-client/AdminCustomersResource
---
import { TypeList } from "docs-ui"
# AdminCustomersResource
This class is used to send requests to [Admin Customer API Routes](https://docs.medusajs.com/api/admin#customers). All its method
are available in the JS Client under the `medusa.admin.customers` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Customers can either be created when they register through the [CustomersResource.create](../js_client.CustomersResource/page.mdx#create) method, or created by the admin using the [create](page.mdx#create) method.
Related Guide: [How to manage customers](https://docs.medusajs.com/modules/customers/admin/manage-customers).
## Methods
### create
Create a customer as an admin.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customers.create({
email: "user@example.com",
first_name: "Caterina",
last_name: "Yost",
password: "supersecret"
})
.then(({ customer }) => {
console.log(customer.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostCustomersReq](../../../medusa/classes/medusa.AdminPostCustomersReq/page.mdx)","description":"The customer to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"email","type":"`string`","description":"The customer's email.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`string`","description":"The customer's first name.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`string`","description":"The customer's last name.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"password","type":"`string`","description":"The customer's password.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`string`","description":"The customer's phone number.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs to hold additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCustomersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer's details.","expandable":false,"children":[{"name":"AdminCustomersRes","type":"[AdminCustomersRes](../../../medusa/types/medusa.AdminCustomersRes/page.mdx)","optional":false,"defaultValue":"","description":"The customer's details.","expandable":false,"children":[{"name":"customer","type":"[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx)","description":"Customer details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"groups","type":"Collection&#60;[CustomerGroup](../../../customer_models/classes/customer_models.CustomerGroup/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customers","type":"Collection&#60;[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]}]},{"name":"addresses","type":"Collection&#60;[Address](../../../customer_models/classes/customer_models.Address/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[EntityDateColumns](../../../types/DAL/types/types.DAL.EntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customer","type":"[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":Line truncated
### update
Update a customer's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customers.update(customerId, {
first_name: "Dolly"
})
.then(({ customer }) => {
console.log(customer.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The customer's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostCustomersCustomerReq](../../../medusa/classes/medusa.AdminPostCustomersCustomerReq/page.mdx)","description":"The attributes to update in the customer.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"email","type":"`string`","description":"The Customer's email. You can't update the email of a registered customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`string`","description":"The Customer's first name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`string`","description":"The Customer's last name.","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":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs to hold additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"groups","type":"[Group](../../../medusa/classes/medusa.Group/page.mdx)[]","description":"A list of customer groups to which the customer belongs.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of a customer group","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCustomersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer's details.","expandable":false,"children":[{"name":"AdminCustomersRes","type":"[AdminCustomersRes](../../../medusa/types/medusa.AdminCustomersRes/page.mdx)","optional":false,"defaultValue":"","description":"The customer's details.","expandable":false,"children":[{"name":"customer","type":"[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx)","description":"Customer details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"groups","type":"Collection&#60;[CustomerGroup](../../../customer_models/classes/customer_models.CustomerGroup/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customers","type":"Collection&#60;[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]}]},{"name":"addresses","type":"Collection&#60;[Address](../../../customer_models/classes/customer_models.Address/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[EntityDateColumns](../../../types/DAL/types/types.DAL.EntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customer","type":"[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":Line truncated
### retrieve
Retrieve the details of a customer.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customers.retrieve(customerId)
.then(({ customer }) => {
console.log(customer.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The customer's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCustomersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer's details.","expandable":false,"children":[{"name":"AdminCustomersRes","type":"[AdminCustomersRes](../../../medusa/types/medusa.AdminCustomersRes/page.mdx)","optional":false,"defaultValue":"","description":"The customer's details.","expandable":false,"children":[{"name":"customer","type":"[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx)","description":"Customer details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"groups","type":"Collection&#60;[CustomerGroup](../../../customer_models/classes/customer_models.CustomerGroup/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customers","type":"Collection&#60;[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]}]},{"name":"addresses","type":"Collection&#60;[Address](../../../customer_models/classes/customer_models.Address/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[EntityDateColumns](../../../types/DAL/types/types.DAL.EntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customer","type":"[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":Line truncated
### list
Retrieve a list of Customers. The customers can be filtered by fields such as `q` or `groups`. The customers can also be paginated.
#### Example
To list customers:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customers.list()
.then(({ customers, limit, offset, count }) => {
console.log(customers.length);
})
```
To specify relations that should be retrieved within the customers:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customers.list({
expand: "billing_address"
})
.then(({ customers, limit, offset, count }) => {
console.log(customers.length);
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customers.list({
expand: "billing_address",
limit,
offset
})
.then(({ customers, limit, offset, count }) => {
console.log(customers.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetCustomersParams](../../../medusa/classes/medusa.AdminGetCustomersParams/page.mdx)","description":"Filters and pagination configurations to apply on the retrieved customers.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":false,"defaultValue":"50","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":false,"defaultValue":"0","expandable":false,"children":[]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"q","type":"`string`","description":"Search term used to search customers' email, first name, last name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"Filter customers by whether they have an account.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"groups","type":"`string`[]","description":"Filter customers by the customer's customer groups.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the customers' `created_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"updated_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the customers' `updated_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCustomersListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of customers with pagination fields.","expandable":false,"children":[{"name":"AdminCustomersListRes","type":"[AdminCustomersListRes](../../../medusa/types/medusa.AdminCustomersListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of customers with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customers","type":"[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx)[]","description":"An array of customer details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"groups","type":"Collection&#60;[CustomerGroup](../../../customer_models/classes/customer_models.CustomerGroup/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customers","type":"Collection&#60;[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]}]},{"name":"addresses","type":"Collection&#60;[Address](../../../customer_models/classes/customer_models.Address/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[EntityDateColumns](../../../types/DAL/types/types.DAL.EntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"","optional":false,"defaultValue":"","exLine truncated
@@ -0,0 +1,540 @@
---
slug: /references/js-client/AdminDiscountsResource
---
import { TypeList } from "docs-ui"
# AdminDiscountsResource
This class is used to send requests to [Admin Discount API Routes](https://docs.medusajs.com/api/admin#discounts). All its method
are available in the JS Client under the `medusa.admin.discounts` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Admins can create discounts with conditions and rules, providing them with advanced settings for variety of cases.
The methods in this class can be used to manage discounts, their conditions, resources, and more.
Related Guide: [How to manage discounts](https://docs.medusajs.com/modules/discounts/admin/manage-discounts).
## Methods
### addRegion
Add a Region to the list of Regions a Discount can be used in.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.addRegion(discountId, regionId)
.then(({ discount }) => {
console.log(discount.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"regionId","type":"`string`","description":"The ID of the region to add.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addRegion"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the discount's details.","expandable":false,"children":[{"name":"AdminDiscountsRes","type":"[AdminDiscountsRes](../../../medusa/types/medusa.AdminDiscountsRes/page.mdx)","optional":false,"defaultValue":"","description":"The discount's details.","expandable":false,"children":[{"name":"discount","type":"[Discount](../../../medusa/classes/medusa.Discount/page.mdx)","description":"Discount details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of the discount to apply","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addRegion"/>
### create
Create a discount with a given set of rules that defines how the discount is applied.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
import { AllocationType, DiscountRuleType } from "@medusajs/medusa"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.create({
code: "TEST",
rule: {
type: DiscountRuleType.FIXED,
value: 10,
allocation: AllocationType.ITEM
},
regions: ["reg_XXXXXXXX"],
is_dynamic: false,
is_disabled: false
})
.then(({ discount }) => {
console.log(discount.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostDiscountsReq](../../../medusa/classes/medusa.AdminPostDiscountsReq/page.mdx)","description":"The discount to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"A unique code that will be used to redeem the discount","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rule","type":"[AdminPostDiscountsDiscountRule](../../../medusa/classes/medusa.AdminPostDiscountsDiscountRule/page.mdx)","description":"The discount rule that defines how discounts are calculated","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"type","type":"`DiscountRuleType`","description":"The discount rule's type.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`number`","description":"The discount rule's value.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"allocation","type":"`AllocationType`","description":"The discount rule's allocation.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The discount rule's description.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"conditions","type":"[AdminCreateCondition](../../../medusa/classes/medusa.AdminCreateCondition/page.mdx)[]","description":"The discount rule's conditions.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"operator","type":"`DiscountConditionOperator`","description":"The operator of the discount condition.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"`string`[]","description":"The products associated with the discount condition, if the discount condition's type is `products`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_collections","type":"`string`[]","description":"The product collections associated with the discount condition, if the discount condition's type is `product_collections`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_types","type":"`string`[]","description":"The product types associated with the discount condition, if the discount condition's type is `product_types`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_tags","type":"`string`[]","description":"The product tags associated with the discount condition, if the discount condition's type is `product_tags`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_groups","type":"`string`[]","description":"The customer groups associated with the discount condition, if the discount condition's type is `customer_groups`.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"is_dynamic","type":"`boolean`","description":"Whether the discount should have multiple instances of itself, each with a different code. This can be useful for automatically generated discount codes that all have to follow a common set of rules.","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_disabled","type":"`boolean`","description":"Whether the discount code is disabled on creation. If set to `true`, it will not be available for customers.","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"regions","type":"`string`[]","description":"A list of region IDs representing the Regions in which the Discount can be used.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"starts_at","type":"`Date`","description":"The date and time at which the discount should be available.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ends_at","type":"`Date`","description":"The date and time at which the discount should no longer be available.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"valid_duration","type":"`string`","description":"The duration the discount runs between","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"usage_limit","type":"`number`","description":"Maximum number of times the discount can be used","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs to hold additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the discount's details.","expandable":false,"children":[{"name":"AdminDiscountsRes","type":"[AdminDiscountsRes](../../../medusa/types/medusa.AdminDiscountsRes/page.mdx)","optional":false,"defaultValue":"","description":"The discount's details.","expandable":false,"children":[{"name":"discount","type":"[Discount](../../../medusa/classes/medusa.Discount/page.mdx)","description":"Discount details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of the discount to apply","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update a discount with a given set of rules that define how the discount is applied.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.update(discountId, {
code: "TEST"
})
.then(({ discount }) => {
console.log(discount.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostDiscountsDiscountReq](../../../medusa/classes/medusa.AdminPostDiscountsDiscountReq/page.mdx)","description":"The attributes to update in the discount.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"A unique code that will be used to redeem the discount","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rule","type":"[AdminUpdateDiscountRule](../../../medusa/classes/medusa.AdminUpdateDiscountRule/page.mdx)","description":"The discount rule that defines how discounts are calculated","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The discount rule's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The discount rule's description.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`number`","description":"The discount rule's value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"allocation","type":"`AllocationType`","description":"The discount rule's allocation.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"conditions","type":"[AdminUpsertCondition](../../../medusa/classes/medusa.AdminUpsertCondition/page.mdx)[]","description":"The discount rule's discount conditions.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"operator","type":"`DiscountConditionOperator`","description":"The discount condition's operator.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"The discount condition's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"`string`[]","description":"The products associated with the discount condition, if the discount condition's type is `products`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_collections","type":"`string`[]","description":"The product collections associated with the discount condition, if the discount condition's type is `product_collections`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_types","type":"`string`[]","description":"The product types associated with the discount condition, if the discount condition's type is `product_types`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_tags","type":"`string`[]","description":"The product tags associated with the discount condition, if the discount condition's type is `product_tags`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_groups","type":"`string`[]","description":"The customer groups associated with the discount condition, if the discount condition's type is `customer_groups`.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"is_disabled","type":"`boolean`","description":"Whether the discount code is disabled on creation. If set to `true`, it will not be available for customers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"starts_at","type":"`Date`","description":"The date and time at which the discount should be available.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ends_at","type":"`null` \\| `Date`","description":"The date and time at which the discount should no longer be available.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"valid_duration","type":"`null` \\| `string`","description":"The duration the discount runs between","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"usage_limit","type":"`null` \\| `number`","description":"Maximum number of times the discount can be used","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"regions","type":"`string`[]","description":"A list of region IDs representing the Regions in which the Discount can be used.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An object containing metadata of the discount","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the discount.","expandable":false,"children":[{"name":"AdminDiscountsRes","type":"[AdminDiscountsRes](../../../medusa/types/medusa.AdminDiscountsRes/page.mdx)","optional":false,"defaultValue":"","description":"The discount's details.","expandable":false,"children":[{"name":"discount","type":"[Discount](../../../medusa/classes/medusa.Discount/page.mdx)","description":"Discount details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of the discount to apply","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### createDynamicCode
Create a dynamic unique code that can map to a parent discount. This is useful if you want to automatically generate codes with the same rules and conditions.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.createDynamicCode(discountId, {
code: "TEST",
usage_limit: 1
})
.then(({ discount }) => {
console.log(discount.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostDiscountsDiscountDynamicCodesReq](../../../medusa/classes/medusa.AdminPostDiscountsDiscountDynamicCodesReq/page.mdx)","description":"The dynamic code to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"A unique code that will be used to redeem the Discount","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"usage_limit","type":"`number`","description":"Maximum number of times the discount code can be used","optional":false,"defaultValue":"1","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs to hold additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createDynamicCode"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the discount.","expandable":false,"children":[{"name":"AdminDiscountsRes","type":"[AdminDiscountsRes](../../../medusa/types/medusa.AdminDiscountsRes/page.mdx)","optional":false,"defaultValue":"","description":"The discount's details.","expandable":false,"children":[{"name":"discount","type":"[Discount](../../../medusa/classes/medusa.Discount/page.mdx)","description":"Discount details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of the discount to apply","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createDynamicCode"/>
### delete
Delete a discount. Deleting the discount will make it unavailable for customers to use.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.delete(discountId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the delete operation details.","expandable":false,"children":[{"name":"DeleteResponse","type":"[DeleteResponse](../../../medusa/interfaces/medusa.DeleteResponse/page.mdx)","optional":false,"defaultValue":"","description":"The response returned for a \n\n`DELETE`\n\n request.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the deleted item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the deleted item.","optional":false,"defaultValue":"product-collection","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether the item was deleted successfully.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### deleteDynamicCode
Delete a dynamic code from a discount.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.deleteDynamicCode(discountId, code)
.then(({ discount }) => {
console.log(discount.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string`","description":"The code of the dynamic code to delete.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteDynamicCode"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the discount.","expandable":false,"children":[{"name":"AdminDiscountsRes","type":"[AdminDiscountsRes](../../../medusa/types/medusa.AdminDiscountsRes/page.mdx)","optional":false,"defaultValue":"","description":"The discount's details.","expandable":false,"children":[{"name":"discount","type":"[Discount](../../../medusa/classes/medusa.Discount/page.mdx)","description":"Discount details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of the discount to apply","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteDynamicCode"/>
### retrieve
Retrieve a discount.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.retrieve(discountId)
.then(({ discount }) => {
console.log(discount.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetDiscountParams](../../../medusa/classes/medusa.AdminGetDiscountParams/page.mdx)","description":"Configurations to apply on the retrieved product category.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the discount.","expandable":false,"children":[{"name":"AdminDiscountsRes","type":"[AdminDiscountsRes](../../../medusa/types/medusa.AdminDiscountsRes/page.mdx)","optional":false,"defaultValue":"","description":"The discount's details.","expandable":false,"children":[{"name":"discount","type":"[Discount](../../../medusa/classes/medusa.Discount/page.mdx)","description":"Discount details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of the discount to apply","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### retrieveByCode
Retrieve a discount's details by its discount code.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.retrieveByCode(code)
.then(({ discount }) => {
console.log(discount.id);
})
```
#### Parameters
<TypeList types={[{"name":"code","type":"`string`","description":"The code of the discount.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieveByCode"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the discount.","expandable":false,"children":[{"name":"AdminDiscountsRes","type":"[AdminDiscountsRes](../../../medusa/types/medusa.AdminDiscountsRes/page.mdx)","optional":false,"defaultValue":"","description":"The discount's details.","expandable":false,"children":[{"name":"discount","type":"[Discount](../../../medusa/classes/medusa.Discount/page.mdx)","description":"Discount details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of the discount to apply","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieveByCode"/>
### list
Retrieve a list of Discounts. The discounts can be filtered by fields such as `rule` or `is_dynamic`. The discounts can also be paginated.
#### Example
To list discounts:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.list()
.then(({ discounts, limit, offset, count }) => {
console.log(discounts.id);
})
```
To specify relations that should be retrieved within the discounts:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.list({
expand: "rule"
})
.then(({ discounts, limit, offset, count }) => {
console.log(discounts.id);
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.list({
expand: "rule",
limit,
offset
})
.then(({ discounts, limit, offset, count }) => {
console.log(discounts.id);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetDiscountsParams](../../../medusa/classes/medusa.AdminGetDiscountsParams/page.mdx)","description":"Filters and pagination configurations to apply on the retrieved discounts.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"rule","type":"[AdminGetDiscountsDiscountRuleParams](../../../medusa/classes/medusa.AdminGetDiscountsDiscountRuleParams/page.mdx)","description":"Filter discounts by their associated rule.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"type","type":"`DiscountRuleType`","description":"Type to filter discount rules by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"allocation","type":"`AllocationType`","description":"Allocation to filter discount rules by.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"q","type":"`string`","description":"Search terms to search discounts' code fields.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_dynamic","type":"`boolean`","description":"Filter discounts by whether they're dynamic.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_disabled","type":"`boolean`","description":"Filter discounts by whether they're disabled.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the discounts' `created_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"updated_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the discounts' `updated_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":true,"defaultValue":"20","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of discounts with pagination fields.","expandable":false,"children":[{"name":"AdminDiscountsListRes","type":"[AdminDiscountsListRes](../../../medusa/types/medusa.AdminDiscountsListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of discounts with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discounts","type":"[Discount](../../../medusa/classes/medusa.Discount/page.mdx)[]","description":"The list of discounts.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of the discount to apply","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### removeRegion
Remove a Region from the list of Regions that a Discount can be used in. This does not delete a region, only the association between it and the discount.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.removeRegion(discountId, regionId)
.then(({ discount }) => {
console.log(discount.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"regionId","type":"`string`","description":"The ID of the region to remove.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeRegion"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the discount.","expandable":false,"children":[{"name":"AdminDiscountsRes","type":"[AdminDiscountsRes](../../../medusa/types/medusa.AdminDiscountsRes/page.mdx)","optional":false,"defaultValue":"","description":"The discount's details.","expandable":false,"children":[{"name":"discount","type":"[Discount](../../../medusa/classes/medusa.Discount/page.mdx)","description":"Discount details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of the discount to apply","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeRegion"/>
### createCondition
Create a discount condition. Only one of `products`, `product_types`, `product_collections`, `product_tags`, and `customer_groups` should be provided in the `payload` parameter,
based on the type of discount condition. For example, if the discount condition's type is `products`, the `products` field should be provided in the `payload` parameter.
#### Example
To create a condition in a discount:
```ts
import Medusa from "@medusajs/medusa-js"
import { DiscountConditionOperator } from "@medusajs/medusa"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.createCondition(discountId, {
operator: DiscountConditionOperator.IN,
products: [productId]
})
.then(({ discount }) => {
console.log(discount.id);
})
```
To specify relations that should be retrieved as part of the response:
```ts
import Medusa from "@medusajs/medusa-js"
import { DiscountConditionOperator } from "@medusajs/medusa"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.createCondition(discountId, {
operator: DiscountConditionOperator.IN,
products: [productId]
}, {
expand: "rule"
})
.then(({ discount }) => {
console.log(discount.id);
})
```
#### Parameters
<TypeList types={[{"name":"discountId","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostDiscountsDiscountConditions](../../../medusa/classes/medusa.AdminPostDiscountsDiscountConditions/page.mdx)","description":"The discount condition to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"operator","type":"`DiscountConditionOperator`","description":"Operator of the condition. `in` indicates that discountable resources are within the specified resources. `not\\_in` indicates that discountable resources are everything but the specified resources.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"`string`[]","description":"The products associated with the discount condition, if the discount condition's type is `products`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_collections","type":"`string`[]","description":"The product collections associated with the discount condition, if the discount condition's type is `product_collections`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_types","type":"`string`[]","description":"The product types associated with the discount condition, if the discount condition's type is `product_types`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_tags","type":"`string`[]","description":"The product tags associated with the discount condition, if the discount condition's type is `product_tags`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_groups","type":"`string`[]","description":"The customer groups associated with the discount condition, if the discount condition's type is `customer_groups`.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"query","type":"[AdminPostDiscountsDiscountConditionsParams](../../../medusa/classes/medusa.AdminPostDiscountsDiscountConditionsParams/page.mdx)","description":"Configurations to apply on the returned discount.","optional":false,"defaultValue":"{}","expandable":false,"children":[{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createCondition"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the discount.","expandable":false,"children":[{"name":"AdminDiscountsRes","type":"[AdminDiscountsRes](../../../medusa/types/medusa.AdminDiscountsRes/page.mdx)","optional":false,"defaultValue":"","description":"The discount's details.","expandable":false,"children":[{"name":"discount","type":"[Discount](../../../medusa/classes/medusa.Discount/page.mdx)","description":"Discount details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of the discount to apply","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createCondition"/>
### updateCondition
Update a discount condition. Only one of `products`, `product_types`, `product_collections`, `product_tags`, and `customer_groups` should be provided in the `payload` parameter,
based on the type of discount condition. For example, if the discount condition's type is `products`, the `products` field should be provided in the `payload` parameter.
#### Example
To update a condition in a discount:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.updateCondition(discountId, conditionId, {
products: [
productId
]
})
.then(({ discount }) => {
console.log(discount.id);
})
```
To specify relations that should be retrieved as part of the response:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.updateCondition(discountId, conditionId, {
products: [
productId
]
}, {
expand: "rule"
})
.then(({ discount }) => {
console.log(discount.id);
})
```
#### Parameters
<TypeList types={[{"name":"discountId","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"conditionId","type":"`string`","description":"The ID of the discount condition.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostDiscountsDiscountConditionsCondition](../../../medusa/classes/medusa.AdminPostDiscountsDiscountConditionsCondition/page.mdx)","description":"The attributes to update in the discount condition.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"products","type":"`string`[]","description":"The products associated with the discount condition, if the discount condition's type is `products`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_collections","type":"`string`[]","description":"The product collections associated with the discount condition, if the discount condition's type is `product_collections`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_types","type":"`string`[]","description":"The product types associated with the discount condition, if the discount condition's type is `product_types`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_tags","type":"`string`[]","description":"The product tags associated with the discount condition, if the discount condition's type is `product_tags`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_groups","type":"`string`[]","description":"The customer groups associated with the discount condition, if the discount condition's type is `customer_groups`.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"query","type":"[AdminPostDiscountsDiscountConditionsConditionParams](../../../medusa/classes/medusa.AdminPostDiscountsDiscountConditionsConditionParams/page.mdx)","description":"Configurations to apply on the returned discount.","optional":false,"defaultValue":"{}","expandable":false,"children":[{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateCondition"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the discount.","expandable":false,"children":[{"name":"AdminDiscountsRes","type":"[AdminDiscountsRes](../../../medusa/types/medusa.AdminDiscountsRes/page.mdx)","optional":false,"defaultValue":"","description":"The discount's details.","expandable":false,"children":[{"name":"discount","type":"[Discount](../../../medusa/classes/medusa.Discount/page.mdx)","description":"Discount details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of the discount to apply","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateCondition"/>
### deleteCondition
Delete a discount condition. This doesn't delete resources associated to the discount condition.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.deleteCondition(discountId, conditionId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"discountId","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"conditionId","type":"`string`","description":"The ID of the discount condition.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteCondition"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation details.","expandable":false,"children":[{"name":"DeleteResponse","type":"[DeleteResponse](../../../medusa/interfaces/medusa.DeleteResponse/page.mdx)","optional":false,"defaultValue":"","description":"The response returned for a \n\n`DELETE`\n\n request.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the deleted item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the deleted item.","optional":false,"defaultValue":"product-collection","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether the item was deleted successfully.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteCondition"/>
### getCondition
Retrieve a Discount Condition's details.
#### Example
A simple example that retrieves a discount condition by its ID:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.getCondition(discountId, conditionId)
.then(({ discount_condition }) => {
console.log(discount_condition.id);
})
```
To specify relations that should be retrieved:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.getCondition(discountId, conditionId, {
expand: "discount_rule"
})
.then(({ discount_condition }) => {
console.log(discount_condition.id);
})
```
#### Parameters
<TypeList types={[{"name":"discountId","type":"`string`","description":"The ID of the discount that the condition belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"conditionId","type":"`string`","description":"The ID of the discount condition.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetDiscountsDiscountConditionsConditionParams](../../../medusa/classes/medusa.AdminGetDiscountsDiscountConditionsConditionParams/page.mdx)","description":"Configurations to apply on the retrieved discount condition.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getCondition"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountConditionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the discount condition details.","expandable":false,"children":[{"name":"AdminDiscountConditionsRes","type":"[AdminDiscountConditionsRes](../../../medusa/types/medusa.AdminDiscountConditionsRes/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"discount_condition","type":"`DiscountCondition`","description":"Discount condition details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getCondition"/>
### addConditionResourceBatch
Add a batch of resources to a discount condition. The type of resource depends on the type of discount condition. For example, if the discount condition's type is `products`,
the resources being added should be products.
#### Example
To add resources to a discount condition:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.addConditionResourceBatch(discountId, conditionId, {
resources: [{ id: itemId }]
})
.then(({ discount }) => {
console.log(discount.id);
})
```
To specify relations to include in the returned discount:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.addConditionResourceBatch(discountId, conditionId, {
resources: [{ id: itemId }]
}, {
expand: "rule"
})
.then(({ discount }) => {
console.log(discount.id);
})
```
#### Parameters
<TypeList types={[{"name":"discountId","type":"`string`","description":"The ID of the discount the condition belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"conditionId","type":"`string`","description":"The ID of the discount condition.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostDiscountsDiscountConditionsConditionBatchReq](../../../medusa/classes/medusa.AdminPostDiscountsDiscountConditionsConditionBatchReq/page.mdx)","description":"The resources to add to the discount condition.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"resources","type":"`object`[]","description":"The resources to be added to the discount condition","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the item","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminPostDiscountsDiscountConditionsConditionBatchParams](../../../medusa/classes/medusa.AdminPostDiscountsDiscountConditionsConditionBatchParams/page.mdx)","description":"Configurations to apply on the retrieved discount.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addConditionResourceBatch"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the discount.","expandable":false,"children":[{"name":"AdminDiscountsRes","type":"[AdminDiscountsRes](../../../medusa/types/medusa.AdminDiscountsRes/page.mdx)","optional":false,"defaultValue":"","description":"The discount's details.","expandable":false,"children":[{"name":"discount","type":"[Discount](../../../medusa/classes/medusa.Discount/page.mdx)","description":"Discount details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of the discount to apply","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addConditionResourceBatch"/>
### deleteConditionResourceBatch
Remove a batch of resources from a discount condition. This will only remove the association between the resource and the discount condition, not the resource itself.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.deleteConditionResourceBatch(discountId, conditionId, {
resources: [{ id: itemId }]
})
.then(({ discount }) => {
console.log(discount.id);
})
```
#### Parameters
<TypeList types={[{"name":"discountId","type":"`string`","description":"The ID of the discount the condition belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"conditionId","type":"`string`","description":"The ID of the discount condition.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminDeleteDiscountsDiscountConditionsConditionBatchReq](../../../medusa/classes/medusa.AdminDeleteDiscountsDiscountConditionsConditionBatchReq/page.mdx)","description":"The resources to remove.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"resources","type":"`object`[]","description":"The resources to be removed from the discount condition","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The id of the item","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteConditionResourceBatch"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the discount.","expandable":false,"children":[{"name":"AdminDiscountsRes","type":"[AdminDiscountsRes](../../../medusa/types/medusa.AdminDiscountsRes/page.mdx)","optional":false,"defaultValue":"","description":"The discount's details.","expandable":false,"children":[{"name":"discount","type":"[Discount](../../../medusa/classes/medusa.Discount/page.mdx)","description":"Discount details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of the discount to apply","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteConditionResourceBatch"/>
@@ -0,0 +1,271 @@
---
slug: /references/js-client/AdminDraftOrdersResource
---
import { TypeList } from "docs-ui"
# AdminDraftOrdersResource
This class is used to send requests to [Admin Draft Order API Routes](https://docs.medusajs.com/api/admin#draft-orders). All its method
are available in the JS Client under the `medusa.admin.draftOrders` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A draft order is an order created manually by the admin. It allows admins to create orders without direct involvement from the customer.
Related Guide: [How to manage draft orders](https://docs.medusajs.com/modules/orders/admin/manage-draft-orders).
## Methods
### create
Create a Draft Order. A draft order is not transformed into an order until payment is captured.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.draftOrders.create({
email: "user@example.com",
region_id,
items: [
{
quantity: 1
}
],
shipping_methods: [
{
option_id
}
],
})
.then(({ draft_order }) => {
console.log(draft_order.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostDraftOrdersReq](../../../medusa/classes/medusa.AdminPostDraftOrdersReq/page.mdx)","description":"The draft order to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"email","type":"`string`","description":"The email of the customer of the draft order","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`string`","description":"The ID of the region for the draft order","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_methods","type":"[ShippingMethod](../../../medusa/classes/medusa.ShippingMethod/page.mdx)[]","description":"The shipping methods for the draft order","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"option_id","type":"`string`","description":"The ID of the shipping option in use","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`Record<string, unknown>`","description":"The optional additional data needed for the shipping method","optional":true,"defaultValue":"{}","expandable":false,"children":[]},{"name":"price","type":"`number`","description":"The price of the shipping method.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"status","type":"`string`","description":"The status of the draft order. The draft order's default status is `open`. It's changed to `completed` when its payment is marked as paid.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address","type":"`string` \\| [AddressPayload](../../../medusa/classes/medusa.AddressPayload/page.mdx)","description":"The Address to be used for billing purposes.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address","type":"`string` \\| [AddressPayload](../../../medusa/classes/medusa.AddressPayload/page.mdx)","description":"The Address to be used for shipping purposes.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"items","type":"[Item](../../../medusa/classes/medusa.Item/page.mdx)[]","description":"The draft order's line items.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"quantity","type":"`number`","description":"The quantity of the line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The title of the line item if `variant\\_id` is not provided.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"unit_price","type":"`number`","description":"The custom price of the line item. If a `variant\\_id` is supplied, the price provided here will override the variant's price.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_id","type":"`string`","description":"The ID of the Product Variant associated with the line item. If the line item is custom, the `variant\\_id` should be omitted.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"The optional key-value map with additional details about the line item.","optional":true,"defaultValue":"{}","expandable":false,"children":[]}]},{"name":"discounts","type":"[Discount](../../../medusa/classes/medusa.Discount/page.mdx)[]","description":"The discounts to add to the draft order","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of the discount to apply","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customer_id","type":"`string`","description":"The ID of the customer this draft order is associated with.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"no_notification_order","type":"`boolean`","description":"An optional flag passed to the resulting order that indicates whether the customer should receive notifications about order updates.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"The optional key-value map with additional details about the Draft Order.","optional":true,"defaultValue":"{}","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDraftOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the draft order's details","expandable":false,"children":[{"name":"AdminDraftOrdersRes","type":"[AdminDraftOrdersRes](../../../medusa/types/medusa.AdminDraftOrdersRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of draft orders.","expandable":false,"children":[{"name":"draft_order","type":"`DraftOrder`","description":"Draft order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### addLineItem
Create a Line Item in the Draft Order.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.draftOrders.addLineItem(draftOrderId, {
quantity: 1
})
.then(({ draft_order }) => {
console.log(draft_order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the draft order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostDraftOrdersDraftOrderLineItemsReq](../../../medusa/classes/medusa.AdminPostDraftOrdersDraftOrderLineItemsReq/page.mdx)","description":"The line item to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"quantity","type":"`number`","description":"The quantity of the line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The title of the line item if `variant\\_id` is not provided.","optional":true,"defaultValue":"\"Custom item\"","expandable":false,"children":[]},{"name":"unit_price","type":"`number`","description":"The custom price of the line item. If a `variant\\_id` is supplied, the price provided here will override the variant's price.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_id","type":"`string`","description":"The ID of the Product Variant associated with the line item. If the line item is custom, the `variant\\_id` should be omitted.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"The optional key-value map with additional details about the Line Item.","optional":true,"defaultValue":"{}","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addLineItem"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDraftOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the draft order's details","expandable":false,"children":[{"name":"AdminDraftOrdersRes","type":"[AdminDraftOrdersRes](../../../medusa/types/medusa.AdminDraftOrdersRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of draft orders.","expandable":false,"children":[{"name":"draft_order","type":"`DraftOrder`","description":"Draft order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addLineItem"/>
### delete
Delete a Draft Order.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.draftOrders.delete(draftOrderId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the draft order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation details.","expandable":false,"children":[{"name":"DeleteResponse","type":"[DeleteResponse](../../../medusa/interfaces/medusa.DeleteResponse/page.mdx)","optional":false,"defaultValue":"","description":"The response returned for a \n\n`DELETE`\n\n request.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the deleted item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the deleted item.","optional":false,"defaultValue":"product-collection","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether the item was deleted successfully.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### removeLineItem
Delete a Line Item from a Draft Order.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.draftOrders.removeLineItem(draftOrderId, itemId)
.then(({ draft_order }) => {
console.log(draft_order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the draft order that the line item belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"itemId","type":"`string`","description":"The ID of the line item to delete from the draft order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeLineItem"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDraftOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the draft order's details","expandable":false,"children":[{"name":"AdminDraftOrdersRes","type":"[AdminDraftOrdersRes](../../../medusa/types/medusa.AdminDraftOrdersRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of draft orders.","expandable":false,"children":[{"name":"draft_order","type":"`DraftOrder`","description":"Draft order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeLineItem"/>
### retrieve
Retrieve a Draft Order's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.draftOrders.retrieve(draftOrderId)
.then(({ draft_order }) => {
console.log(draft_order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the draft order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDraftOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the draft order's details.","expandable":false,"children":[{"name":"AdminDraftOrdersRes","type":"[AdminDraftOrdersRes](../../../medusa/types/medusa.AdminDraftOrdersRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of draft orders.","expandable":false,"children":[{"name":"draft_order","type":"`DraftOrder`","description":"Draft order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve an list of Draft Orders. The draft orders can be filtered by parameters such as `query`. The draft orders can also paginated.
#### Example
To list draft orders:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.draftOrders.list()
.then(({ draft_orders, limit, offset, count }) => {
console.log(draft_orders.length);
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.draftOrders.list({
limit,
offset
})
.then(({ draft_orders, limit, offset, count }) => {
console.log(draft_orders.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetDraftOrdersParams](../../../medusa/classes/medusa.AdminGetDraftOrdersParams/page.mdx)","description":"Filters and pagination configurations to apply on the retrieved draft orders.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Search term to search draft orders by their display IDs and emails.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Limit the number of items returned in the list.","optional":true,"defaultValue":"50","expandable":false,"children":[]},{"name":"status","type":"[DraftOrderStatusValue](../../../medusa/types/medusa.DraftOrderStatusValue/page.mdx)[]","description":"Statuses to filter draft orders by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the draft orders' `created_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"updated_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the draft orders' `updated_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":true,"defaultValue":"20","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDraftOrdersListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of draft orders with pagination fields.","expandable":false,"children":[{"name":"AdminDraftOrdersListRes","type":"[AdminDraftOrdersListRes](../../../medusa/types/medusa.AdminDraftOrdersListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of draft orders with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"draft_orders","type":"`DraftOrder`[]","description":"An array of draft order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### markPaid
Capture the draft order's payment. This will also set the draft order's status to `completed` and create an order from the draft order. The payment is captured through Medusa's system payment,
which is manual payment that isn't integrated with any third-party payment provider. It is assumed that the payment capturing is handled manually by the admin.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.draftOrders.markPaid(draftOrderId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the draft order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="markPaid"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPostDraftOrdersDraftOrderRegisterPaymentRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the created order's details.","expandable":false,"children":[{"name":"AdminPostDraftOrdersDraftOrderRegisterPaymentRes","type":"[AdminPostDraftOrdersDraftOrderRegisterPaymentRes](../../../medusa/types/medusa.AdminPostDraftOrdersDraftOrderRegisterPaymentRes/page.mdx)","optional":false,"defaultValue":"","description":"The order's details.","expandable":false,"children":[{"name":"order","type":"[Order](../../../types/types/types.Order/page.mdx)","description":"Order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="markPaid"/>
### update
Update a Draft Order's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.draftOrders.update(draftOrderId, {
email: "user@example.com"
})
.then(({ draft_order }) => {
console.log(draft_order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the draft order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostDraftOrdersDraftOrderReq](../../../medusa/classes/medusa.AdminPostDraftOrdersDraftOrderReq/page.mdx)","description":"The attributes to update in the draft order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"region_id","type":"`string`","description":"The ID of the Region to create the Draft Order in.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"The 2 character ISO code for the Country.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"An email to be used in the Draft Order.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address","type":"`string` \\| [AddressPayload](../../../medusa/classes/medusa.AddressPayload/page.mdx)","description":"The Address to be used for billing purposes.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address","type":"`string` \\| [AddressPayload](../../../medusa/classes/medusa.AddressPayload/page.mdx)","description":"The Address to be used for shipping purposes.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"discounts","type":"[Discount](../../../medusa/classes/medusa.Discount-1/page.mdx)[]","description":"An array of Discount codes to add to the Draft Order.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code that a Discount is identifed by.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customer_id","type":"`string`","description":"The ID of the customer this draft order is associated with.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"no_notification_order","type":"`boolean`","description":"An optional flag passed to the resulting order that indicates whether the customer should receive notifications about order updates.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDraftOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the draft order's details.","expandable":false,"children":[{"name":"AdminDraftOrdersRes","type":"[AdminDraftOrdersRes](../../../medusa/types/medusa.AdminDraftOrdersRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of draft orders.","expandable":false,"children":[{"name":"draft_order","type":"`DraftOrder`","description":"Draft order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### updateLineItem
Update a Line Item in a Draft Order.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.draftOrders.updateLineItem(draftOrderId, lineId, {
quantity: 1
})
.then(({ draft_order }) => {
console.log(draft_order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the draft order that the line item belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"itemId","type":"`string`","description":"The ID of the line item to update.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostDraftOrdersDraftOrderLineItemsItemReq](../../../medusa/classes/medusa.AdminPostDraftOrdersDraftOrderLineItemsItemReq/page.mdx)","description":"The attributes to update in the line item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"title","type":"`string`","description":"The title of the line item if `variant\\_id` is not provided.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"unit_price","type":"`number`","description":"The custom price of the line item. If a `variant\\_id` is supplied, the price provided here will override the variant's price.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"`number`","description":"The quantity of the line item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"The optional key-value map with additional details about the Line Item.","optional":true,"defaultValue":"{}","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateLineItem"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDraftOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the draft order's details.","expandable":false,"children":[{"name":"AdminDraftOrdersRes","type":"[AdminDraftOrdersRes](../../../medusa/types/medusa.AdminDraftOrdersRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of draft orders.","expandable":false,"children":[{"name":"draft_order","type":"`DraftOrder`","description":"Draft order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateLineItem"/>
@@ -0,0 +1,160 @@
---
slug: /references/js-client/AdminGiftCardsResource
---
import { TypeList } from "docs-ui"
# AdminGiftCardsResource
This class is used to send requests to [Admin Gift Card API Routes](https://docs.medusajs.com/api/admin#gift-cards). All its method
are available in the JS Client under the `medusa.admin.giftCards` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Admins can create gift cards and send them directly to customers, specifying options like their balance, region, and more.
These gift cards are different than the saleable gift cards in a store, which are created and managed through [AdminProductsResource](../js_client.AdminProductsResource/page.mdx).
Related Guide: [How to manage gift cards](https://docs.medusajs.com/modules/gift-cards/admin/manage-gift-cards#manage-custom-gift-cards).
## Methods
### create
Create a gift card that can redeemed by its unique code. The Gift Card is only valid within one region.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.giftCards.create({
region_id
})
.then(({ gift_card }) => {
console.log(gift_card.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostGiftCardsReq](../../../medusa/classes/medusa.AdminPostGiftCardsReq/page.mdx)","description":"The gift card to be created.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"region_id","type":"`string`","description":"The ID of the Region in which the Gift Card can be used.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`number`","description":"The value (excluding VAT) that the Gift Card should represent.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ends_at","type":"`Date`","description":"The date and time at which the Gift Card should no longer be available.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_disabled","type":"`boolean`","description":"Whether the Gift Card is disabled on creation. If set to `true`, the gift card will not be available for customers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs to hold additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminGiftCardsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the gift card's details.","expandable":false,"children":[{"name":"AdminGiftCardsRes","type":"[AdminGiftCardsRes](../../../medusa/types/medusa.AdminGiftCardsRes/page.mdx)","optional":false,"defaultValue":"","description":"The gift card's details.","expandable":false,"children":[{"name":"gift_card","type":"[GiftCard](../../../medusa/classes/medusa.GiftCard/page.mdx)","description":"A gift card's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of a gift card.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update a gift card's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.giftCards.update(giftCardId, {
region_id
})
.then(({ gift_card }) => {
console.log(gift_card.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the gift card.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostGiftCardsGiftCardReq](../../../medusa/classes/medusa.AdminPostGiftCardsGiftCardReq/page.mdx)","description":"The attributes to update in the gift card.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"balance","type":"`number`","description":"The value (excluding VAT) that the Gift Card should represent.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_disabled","type":"`boolean`","description":"Whether the Gift Card is disabled on creation. If set to `true`, the gift card will not be available for customers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ends_at","type":"`null` \\| `Date`","description":"The date and time at which the Gift Card should no longer be available.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`string`","description":"The ID of the Region in which the Gift Card can be used.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs to hold additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminGiftCardsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the gift card's details.","expandable":false,"children":[{"name":"AdminGiftCardsRes","type":"[AdminGiftCardsRes](../../../medusa/types/medusa.AdminGiftCardsRes/page.mdx)","optional":false,"defaultValue":"","description":"The gift card's details.","expandable":false,"children":[{"name":"gift_card","type":"[GiftCard](../../../medusa/classes/medusa.GiftCard/page.mdx)","description":"A gift card's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of a gift card.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete a gift card. Once deleted, it can't be used by customers.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.giftCards.delete(giftCardId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the gift card.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"[DeleteResponse](../../../medusa/interfaces/medusa.DeleteResponse/page.mdx)","optional":false,"defaultValue":"","description":"The response returned for a \n\n`DELETE`\n\n request.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the deleted item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the deleted item.","optional":false,"defaultValue":"product-collection","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether the item was deleted successfully.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### retrieve
Retrieve a gift card's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.giftCards.retrieve(giftCardId)
.then(({ gift_card }) => {
console.log(gift_card.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the gift card.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminGiftCardsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the gift card's details.","expandable":false,"children":[{"name":"AdminGiftCardsRes","type":"[AdminGiftCardsRes](../../../medusa/types/medusa.AdminGiftCardsRes/page.mdx)","optional":false,"defaultValue":"","description":"The gift card's details.","expandable":false,"children":[{"name":"gift_card","type":"[GiftCard](../../../medusa/classes/medusa.GiftCard/page.mdx)","description":"A gift card's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of a gift card.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of gift cards. The gift cards can be filtered by fields such as `q` passed in the `query` parameter. The gift cards can also paginated.
#### Example
To list gift cards:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.giftCards.list()
.then(({ gift_cards, limit, offset, count }) => {
console.log(gift_cards.length);
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.giftCards.list({
limit,
offset
})
.then(({ gift_cards, limit, offset, count }) => {
console.log(gift_cards.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetGiftCardsParams](../../../medusa/classes/medusa.AdminGetGiftCardsParams/page.mdx)","description":"Filters and pagination configurations to apply on the retrieved gift cards.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":false,"defaultValue":"50","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":false,"defaultValue":"0","expandable":false,"children":[]},{"name":"q","type":"`string`","description":"Search term to search gift cards by their code and display ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminGiftCardsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of gift cards with pagination fields.","expandable":false,"children":[{"name":"AdminGiftCardsListRes","type":"[AdminGiftCardsListRes](../../../medusa/types/medusa.AdminGiftCardsListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of gift cards with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"gift_cards","type":"[GiftCard](../../../medusa/classes/medusa.GiftCard/page.mdx)[]","description":"The list of gift cards.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of a gift card.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
@@ -0,0 +1,262 @@
---
slug: /references/js-client/AdminInventoryItemsResource
---
import { TypeList } from "docs-ui"
# AdminInventoryItemsResource
This class is used to send requests to [Admin Inventory Item API Routes](https://docs.medusajs.com/api/admin#inventory-items). To use these API Routes, make sure to install the
[@medusajs/inventory](https://docs.medusajs.com/modules/multiwarehouse/install-modules#inventory-module) module in your Medusa backend. All its method
are available in the JS Client under the `medusa.admin.inventoryItems` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Inventory items, provided by the [Inventory Module](https://docs.medusajs.com/modules/multiwarehouse/inventory-module), can be used to manage the inventory of saleable items in your store.
Related Guide: [How to manage inventory items](https://docs.medusajs.com/modules/multiwarehouse/admin/manage-inventory-items).
## Methods
### retrieve
Retrieve an Inventory Item's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.inventoryItems.retrieve(inventoryItemId)
.then(({ inventory_item }) => {
console.log(inventory_item.id);
})
```
#### Parameters
<TypeList types={[{"name":"inventoryItemId","type":"`string`","description":"The ID of the inventory item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetInventoryItemsItemParams](../../../medusa/classes/medusa.AdminGetInventoryItemsItemParams/page.mdx)","description":"Configurations applied on the retrieved inventory item.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminInventoryItemsRes&#62;","optional":false,"defaultValue":"","description":"The inventory item's details.","expandable":false,"children":[{"name":"AdminInventoryItemsRes","type":"[AdminInventoryItemsRes](../../../medusa/types/medusa.AdminInventoryItemsRes/page.mdx)","optional":false,"defaultValue":"","description":"The inventory item's details.","expandable":false,"children":[{"name":"inventory_item","type":"[InventoryItemDTO](../../../medusa/types/medusa.InventoryItemDTO/page.mdx)","description":"Inventory Item details","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The inventory item's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"requires_shipping","type":"`boolean`","description":"Whether the item requires shipping.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The date with timezone at which the resource was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The date with timezone at which the resource was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date` \\| `null`","description":"The date with timezone at which the resource was deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"sku","type":"`string` \\| `null`","description":"The Stock Keeping Unit (SKU) code of the Inventory Item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`string` \\| `null`","description":"The country in which the Inventory Item was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"hs_code","type":"`string` \\| `null`","description":"The Harmonized System code of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"mid_code","type":"`string` \\| `null`","description":"The Manufacturers Identification code that identifies the manufacturer of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"material","type":"`string` \\| `null`","description":"The material and composition that the Inventory Item is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`number` \\| `null`","description":"The weight of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`number` \\| `null`","description":"The length of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`number` \\| `null`","description":"The height of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`number` \\| `null`","description":"The width of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string` \\| `null`","description":"Title of the inventory item","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string` \\| `null`","description":"Description of the inventory item","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`string` \\| `null`","description":"Thumbnail for the inventory item","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>` \\| `null`","description":"An optional key-value map with additional details","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### update
Update an Inventory Item's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.inventoryItems.update(inventoryItemId, {
origin_country: "US",
})
.then(({ inventory_item }) => {
console.log(inventory_item.id);
})
```
#### Parameters
<TypeList types={[{"name":"inventoryItemId","type":"`string`","description":"The ID of the inventory item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostInventoryItemsInventoryItemReq](../../../medusa/classes/medusa.AdminPostInventoryItemsInventoryItemReq/page.mdx)","description":"The attributes to update in the inventory item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"sku","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`string`","description":"The country in which the Inventory Item was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"hs_code","type":"`string`","description":"The Harmonized System code of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"mid_code","type":"`string`","description":"The Manufacturers Identification code that identifies the manufacturer of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"material","type":"`string`","description":"The material and composition that the Inventory Item is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`number`","description":"The weight of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`number`","description":"The height of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`number`","description":"The length of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`number`","description":"The width of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The inventory item's title.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The inventory item's description.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`string`","description":"The inventory item's thumbnail.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"requires_shipping","type":"`boolean`","description":"Whether the item requires shipping.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminPostInventoryItemsInventoryItemParams](../../../medusa/classes/medusa.AdminPostInventoryItemsInventoryItemParams/page.mdx)","description":"Configurations to apply on the retrieved inventory item.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminInventoryItemsRes&#62;","optional":false,"defaultValue":"","description":"The inventory item's details.","expandable":false,"children":[{"name":"AdminInventoryItemsRes","type":"[AdminInventoryItemsRes](../../../medusa/types/medusa.AdminInventoryItemsRes/page.mdx)","optional":false,"defaultValue":"","description":"The inventory item's details.","expandable":false,"children":[{"name":"inventory_item","type":"[InventoryItemDTO](../../../medusa/types/medusa.InventoryItemDTO/page.mdx)","description":"Inventory Item details","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The inventory item's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"requires_shipping","type":"`boolean`","description":"Whether the item requires shipping.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The date with timezone at which the resource was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The date with timezone at which the resource was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date` \\| `null`","description":"The date with timezone at which the resource was deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"sku","type":"`string` \\| `null`","description":"The Stock Keeping Unit (SKU) code of the Inventory Item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`string` \\| `null`","description":"The country in which the Inventory Item was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"hs_code","type":"`string` \\| `null`","description":"The Harmonized System code of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"mid_code","type":"`string` \\| `null`","description":"The Manufacturers Identification code that identifies the manufacturer of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"material","type":"`string` \\| `null`","description":"The material and composition that the Inventory Item is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`number` \\| `null`","description":"The weight of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`number` \\| `null`","description":"The length of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`number` \\| `null`","description":"The height of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`number` \\| `null`","description":"The width of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string` \\| `null`","description":"Title of the inventory item","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string` \\| `null`","description":"Description of the inventory item","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`string` \\| `null`","description":"Thumbnail for the inventory item","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>` \\| `null`","description":"An optional key-value map with additional details","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete an Inventory Item. This does not delete the associated product variant.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.inventoryItems.delete(inventoryItemId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
#### Parameters
<TypeList types={[{"name":"inventoryItemId","type":"`string`","description":"The ID of the inventory item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"The deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"[DeleteResponse](../../../medusa/interfaces/medusa.DeleteResponse/page.mdx)","optional":false,"defaultValue":"","description":"The response returned for a \n\n`DELETE`\n\n request.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the deleted item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the deleted item.","optional":false,"defaultValue":"product-collection","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether the item was deleted successfully.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### create
Create an Inventory Item for a product variant.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.inventoryItems.create({
variant_id: "variant_123",
})
.then(({ inventory_item }) => {
console.log(inventory_item.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostInventoryItemsReq](../../../medusa/classes/medusa.AdminPostInventoryItemsReq/page.mdx)","description":"The inventory item to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"variant_id","type":"`string`","description":"The ID of the variant to create the inventory item for.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"sku","type":"`string`","description":"The unique SKU of the associated Product Variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"hs_code","type":"`string`","description":"The Harmonized System code of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`number`","description":"The weight of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`number`","description":"The length of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`number`","description":"The height of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`number`","description":"The width of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`string`","description":"The country in which the Inventory Item was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"mid_code","type":"`string`","description":"The Manufacturers Identification code that identifies the manufacturer of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"material","type":"`string`","description":"The material and composition that the Inventory Item is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"The inventory item's title.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The inventory item's description.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`string`","description":"The inventory item's thumbnail.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs with additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminPostInventoryItemsParams](../../../medusa/classes/medusa.AdminPostInventoryItemsParams/page.mdx)","description":"Configurations to apply on the retrieved inventory item.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminInventoryItemsRes&#62;","optional":false,"defaultValue":"","description":"The inventory item's details.","expandable":false,"children":[{"name":"AdminInventoryItemsRes","type":"[AdminInventoryItemsRes](../../../medusa/types/medusa.AdminInventoryItemsRes/page.mdx)","optional":false,"defaultValue":"","description":"The inventory item's details.","expandable":false,"children":[{"name":"inventory_item","type":"[InventoryItemDTO](../../../medusa/types/medusa.InventoryItemDTO/page.mdx)","description":"Inventory Item details","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The inventory item's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"requires_shipping","type":"`boolean`","description":"Whether the item requires shipping.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The date with timezone at which the resource was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The date with timezone at which the resource was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date` \\| `null`","description":"The date with timezone at which the resource was deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"sku","type":"`string` \\| `null`","description":"The Stock Keeping Unit (SKU) code of the Inventory Item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`string` \\| `null`","description":"The country in which the Inventory Item was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"hs_code","type":"`string` \\| `null`","description":"The Harmonized System code of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"mid_code","type":"`string` \\| `null`","description":"The Manufacturers Identification code that identifies the manufacturer of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"material","type":"`string` \\| `null`","description":"The material and composition that the Inventory Item is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`number` \\| `null`","description":"The weight of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`number` \\| `null`","description":"The length of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`number` \\| `null`","description":"The height of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`number` \\| `null`","description":"The width of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string` \\| `null`","description":"Title of the inventory item","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string` \\| `null`","description":"Description of the inventory item","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`string` \\| `null`","description":"Thumbnail for the inventory item","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>` \\| `null`","description":"An optional key-value map with additional details","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### list
Retrieve a list of inventory items. The inventory items can be filtered by fields such as `q` or `location_id` passed in the `query` parameter.
The inventory items can also be paginated.
#### Example
To list inventory items:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.inventoryItems.list()
.then(({ inventory_items, count, offset, limit }) => {
console.log(inventory_items.length);
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.inventoryItems.list({
limit,
offset
})
.then(({ inventory_items, count, offset, limit }) => {
console.log(inventory_items.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetInventoryItemsParams](../../../medusa/classes/medusa.AdminGetInventoryItemsParams/page.mdx)","description":"Filters and pagination configurations applied on the retrieved inventory items.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string` \\| `string`[]","description":"IDs to filter inventory items by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"q","type":"`string`","description":"Search terms to search inventory items' sku, title, and description.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"location_id","type":"`string` \\| `string`[]","description":"Location IDs to filter inventory items by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"sku","type":"`string` \\| `string`[]","description":"SKUs to filter inventory items by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`string` \\| `string`[]","description":"Origin countries to filter inventory items by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"mid_code","type":"`string` \\| `string`[]","description":"MID codes to filter inventory items by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"material","type":"`string` \\| `string`[]","description":"Materials to filter inventory items by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"hs_code","type":"`string` \\| `string`[] \\| [StringComparisonOperator](../../../medusa/classes/medusa.StringComparisonOperator/page.mdx)","description":"String filters to apply to inventory items' `hs_code` field.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`number` \\| [NumericalComparisonOperator](../../../medusa/classes/medusa.NumericalComparisonOperator/page.mdx)","description":"Number filters to apply to inventory items' `weight` field.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`number` \\| [NumericalComparisonOperator](../../../medusa/classes/medusa.NumericalComparisonOperator/page.mdx)","description":"Number filters to apply to inventory items' `length` field.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`number` \\| [NumericalComparisonOperator](../../../medusa/classes/medusa.NumericalComparisonOperator/page.mdx)","description":"Number filters to apply to inventory items' `height` field.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`number` \\| [NumericalComparisonOperator](../../../medusa/classes/medusa.NumericalComparisonOperator/page.mdx)","description":"Number filters to apply to inventory items' `width` field.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"requires_shipping","type":"`boolean`","description":"Filter inventory items by whether they require shipping.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":true,"defaultValue":"20","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminInventoryItemsListWithVariantsAndLocationLevelsRes&#62;","optional":false,"defaultValue":"","description":"The list of inventory items with pagination fields.","expandable":false,"children":[{"name":"AdminInventoryItemsListWithVariantsAndLocationLevelsRes","type":"[AdminInventoryItemsListWithVariantsAndLocationLevelsRes](../../../medusa/types/medusa.AdminInventoryItemsListWithVariantsAndLocationLevelsRes/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"inventory_items","type":"[DecoratedInventoryItemDTO](../../../medusa/types/medusa.DecoratedInventoryItemDTO/page.mdx)[]","description":"an array of Inventory Item details","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"stocked_quantity","type":"`number`","description":"The total quantity of the item in stock across levels","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reserved_quantity","type":"`number`","description":"The total quantity of the item available across levels","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"location_levels","type":"[InventoryLevelDTO](../../../medusa/types/medusa.InventoryLevelDTO/page.mdx)[]","description":"An array of location level details","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"inventory_item_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"location_id","type":"`string`","description":"the item location ID","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"stocked_quantity","type":"`number`","description":"the total stock quantity of an inventory item at the given location ID","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reserved_quantity","type":"`number`","description":"the reserved stock quantity of an inventory item at the given location ID","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"incoming_quantity","type":"`number`","description":"the incoming stock quantity of an inventory item at the given location ID","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>` \\| `null`","description":"An optional key-value map with additional details","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The date with timezone at which the resource was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The date with timezone at which the resource was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date` \\| `null`","description":"The date with timezone at which the resource was deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"variants","type":"[ProductVariant](../../../medusa_react/types/medusa_react.ProductVariant/page.mdx)[]","description":"An array of product variant details","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### updateLocationLevel
Update a location level's details for a given inventory item.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.inventoryItems.updateLocationLevel(inventoryItemId, locationId, {
stocked_quantity: 15,
})
.then(({ inventory_item }) => {
console.log(inventory_item.id);
})
```
#### Parameters
<TypeList types={[{"name":"inventoryItemId","type":"`string`","description":"The ID of the inventory item that the location level belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"locationId","type":"`string`","description":"The ID of the location level to update.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostInventoryItemsItemLocationLevelsLevelReq](../../../medusa/classes/medusa.AdminPostInventoryItemsItemLocationLevelsLevelReq/page.mdx)","description":"The attributes to update in the location level.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"incoming_quantity","type":"`number`","description":"the incoming stock quantity of an inventory item at the given location ID","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"stocked_quantity","type":"`number`","description":"the total stock quantity of an inventory item at the given location ID","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminPostInventoryItemsItemLocationLevelsLevelParams](../../../medusa/classes/medusa.AdminPostInventoryItemsItemLocationLevelsLevelParams/page.mdx)","description":"Configurations to apply on the returned inventory item.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateLocationLevel"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminInventoryItemsRes&#62;","optional":false,"defaultValue":"","description":"the inventory item's details.","expandable":false,"children":[{"name":"AdminInventoryItemsRes","type":"[AdminInventoryItemsRes](../../../medusa/types/medusa.AdminInventoryItemsRes/page.mdx)","optional":false,"defaultValue":"","description":"The inventory item's details.","expandable":false,"children":[{"name":"inventory_item","type":"[InventoryItemDTO](../../../medusa/types/medusa.InventoryItemDTO/page.mdx)","description":"Inventory Item details","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The inventory item's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"requires_shipping","type":"`boolean`","description":"Whether the item requires shipping.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The date with timezone at which the resource was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The date with timezone at which the resource was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date` \\| `null`","description":"The date with timezone at which the resource was deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"sku","type":"`string` \\| `null`","description":"The Stock Keeping Unit (SKU) code of the Inventory Item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`string` \\| `null`","description":"The country in which the Inventory Item was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"hs_code","type":"`string` \\| `null`","description":"The Harmonized System code of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"mid_code","type":"`string` \\| `null`","description":"The Manufacturers Identification code that identifies the manufacturer of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"material","type":"`string` \\| `null`","description":"The material and composition that the Inventory Item is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`number` \\| `null`","description":"The weight of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`number` \\| `null`","description":"The length of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`number` \\| `null`","description":"The height of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`number` \\| `null`","description":"The width of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string` \\| `null`","description":"Title of the inventory item","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string` \\| `null`","description":"Description of the inventory item","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`string` \\| `null`","description":"Thumbnail for the inventory item","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>` \\| `null`","description":"An optional key-value map with additional details","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateLocationLevel"/>
### createLocationLevel
Create a Location Level for a given Inventory Item.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.inventoryItems.createLocationLevel(inventoryItemId, {
location_id: "sloc_123",
stocked_quantity: 10,
})
.then(({ inventory_item }) => {
console.log(inventory_item.id);
})
```
#### Parameters
<TypeList types={[{"name":"inventoryItemId","type":"`string`","description":"The ID of the inventory item that the location level belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostInventoryItemsItemLocationLevelsReq](../../../medusa/classes/medusa.AdminPostInventoryItemsItemLocationLevelsReq/page.mdx)","description":"The location level to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"location_id","type":"`string`","description":"the ID of the stock location","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"stocked_quantity","type":"`number`","description":"the stock quantity of the inventory item at this location","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"incoming_quantity","type":"`number`","description":"the incoming stock quantity of the inventory item at this location","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminPostInventoryItemsItemLocationLevelsParams](../../../medusa/classes/medusa.AdminPostInventoryItemsItemLocationLevelsParams/page.mdx)","description":"Configurations to apply on the returned inventory item.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createLocationLevel"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminInventoryItemsRes&#62;","optional":false,"defaultValue":"","description":"the inventory item's details.","expandable":false,"children":[{"name":"AdminInventoryItemsRes","type":"[AdminInventoryItemsRes](../../../medusa/types/medusa.AdminInventoryItemsRes/page.mdx)","optional":false,"defaultValue":"","description":"The inventory item's details.","expandable":false,"children":[{"name":"inventory_item","type":"[InventoryItemDTO](../../../medusa/types/medusa.InventoryItemDTO/page.mdx)","description":"Inventory Item details","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The inventory item's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"requires_shipping","type":"`boolean`","description":"Whether the item requires shipping.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The date with timezone at which the resource was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The date with timezone at which the resource was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date` \\| `null`","description":"The date with timezone at which the resource was deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"sku","type":"`string` \\| `null`","description":"The Stock Keeping Unit (SKU) code of the Inventory Item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`string` \\| `null`","description":"The country in which the Inventory Item was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"hs_code","type":"`string` \\| `null`","description":"The Harmonized System code of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"mid_code","type":"`string` \\| `null`","description":"The Manufacturers Identification code that identifies the manufacturer of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"material","type":"`string` \\| `null`","description":"The material and composition that the Inventory Item is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`number` \\| `null`","description":"The weight of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`number` \\| `null`","description":"The length of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`number` \\| `null`","description":"The height of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`number` \\| `null`","description":"The width of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string` \\| `null`","description":"Title of the inventory item","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string` \\| `null`","description":"Description of the inventory item","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`string` \\| `null`","description":"Thumbnail for the inventory item","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>` \\| `null`","description":"An optional key-value map with additional details","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createLocationLevel"/>
### deleteLocationLevel
Delete a location level of an Inventory Item.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.inventoryItems.deleteLocationLevel(inventoryItemId, locationId)
.then(({ inventory_item }) => {
console.log(inventory_item.id);
})
```
#### Parameters
<TypeList types={[{"name":"inventoryItemId","type":"`string`","description":"The ID of the inventory item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"locationId","type":"`string`","description":"The ID of the location level to delete.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteLocationLevel"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminInventoryItemsRes&#62;","optional":false,"defaultValue":"","description":"the inventory item's details.","expandable":false,"children":[{"name":"AdminInventoryItemsRes","type":"[AdminInventoryItemsRes](../../../medusa/types/medusa.AdminInventoryItemsRes/page.mdx)","optional":false,"defaultValue":"","description":"The inventory item's details.","expandable":false,"children":[{"name":"inventory_item","type":"[InventoryItemDTO](../../../medusa/types/medusa.InventoryItemDTO/page.mdx)","description":"Inventory Item details","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The inventory item's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"requires_shipping","type":"`boolean`","description":"Whether the item requires shipping.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The date with timezone at which the resource was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The date with timezone at which the resource was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date` \\| `null`","description":"The date with timezone at which the resource was deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"sku","type":"`string` \\| `null`","description":"The Stock Keeping Unit (SKU) code of the Inventory Item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`string` \\| `null`","description":"The country in which the Inventory Item was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"hs_code","type":"`string` \\| `null`","description":"The Harmonized System code of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"mid_code","type":"`string` \\| `null`","description":"The Manufacturers Identification code that identifies the manufacturer of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"material","type":"`string` \\| `null`","description":"The material and composition that the Inventory Item is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`number` \\| `null`","description":"The weight of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`number` \\| `null`","description":"The length of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`number` \\| `null`","description":"The height of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`number` \\| `null`","description":"The width of the Inventory Item. May be used in shipping rate calculations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string` \\| `null`","description":"Title of the inventory item","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string` \\| `null`","description":"Description of the inventory item","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`string` \\| `null`","description":"Thumbnail for the inventory item","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>` \\| `null`","description":"An optional key-value map with additional details","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteLocationLevel"/>
### listLocationLevels
Retrieve a list of inventory levels of an inventory item. The inventory levels can be filtered by fields such as `location_id` passed in the `query` parameter.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.inventoryItems.listLocationLevels(inventoryItemId)
.then(({ inventory_item }) => {
console.log(inventory_item.location_levels);
})
```
#### Parameters
<TypeList types={[{"name":"inventoryItemId","type":"`string`","description":"The ID of the inventory item that the location levels belong to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetInventoryItemsItemLocationLevelsParams](../../../medusa/classes/medusa.AdminGetInventoryItemsItemLocationLevelsParams/page.mdx)","description":"Filters to apply on the retrieved location levels.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"location_id","type":"`string`[]","description":"Location IDs to filter location levels.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listLocationLevels"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminInventoryItemsLocationLevelsRes&#62;","optional":false,"defaultValue":"","description":"The inventory item's details and list of location levels.","expandable":false,"children":[{"name":"AdminInventoryItemsLocationLevelsRes","type":"[AdminInventoryItemsLocationLevelsRes](../../../medusa/types/medusa.AdminInventoryItemsLocationLevelsRes/page.mdx)","optional":false,"defaultValue":"","description":"Details of inventory items and their associated location levels.","expandable":false,"children":[{"name":"inventory_item","type":"`object`","description":"An inventory item's ID and associated location levels.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`any`","description":"The id of the location","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"location_levels","type":"[InventoryLevelDTO](../../../medusa/types/medusa.InventoryLevelDTO/page.mdx)[]","description":"List of stock levels at a given location","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"inventory_item_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"location_id","type":"`string`","description":"the item location ID","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"stocked_quantity","type":"`number`","description":"the total stock quantity of an inventory item at the given location ID","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reserved_quantity","type":"`number`","description":"the reserved stock quantity of an inventory item at the given location ID","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"incoming_quantity","type":"`number`","description":"the incoming stock quantity of an inventory item at the given location ID","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>` \\| `null`","description":"An optional key-value map with additional details","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The date with timezone at which the resource was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The date with timezone at which the resource was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date` \\| `null`","description":"The date with timezone at which the resource was deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listLocationLevels"/>
@@ -0,0 +1,161 @@
---
slug: /references/js-client/AdminInvitesResource
---
import { TypeList } from "docs-ui"
# AdminInvitesResource
This class is used to send requests to [Admin Invite API Routes](https://docs.medusajs.com/api/admin#invites). All its method
are available in the JS Client under the `medusa.admin.invites` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
An admin can invite new users to manage their team. This would allow new users to authenticate as admins and perform admin functionalities.
Related Guide: [How to manage invites](https://docs.medusajs.com/modules/users/admin/manage-invites).
## Methods
### accept
Accept an Invite. This will also delete the invite and create a new user that can log in and perform admin functionalities.
The user will have the email associated with the invite, and the password provided in the `payload` parameter.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.invites.accept({
token,
user: {
first_name: "Brigitte",
last_name: "Collier",
password: "supersecret"
}
})
.then(() => {
// successful
})
.catch(() => {
// an error occurred
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostInvitesInviteAcceptReq](../../../medusa/classes/medusa.AdminPostInvitesInviteAcceptReq/page.mdx)","description":"The user accepting the invite.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"token","type":"`string`","description":"The token of the invite to accept. This is a unique token generated when the invite was created or resent.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"user","type":"[AdminPostInvitesInviteAcceptUserReq](../../../medusa/classes/medusa.AdminPostInvitesInviteAcceptUserReq/page.mdx)","description":"The details of the user to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"first_name","type":"`string`","description":"The invite's first name.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`string`","description":"The invite's last name.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"password","type":"`string`","description":"The invite's password","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="accept"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"`ResponsePromise`","optional":false,"defaultValue":"","description":"Resolves when the invite is accepted successfully.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="accept"/>
### create
Create an invite. This will generate a token associated with the invite and trigger an `invite.created` event. If you have a Notification Provider installed that handles this
event, a notification should be sent to the email associated with the invite to allow them to accept the invite.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.invites.create({
user: "user@example.com",
role: "admin"
})
.then(() => {
// successful
})
.catch(() => {
// an error occurred
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostInvitesPayload`","description":"The invite to be created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"`ResponsePromise`","optional":false,"defaultValue":"","description":"Resolves when the invite is created successfully.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### delete
Delete an invite. Only invites that weren't accepted can be deleted.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.invites.delete(inviteId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The invite's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"[DeleteResponse](../../../medusa/interfaces/medusa.DeleteResponse/page.mdx)","optional":false,"defaultValue":"","description":"The response returned for a \n\n`DELETE`\n\n request.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the deleted item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the deleted item.","optional":false,"defaultValue":"product-collection","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether the item was deleted successfully.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### list
Retrieve a list of invites.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.invites.list()
.then(({ invites }) => {
console.log(invites.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminListInvitesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of invites.","expandable":false,"children":[{"name":"AdminListInvitesRes","type":"[AdminListInvitesRes](../../../medusa/types/medusa.AdminListInvitesRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of invites.","expandable":false,"children":[{"name":"invites","type":"[Invite](../../../user_models/classes/user_models.Invite/page.mdx)[]","description":"An array of invites","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"`OptionalFields`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"accepted","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"token","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"expires_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### resend
Resend an invite. This renews the expiry date by seven days and generates a new token for the invite. It also triggers the `invite.created` event,
so if you have a Notification Provider installed that handles this event, a notification should be sent to the email associated with the
invite to allow them to accept the invite.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.invites.resend(inviteId)
.then(() => {
// successful
})
.catch(() => {
// an error occurred
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The invite's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="resend"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"`ResponsePromise`","optional":false,"defaultValue":"","description":"Resolves when the invite is resent successfully.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="resend"/>
@@ -0,0 +1,159 @@
---
slug: /references/js-client/AdminNotesResource
---
import { TypeList } from "docs-ui"
# AdminNotesResource
This class is used to send requests to [Admin Note API Routes](https://docs.medusajs.com/api/admin#notes). All its method
are available in the JS Client under the `medusa.admin.notes` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Notes are created by admins and can be associated with any resource. For example, an admin can add a note to an order for additional details or remarks.
## Methods
### create
Create a Note which can be associated with any resource.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notes.create({
resource_id,
resource_type: "order",
value: "We delivered this order"
})
.then(({ note }) => {
console.log(note.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostNotesReq](../../../medusa/classes/medusa.AdminPostNotesReq/page.mdx)","description":"The note to be created.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"resource_id","type":"`string`","description":"The ID of the resource which the Note relates to. For example, an order ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"resource_type","type":"`string`","description":"The type of resource which the Note relates to. For example, `order`.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string`","description":"The content of the Note to create.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminNotesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the note's details.","expandable":false,"children":[{"name":"AdminNotesRes","type":"[AdminNotesRes](../../../medusa/types/medusa.AdminNotesRes/page.mdx)","optional":false,"defaultValue":"","description":"The note's details.","expandable":false,"children":[{"name":"note","type":"`Note`","description":"Note details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update a Note's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notes.update(noteId, {
value: "We delivered this order"
})
.then(({ note }) => {
console.log(note.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The note's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostNotesNoteReq](../../../medusa/classes/medusa.AdminPostNotesNoteReq/page.mdx)","description":"The attributes to update in the note.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string`","description":"The description of the Note.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminNotesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the note's details.","expandable":false,"children":[{"name":"AdminNotesRes","type":"[AdminNotesRes](../../../medusa/types/medusa.AdminNotesRes/page.mdx)","optional":false,"defaultValue":"","description":"The note's details.","expandable":false,"children":[{"name":"note","type":"`Note`","description":"Note details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete a Note.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notes.delete(noteId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The note's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"[DeleteResponse](../../../medusa/interfaces/medusa.DeleteResponse/page.mdx)","optional":false,"defaultValue":"","description":"The response returned for a \n\n`DELETE`\n\n request.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the deleted item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the deleted item.","optional":false,"defaultValue":"product-collection","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether the item was deleted successfully.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### retrieve
Retrieve a note's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notes.retrieve(noteId)
.then(({ note }) => {
console.log(note.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The note's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminNotesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the note's details.","expandable":false,"children":[{"name":"AdminNotesRes","type":"[AdminNotesRes](../../../medusa/types/medusa.AdminNotesRes/page.mdx)","optional":false,"defaultValue":"","description":"The note's details.","expandable":false,"children":[{"name":"note","type":"`Note`","description":"Note details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of notes. The notes can be filtered by fields such as `resource_id` passed in the `query` parameter. The notes can also be paginated.
#### Example
To list notes:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notes.list()
.then(({ notes, limit, offset, count }) => {
console.log(notes.length);
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notes.list({
limit,
offset
})
.then(({ notes, limit, offset, count }) => {
console.log(notes.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetNotesParams](../../../medusa/classes/medusa.AdminGetNotesParams/page.mdx)","description":"Filters and pagination configurations applied on retrieved notes.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":false,"defaultValue":"50","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":false,"defaultValue":"0","expandable":false,"children":[]},{"name":"resource_id","type":"`string`","description":"Resource ID to filter notes by.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminNotesListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of notes with pagination fields.","expandable":false,"children":[{"name":"AdminNotesListRes","type":"[AdminNotesListRes](../../../medusa/types/medusa.AdminNotesListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of notes with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"notes","type":"`Note`[]","description":"An array of notes","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
@@ -0,0 +1,98 @@
---
slug: /references/js-client/AdminNotificationsResource
---
import { TypeList } from "docs-ui"
# AdminNotificationsResource
This class is used to send requests to [Admin Notification API Routes](https://docs.medusajs.com/api/admin#notifications). All its method
are available in the JS Client under the `medusa.admin.notifications` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Notifications are sent to customers to inform them of new updates. For example, a notification can be sent to the customer when their order is place or its state is updated.
The notification's type, such as an email or SMS, is determined by the notification provider installed on the Medusa backend.
## Methods
### list
Retrieve a list of notifications. The notifications can be filtered by fields such as `event_name` or `resource_type` passed in the `query` parameter.
The notifications can also be paginated.
#### Example
To list notifications:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notifications.list()
.then(({ notifications }) => {
console.log(notifications.length);
})
```
To specify relations that should be retrieved within the notifications:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notifications.list({
expand: "provider"
})
.then(({ notifications }) => {
console.log(notifications.length);
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notifications.list({
expand: "provider",
limit,
offset
})
.then(({ notifications }) => {
console.log(notifications.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetNotificationsParams](../../../medusa/classes/medusa.AdminGetNotificationsParams/page.mdx)","description":"Filters and pagination configurations applied to the retrieved notifications.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":true,"defaultValue":"50","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"event_name","type":"`string`","description":"Event name to filter notifications by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"resource_type","type":"`string`","description":"Resource type to filter notifications by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"resource_id","type":"`string`","description":"Resource ID to filter notifications by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"to","type":"`string`","description":"Filter notifications by their `to` field.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"include_resends","type":"`string`","description":"Whether to include resends in the results.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminNotificationsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of notifications with pagination fields.","expandable":false,"children":[{"name":"AdminNotificationsListRes","type":"[AdminNotificationsListRes](../../../medusa/types/medusa.AdminNotificationsListRes/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The limit applied on the retrieved items.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before retrieving the list of items.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total count of items.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"notifications","type":"`Notification`[]","description":"an array of notifications","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### resend
Resend a previously sent notifications, with the same data but optionally to a different address.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notifications.resend(notificationId)
.then(({ notification }) => {
console.log(notification.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The notification's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostNotificationsNotificationResendReq](../../../medusa/classes/medusa.AdminPostNotificationsNotificationResendReq/page.mdx)","description":"The details necessary to resend the notification.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"to","type":"`string`","description":"A new address or user identifier that the Notification should be sent to. If not provided, the previous `to` field of the notification will be used.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="resend"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminNotificationsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the notification's details.","expandable":false,"children":[{"name":"AdminNotificationsRes","type":"[AdminNotificationsRes](../../../medusa/types/medusa.AdminNotificationsRes/page.mdx)","optional":false,"defaultValue":"","description":"The notification's details.","expandable":false,"children":[{"name":"notification","type":"`Notification`","description":"Notification details","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="resend"/>
@@ -0,0 +1,365 @@
---
slug: /references/js-client/AdminOrderEditsResource
---
import { TypeList } from "docs-ui"
# AdminOrderEditsResource
This class is used to send requests to [Admin Order Edit API Routes](https://docs.medusajs.com/api/admin#order-edits). All its method
are available in the JS Client under the `medusa.admin.orderEdits` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
An admin can edit an order to remove, add, or update an item's quantity. When an admin edits an order, they're stored as an `OrderEdit`.
Related Guide: [How to edit an order](https://docs.medusajs.com/modules/orders/admin/edit-order).
## Methods
### retrieve
Retrieve an order edit's details.
#### Example
A simple example that retrieves an order edit by its ID:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.retrieve(orderEditId)
.then(({ order_edit }) => {
console.log(order_edit.id)
})
```
To specify relations that should be retrieved:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.retrieve(orderEditId, {
expand: "order"
})
.then(({ order_edit }) => {
console.log(order_edit.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order edit.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[GetOrderEditsOrderEditParams](../../../medusa/classes/medusa.GetOrderEditsOrderEditParams/page.mdx)","description":"Configurations to apply on the retrieved order edit.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrderEditsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order edit's details.","expandable":false,"children":[{"name":"AdminOrderEditsRes","type":"[AdminOrderEditsRes](../../../medusa/types/medusa.AdminOrderEditsRes/page.mdx)","optional":false,"defaultValue":"","description":"The order edit details.","expandable":false,"children":[{"name":"order_edit","type":"`OrderEdit`","description":"Order edit details","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of order edits. The order edits can be filtered by fields such as `q` or `order_id` passed to the `query` parameter. The order edits can also be paginated.
#### Example
To list order edits:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.list()
.then(({ order_edits, count, limit, offset }) => {
console.log(order_edits.length)
})
```
To specify relations that should be retrieved within the order edits:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.list({
expand: "order"
})
.then(({ order_edits, count, limit, offset }) => {
console.log(order_edits.length)
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.list({
expand: "order",
limit,
offset
})
.then(({ order_edits, count, limit, offset }) => {
console.log(order_edits.length)
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[GetOrderEditsParams](../../../medusa/classes/medusa.GetOrderEditsParams/page.mdx)","description":"Filters and pagination configurations applied to retrieved order edits.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Search term to search order edits by their internal note.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order_id","type":"`string`","description":"Filter the order edits by their associated order's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":true,"defaultValue":"20","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrderEditsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of order edits with pagination fields.","expandable":false,"children":[{"name":"AdminOrderEditsListRes","type":"[AdminOrderEditsListRes](../../../medusa/types/medusa.AdminOrderEditsListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of order edits with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"order_edits","type":"`OrderEdit`[]","description":"An array of order edit details","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### create
Create an order edit.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.create({ orderId })
.then(({ order_edit }) => {
console.log(order_edit.id)
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostOrderEditsReq](../../../medusa/classes/medusa.AdminPostOrderEditsReq/page.mdx)","description":"The order edit to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"order_id","type":"`string`","description":"The ID of the order to create the edit for.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"internal_note","type":"`string`","description":"An optional note to associate with the order edit.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrderEditsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order edit's details.","expandable":false,"children":[{"name":"AdminOrderEditsRes","type":"[AdminOrderEditsRes](../../../medusa/types/medusa.AdminOrderEditsRes/page.mdx)","optional":false,"defaultValue":"","description":"The order edit details.","expandable":false,"children":[{"name":"order_edit","type":"`OrderEdit`","description":"Order edit details","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update an Order Edit's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.update(orderEditId, {
internal_note: "internal reason XY"
})
.then(({ order_edit }) => {
console.log(order_edit.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order edit.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostOrderEditsOrderEditReq](../../../medusa/classes/medusa.AdminPostOrderEditsOrderEditReq/page.mdx)","description":"The attributes to update in an order edit.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"internal_note","type":"`string`","description":"An optional note to create or update in the order edit.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrderEditsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order edit's details.","expandable":false,"children":[{"name":"AdminOrderEditsRes","type":"[AdminOrderEditsRes](../../../medusa/types/medusa.AdminOrderEditsRes/page.mdx)","optional":false,"defaultValue":"","description":"The order edit details.","expandable":false,"children":[{"name":"order_edit","type":"`OrderEdit`","description":"Order edit details","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete an order edit. Only order edits that have the status `created` can be deleted.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.delete(orderEditId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order edit.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"[DeleteResponse](../../../medusa/interfaces/medusa.DeleteResponse/page.mdx)","optional":false,"defaultValue":"","description":"The response returned for a \n\n`DELETE`\n\n request.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the deleted item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the deleted item.","optional":false,"defaultValue":"product-collection","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether the item was deleted successfully.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### addLineItem
Create a line item change in the order edit that indicates adding an item in the original order. The item will not be added to the original order until the order edit is
confirmed.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.addLineItem(orderEditId, {
variant_id,
quantity
})
.then(({ order_edit }) => {
console.log(order_edit.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order edit to add the line item change to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostOrderEditsEditLineItemsReq](../../../medusa/classes/medusa.AdminPostOrderEditsEditLineItemsReq/page.mdx)","description":"The line item change to be created.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"variant_id","type":"`string`","description":"The ID of the product variant associated with the item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"`number`","description":"The quantity of the item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs to hold additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addLineItem"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrderEditsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order edit's details.","expandable":false,"children":[{"name":"AdminOrderEditsRes","type":"[AdminOrderEditsRes](../../../medusa/types/medusa.AdminOrderEditsRes/page.mdx)","optional":false,"defaultValue":"","description":"The order edit details.","expandable":false,"children":[{"name":"order_edit","type":"`OrderEdit`","description":"Order edit details","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addLineItem"/>
### deleteItemChange
Delete a line item change that indicates the addition, deletion, or update of a line item in the original order.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.deleteItemChange(orderEdit_id, itemChangeId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
#### Parameters
<TypeList types={[{"name":"orderEditId","type":"`string`","description":"The ID of the order edit.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"itemChangeId","type":"`string`","description":"The ID of the line item change.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteItemChange"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrderEditItemChangeDeleteRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"AdminOrderEditItemChangeDeleteRes","type":"[AdminOrderEditItemChangeDeleteRes](../../../medusa/types/medusa.AdminOrderEditItemChangeDeleteRes/page.mdx)","optional":false,"defaultValue":"","description":"The details of deleting order edit item changes.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the deleted Order Edit Item Change.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`\"item_change\"`","description":"The type of the object that was deleted.","optional":false,"defaultValue":"item_change","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether or not the Order Edit Item Change was deleted.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteItemChange"/>
### requestConfirmation
Request customer confirmation of an order edit. This would emit the event `order-edit.requested` which Notification Providers listen to and send
a notification to the customer about the order edit.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.requestConfirmation(orderEditId)
.then({ order_edit }) => {
console.log(order_edit.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order edit.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="requestConfirmation"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrderEditsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order edit's details.","expandable":false,"children":[{"name":"AdminOrderEditsRes","type":"[AdminOrderEditsRes](../../../medusa/types/medusa.AdminOrderEditsRes/page.mdx)","optional":false,"defaultValue":"","description":"The order edit details.","expandable":false,"children":[{"name":"order_edit","type":"`OrderEdit`","description":"Order edit details","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="requestConfirmation"/>
### cancel
Cancel an order edit.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.cancel(orderEditId)
.then(({ order_edit }) => {
console.log(order_edit.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order edit to cancel.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancel"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrderEditsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order edit's details.","expandable":false,"children":[{"name":"AdminOrderEditsRes","type":"[AdminOrderEditsRes](../../../medusa/types/medusa.AdminOrderEditsRes/page.mdx)","optional":false,"defaultValue":"","description":"The order edit details.","expandable":false,"children":[{"name":"order_edit","type":"`OrderEdit`","description":"Order edit details","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancel"/>
### confirm
Confirm an order edit. This will reflect the changes in the order edit on the associated order.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.confirm(orderEditId)
.then(({ order_edit }) => {
console.log(order_edit.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order edit to confirm.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="confirm"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrderEditsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order edit's details.","expandable":false,"children":[{"name":"AdminOrderEditsRes","type":"[AdminOrderEditsRes](../../../medusa/types/medusa.AdminOrderEditsRes/page.mdx)","optional":false,"defaultValue":"","description":"The order edit details.","expandable":false,"children":[{"name":"order_edit","type":"`OrderEdit`","description":"Order edit details","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="confirm"/>
### updateLineItem
Create or update a line item change in the order edit that indicates addition, deletion, or update of a line item into an original order. Line item changes
are only reflected on the original order after the order edit is confirmed.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.updateLineItem(orderEditId, lineItemId, {
quantity: 5
})
.then(({ order_edit }) => {
console.log(order_edit.id)
})
```
#### Parameters
<TypeList types={[{"name":"orderEditId","type":"`string`","description":"The ID of the order edit that the line item belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"itemId","type":"`string`","description":"The ID of the line item to create or update its line item change.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostOrderEditsEditLineItemsLineItemReq](../../../medusa/classes/medusa.AdminPostOrderEditsEditLineItemsLineItemReq/page.mdx)","description":"The creation or update of the line item change.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"quantity","type":"`number`","description":"The quantity to update","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateLineItem"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrderEditsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order edit's details.","expandable":false,"children":[{"name":"AdminOrderEditsRes","type":"[AdminOrderEditsRes](../../../medusa/types/medusa.AdminOrderEditsRes/page.mdx)","optional":false,"defaultValue":"","description":"The order edit details.","expandable":false,"children":[{"name":"order_edit","type":"`OrderEdit`","description":"Order edit details","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateLineItem"/>
### removeLineItem
Create a line item change in the order edit that indicates deleting an item in the original order. The item in the original order will not be deleted until the order edit is
confirmed.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.removeLineItem(orderEditId, lineItemId)
.then(({ order_edit }) => {
console.log(order_edit.id)
})
```
#### Parameters
<TypeList types={[{"name":"orderEditId","type":"`string`","description":"The ID of the order edit that the line item change belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"itemId","type":"`string`","description":"The ID of the line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeLineItem"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrderEditsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order edit's details.","expandable":false,"children":[{"name":"AdminOrderEditsRes","type":"[AdminOrderEditsRes](../../../medusa/types/medusa.AdminOrderEditsRes/page.mdx)","optional":false,"defaultValue":"","description":"The order edit details.","expandable":false,"children":[{"name":"order_edit","type":"`OrderEdit`","description":"Order edit details","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeLineItem"/>
@@ -0,0 +1,724 @@
---
slug: /references/js-client/AdminOrdersResource
---
import { TypeList } from "docs-ui"
# AdminOrdersResource
This class is used to send requests to [Admin Order API Routes](https://docs.medusajs.com/api/admin#orders). All its method
are available in the JS Client under the `medusa.admin.orders` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Orders are purchases made by customers, typically through a storefront using [CartsResource](../js_client.CartsResource/page.mdx). Draft orders created by the admin are also transformed to an Order once the payment is captured.
Managing orders include managing fulfillment, payment, claims, reservations, and more.
Related Guide: [How to manage orders](https://docs.medusajs.com/modules/orders/admin/manage-orders).
## Methods
### update
Update an order's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.update(orderId, {
email: "user@example.com"
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostOrdersOrderReq](../../../medusa/classes/medusa.AdminPostOrdersOrderReq/page.mdx)","description":"The attributes to update in the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"email","type":"`string`","description":"The email associated with the order","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address","type":"[AddressPayload](../../../medusa/classes/medusa.AddressPayload/page.mdx)","description":"The order's billing address","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address","type":"[AddressPayload](../../../medusa/classes/medusa.AddressPayload/page.mdx)","description":"The order's shipping address","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"items","type":"`Record<string, unknown>`[]","description":"The line items of the order","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"region","type":"`string`","description":"ID of the region that the order is associated with.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"discounts","type":"`Record<string, unknown>`[]","description":"The discounts applied to the order","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"The ID of the customer associated with the order.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"payment_method","type":"[PaymentMethod](../../../medusa/classes/medusa.PaymentMethod/page.mdx)","description":"The payment method chosen for the order.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_method","type":"[ShippingMethod](../../../medusa/classes/medusa.ShippingMethod-3/page.mdx)[]","description":"The Shipping Method used for shipping the order.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"no_notification","type":"`boolean`","description":"If set to `true`, no notification will be sent to the customer related to this order.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`object`","description":"The order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### retrieve
Retrieve an order's details.
#### Example
A simple example that retrieves an order by its ID:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.retrieve(orderId)
.then(({ order }) => {
console.log(order.id);
})
```
To specify relations that should be retrieved:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.retrieve(orderId, {
expand: "customer"
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[FindParams](../../../medusa/classes/medusa.FindParams/page.mdx)","description":"Configurations to apply on the retrieved order.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`object`","description":"The order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of orders. The orders can be filtered by fields such as `status` or `display_id` passed in the `query` parameter. The order can also be paginated.
#### Example
To list orders:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.list()
.then(({ orders, limit, offset, count }) => {
console.log(orders.length);
})
```
To specify relations that should be retrieved within the orders:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.list({
expand: "customers"
})
.then(({ orders, limit, offset, count }) => {
console.log(orders.length);
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.list({
expand: "customers",
limit,
offset
})
.then(({ orders, limit, offset, count }) => {
console.log(orders.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetOrdersParams](../../../medusa/classes/medusa.AdminGetOrdersParams/page.mdx)","description":"Filters and pagination configurations applied on the retrieved orders.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":false,"defaultValue":"0","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":false,"defaultValue":"50","expandable":false,"children":[]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"The field to sort retrieved orders by. By default, the sort order is ascending.\nTo change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"q","type":"`string`","description":"Search term to search orders' shipping address, first name, email, and display ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"ID to filter orders by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"`string`[]","description":"Statuses to filter orders by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillment_status","type":"`string`[]","description":"Fulfillment statuses to filter orders by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"payment_status","type":"`string`[]","description":"Payment statuses to filter orders by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`string`","description":"Display ID to filter orders by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"cart_id","type":"`string`","description":"Cart ID to filter orders by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"Customer ID to filter orders by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"Email to filter orders by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`string` \\| `string`[]","description":"Regions to filter orders by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"Currency code to filter orders by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rate","type":"`string`","description":"Tax rate to filter orders by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"sales_channel_id","type":"`string`[]","description":"Sales channel IDs to filter orders by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"canceled_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the orders' `canceled_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the orders' `created_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the orders' `updated_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of orders with pagination fields.","expandable":false,"children":[{"name":"AdminOrdersListRes","type":"[PaginatedResponse](../../../medusa/interfaces/medusa.PaginatedResponse/page.mdx) & `object`","description":"The list of orders with pagination fields.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### complete
Complete an order and change its status. A canceled order can't be completed.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.complete(orderId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="complete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`object`","description":"The order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="complete"/>
### capturePayment
Capture all the payments associated with an order. The payment of canceled orders can't be captured.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.capturePayment(orderId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order whose payments should be captured.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="capturePayment"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`object`","description":"The order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="capturePayment"/>
### refundPayment
Refund an amount for an order. The amount must be less than or equal the `refundable_amount` of the order.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.refundPayment(orderId, {
amount: 1000,
reason: "Do not like it"
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order whose customer should be refunded.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostOrdersOrderRefundsReq](../../../medusa/classes/medusa.AdminPostOrdersOrderRefundsReq/page.mdx)","description":"The refund's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"amount","type":"`number`","description":"The amount to refund. It should be less than or equal the `refundable\\_amount` of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reason","type":"`string`","description":"The reason for the Refund.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"note","type":"`string`","description":"A note with additional details about the Refund.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"no_notification","type":"`boolean`","description":"If set to `true`, no notification will be sent to the customer related to this Refund.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="refundPayment"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`object`","description":"The order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="refundPayment"/>
### createFulfillment
Create a Fulfillment of an Order using the fulfillment provider, and change the order's fulfillment status to either `partially_fulfilled` or `fulfilled`, depending on
whether all the items were fulfilled.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.createFulfillment(orderId, {
items: [
{
item_id,
quantity: 1
}
]
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order that the fulfillment belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostOrdersOrderFulfillmentsReq](../../../medusa/classes/medusa.AdminPostOrdersOrderFulfillmentsReq/page.mdx)","description":"The fulfillment to be created.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"items","type":"[Item](../../../medusa/classes/medusa.Item-2/page.mdx)[]","description":"The Line Items to include in the Fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"location_id","type":"`string`","description":"The ID of the location where the items will be fulfilled from.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"no_notification","type":"`boolean`","description":"If set to `true`, no notification will be sent to the customer related to this fulfillment.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs to hold additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createFulfillment"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`object`","description":"The order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createFulfillment"/>
### cancelFulfillment
Cancel an order's fulfillment and change its fulfillment status to `canceled`.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.cancelFulfillment(orderId, fulfillmentId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order that the fulfillment belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillmentId","type":"`string`","description":"The fulfillment's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancelFulfillment"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`object`","description":"The order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancelFulfillment"/>
### cancelSwapFulfillment
Cancel a swap's fulfillment and change its fulfillment status to `canceled`.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.cancelSwapFulfillment(orderId, swapId, fulfillmentId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order that the swap is associated with.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"swapId","type":"`string`","description":"The ID of the swap the fulfillment belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillmentId","type":"`string`","description":"The fulfillment's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancelSwapFulfillment"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`object`","description":"The order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancelSwapFulfillment"/>
### cancelClaimFulfillment
Cancel a claim's fulfillment and change its fulfillment status to `canceled`.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.cancelClaimFulfillment(orderId, claimId, fulfillmentId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order that the claim is associated with.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"claimId","type":"`string`","description":"The claim's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillmentId","type":"`string`","description":"The fulfillment's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancelClaimFulfillment"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`object`","description":"The order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancelClaimFulfillment"/>
### createShipment
Create a shipment and mark a fulfillment as shipped. This changes the order's fulfillment status to either `partially_shipped` or `shipped`, depending on
whether all the items were shipped.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.createShipment(order_id, {
fulfillment_id
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostOrdersOrderShipmentReq](../../../medusa/classes/medusa.AdminPostOrdersOrderShipmentReq/page.mdx)","description":"The shipment to be created.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"fulfillment_id","type":"`string`","description":"The ID of the Fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tracking_numbers","type":"`string`[]","description":"The tracking numbers for the shipment.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"no_notification","type":"`boolean`","description":"If set to true no notification will be send related to this Shipment.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createShipment"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`object`","description":"The order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createShipment"/>
### requestReturn
Request and create a return for items in an order. If the return shipping method is specified, it will be automatically fulfilled.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.requestReturn(orderId, {
items: [
{
item_id,
quantity: 1
}
]
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostOrdersOrderReturnsReq](../../../medusa/classes/medusa.AdminPostOrdersOrderReturnsReq/page.mdx)","description":"The return to be created.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"items","type":"[OrdersReturnItem](../../../medusa/classes/medusa.OrdersReturnItem/page.mdx)[]","description":"The line items that will be returned.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"return_shipping","type":"[ReturnShipping](../../../medusa/classes/medusa.ReturnShipping-2/page.mdx)","description":"The Shipping Method to be used to handle the return shipment.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"note","type":"`string`","description":"An optional note with information about the Return.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"receive_now","type":"`boolean`","description":"A flag to indicate if the Return should be registerd as received immediately.","optional":true,"defaultValue":"false","expandable":false,"children":[]},{"name":"no_notification","type":"`boolean`","description":"If set to `true`, no notification will be sent to the customer related to this Return.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"refund","type":"`number`","description":"The amount to refund.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"location_id","type":"`string`","description":"The ID of the location used for the return.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="requestReturn"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details. You can access the return under the `returns` property.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`object`","description":"The order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="requestReturn"/>
### cancel
Cancel an order and change its status. This will also cancel any associated fulfillments and payments, and it may fail if the payment or fulfillment Provider
is unable to cancel the payment/fulfillment.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.cancel(orderId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancel"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`object`","description":"The order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancel"/>
### addShippingMethod
Add a shipping method to an order. If another shipping method exists with the same shipping profile, the previous shipping method will be replaced.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.addShippingMethod(orderId, {
price: 1000,
option_id
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostOrdersOrderShippingMethodsReq](../../../medusa/classes/medusa.AdminPostOrdersOrderShippingMethodsReq/page.mdx)","description":"The shipping method to be added.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"price","type":"`number`","description":"The price (excluding VAT) that should be charged for the Shipping Method","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"option_id","type":"`string`","description":"The ID of the Shipping Option to create the Shipping Method from.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`Record<string, unknown>`","description":"The data required for the Shipping Option to create a Shipping Method. This depends on the Fulfillment Provider.","optional":true,"defaultValue":"{}","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addShippingMethod"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`object`","description":"The order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addShippingMethod"/>
### archive
Archive an order and change its status.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.archive(orderId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="archive"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`object`","description":"The order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="archive"/>
### createSwap
Create a swap for an order. This includes creating a return that is associated with the swap.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.createSwap(orderId, {
return_items: [
{
item_id,
quantity: 1
}
]
})
.then(({ order }) => {
console.log(order.swaps);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostOrdersOrderSwapsReq](../../../medusa/classes/medusa.AdminPostOrdersOrderSwapsReq/page.mdx)","description":"The swap to be created.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"return_items","type":"[ReturnItem](../../../medusa/classes/medusa.ReturnItem/page.mdx)[]","description":"The Line Items to associate with the swap's return.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"return_shipping","type":"[ReturnShipping](../../../medusa/classes/medusa.ReturnShipping-1/page.mdx)","description":"The shipping method associated with the swap's return.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"sales_channel_id","type":"`string`","description":"The ID of the sales channel associated with the swap.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"additional_items","type":"[AdditionalItem](../../../medusa/classes/medusa.AdditionalItem-1/page.mdx)[]","description":"The new items to send to the Customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"custom_shipping_options","type":"[CustomShippingOption](../../../medusa/classes/medusa.CustomShippingOption/page.mdx)[]","description":"An array of custom shipping options to potentially create a Shipping Method from to send the additional items.","optional":true,"defaultValue":"[]","expandable":false,"children":[]},{"name":"no_notification","type":"`boolean`","description":"If set to `true`, no notification will be sent to the customer related to this Swap.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"return_location_id","type":"`string`","description":"The ID of the location used for the associated return.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"allow_backorder","type":"`boolean`","description":"If set to `true`, swaps can be completed with items out of stock","optional":true,"defaultValue":"true","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createSwap"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details. You can access the swap under the `swaps` property.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`object`","description":"The order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createSwap"/>
### cancelSwap
Cancel a swap and change its status.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.cancelSwap(orderId, swapId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order that the swap belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"swapId","type":"`string`","description":"The swap's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancelSwap"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details. You can access the swap under the `swaps` property.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`object`","description":"The order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancelSwap"/>
### fulfillSwap
Create a Fulfillment for a Swap and change its fulfillment status to `fulfilled`. If it requires any additional actions,
its fulfillment status may change to `requires_action`.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.fulfillSwap(orderId, swapId, {
no_notification: true,
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order that the swap belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"swapId","type":"`string`","description":"The swap's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostOrdersOrderSwapsSwapFulfillmentsReq](../../../medusa/classes/medusa.AdminPostOrdersOrderSwapsSwapFulfillmentsReq/page.mdx)","description":"The fulfillment to be created.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs to hold additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"no_notification","type":"`boolean`","description":"If set to `true`, no notification will be sent to the customer related to this swap.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"location_id","type":"`string`","description":"The ID of the fulfillment's location.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="fulfillSwap"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details. You can access the swap under the `swaps` property.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`object`","description":"The order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="fulfillSwap"/>
### createSwapShipment
Create a shipment for a swap and mark its fulfillment as shipped. This changes the swap's fulfillment status to either `shipped` or `partially_shipped`, depending on
whether all the items were shipped.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.createSwapShipment(orderId, swapId, {
fulfillment_id
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order that the swap belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"swapId","type":"`string`","description":"The swap's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostOrdersOrderSwapsSwapShipmentsReq](../../../medusa/classes/medusa.AdminPostOrdersOrderSwapsSwapShipmentsReq/page.mdx)","description":"The shipment to be created.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"fulfillment_id","type":"`string`","description":"The ID of the Fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tracking_numbers","type":"`string`[]","description":"The tracking numbers for the shipment.","optional":true,"defaultValue":"[]","expandable":false,"children":[]},{"name":"no_notification","type":"`boolean`","description":"If set to true no notification will be sent related to this Claim.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createSwapShipment"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details. You can access the swap under the `swaps` property.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`object`","description":"The order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createSwapShipment"/>
### processSwapPayment
Process a swap's payment either by refunding or issuing a payment. This depends on the `difference_due` of the swap. If `difference_due` is negative, the amount is refunded.
If `difference_due` is positive, the amount is captured.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.processSwapPayment(orderId, swapId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order that the swap belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"swapId","type":"`string`","description":"The swap's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="processSwapPayment"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details. You can access the swap under the `swaps` property.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`object`","description":"The order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="processSwapPayment"/>
### createClaim
Create a claim for an order. If a return shipping method is specified, a return will also be created and associated with the claim. If the claim's type is `refund`,
the refund is processed as well.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.createClaim(orderId, {
type: 'refund',
claim_items: [
{
item_id,
quantity: 1
}
]
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostOrdersOrderClaimsReq](../../../medusa/classes/medusa.AdminPostOrdersOrderClaimsReq/page.mdx)","description":"The claim to be created.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"type","type":"`\"replace\"` \\| `\"refund\"`","description":"The type of the Claim. This will determine how the Claim is treated: `replace` Claims will result in a Fulfillment with new items being created, while a `refund` Claim will refund the amount paid for the claimed items.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"claim_items","type":"[Item](../../../medusa/classes/medusa.Item-1/page.mdx)[]","description":"The Claim Items that the Claim will consist of.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"return_shipping","type":"[ReturnShipping](../../../medusa/classes/medusa.ReturnShipping/page.mdx)","description":"Optional details for the Return Shipping Method, if the items are to be sent back. Providing this field will result in a return being created and associated with the claim.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"additional_items","type":"[AdditionalItem](../../../medusa/classes/medusa.AdditionalItem/page.mdx)[]","description":"The new items to send to the Customer. This is only used if the claim's type is `replace`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_methods","type":"[ShippingMethod](../../../medusa/classes/medusa.ShippingMethod-1/page.mdx)[]","description":"The Shipping Methods to send the additional Line Items with. This is only used if the claim's type is `replace`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"refund_amount","type":"`number`","description":"The amount to refund the customer. This is used when the claim's type is `refund`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address","type":"[AddressPayload](../../../medusa/classes/medusa.AddressPayload/page.mdx)","description":"An optional shipping address to send the claimed items to. If not provided, the parent order's shipping address will be used.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"no_notification","type":"`boolean`","description":"If set to true no notification will be send related to this Claim.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"return_location_id","type":"`string`","description":"The ID of the location used for the associated return.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs to hold additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createClaim"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details. You can access the claim under the `claims` property.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`object`","description":"The order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createClaim"/>
### cancelClaim
Cancel a claim and change its status. A claim can't be canceled if it has a refund, if its fulfillments haven't been canceled, of if its associated return hasn't been canceled.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.cancelClaim(orderId, claimId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order that the claim belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"claimId","type":"`string`","description":"The claim's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancelClaim"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details. You can access the swap under the `claims` property.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`object`","description":"The order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancelClaim"/>
### updateClaim
Update a claim's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.updateClaim(orderId, claimId, {
no_notification: true
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order that the claim belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"claimId","type":"`string`","description":"The claim's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostOrdersOrderClaimsClaimReq](../../../medusa/classes/medusa.AdminPostOrdersOrderClaimsClaimReq/page.mdx)","description":"The attributes to update in the claim.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"claim_items","type":"[Item](../../../medusa/classes/medusa.Item-3/page.mdx)[]","description":"The Claim Items that the Claim will consist of.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_methods","type":"[ShippingMethod](../../../medusa/classes/medusa.ShippingMethod-2/page.mdx)[]","description":"The Shipping Methods to send the additional Line Items with.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"no_notification","type":"`boolean`","description":"If set to true no notification will be send related to this Swap.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs to hold additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateClaim"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details. You can access the claims under the `claims` property.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`object`","description":"The order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateClaim"/>
### fulfillClaim
Create a Fulfillment for a Claim, and change its fulfillment status to `partially_fulfilled` or `fulfilled` depending on whether all the items were fulfilled.
It may also change the status to `requires_action` if any actions are required.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.fulfillClaim(orderId, claimId, {
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order that the claim belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"claimId","type":"`string`","description":"The claim's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostOrdersOrderClaimsClaimFulfillmentsReq](../../../medusa/classes/medusa.AdminPostOrdersOrderClaimsClaimFulfillmentsReq/page.mdx)","description":"The fulfillment to be created.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs to hold additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"no_notification","type":"`boolean`","description":"If set to `true`, no notification will be sent to the customer related to this Claim.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"location_id","type":"`string`","description":"The ID of the fulfillment's location.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="fulfillClaim"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details. You can access the swap under the `claims` property.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`object`","description":"The order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="fulfillClaim"/>
### createClaimShipment
Create a shipment for the claim and mark its fulfillment as shipped. If the shipment is created successfully, this changes the claim's fulfillment status
to either `partially_shipped` or `shipped`, depending on whether all the items were shipped.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.createClaimShipment(orderId, claimId, {
fulfillment_id
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order that the claim belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"claimId","type":"`string`","description":"The claim's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostOrdersOrderClaimsClaimShipmentsReq](../../../medusa/classes/medusa.AdminPostOrdersOrderClaimsClaimShipmentsReq/page.mdx)","description":"The shipment to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"fulfillment_id","type":"`string`","description":"The ID of the Fulfillment.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tracking_numbers","type":"`string`[]","description":"An array of tracking numbers for the shipment.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createClaimShipment"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details. You can access the swap under the `claims` property.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`object`","description":"The order's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createClaimShipment"/>
@@ -0,0 +1,130 @@
---
slug: /references/js-client/AdminPaymentCollectionsResource
---
import { TypeList } from "docs-ui"
# AdminPaymentCollectionsResource
This class is used to send requests to [Admin Payment Collection API Routes](https://docs.medusajs.com/api/admin#payment-collections). All its method
are available in the JS Client under the `medusa.admin.paymentCollections` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A payment collection is useful for managing additional payments, such as for Order Edits, or installment payments.
## Methods
### retrieve
Retrieve a Payment Collection's details.
#### Example
A simple example that retrieves a payment collection by its ID:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.paymentCollections.retrieve(paymentCollectionId)
.then(({ payment_collection }) => {
console.log(payment_collection.id)
})
```
To specify relations that should be retrieved:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.paymentCollections.retrieve(paymentCollectionId, {
expand: "currency"
})
.then(({ payment_collection }) => {
console.log(payment_collection.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetPaymentCollectionsParams](../../../medusa/classes/medusa.AdminGetPaymentCollectionsParams/page.mdx)","description":"Configurations to apply on the retrieved payment collection.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPaymentCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the payment collection's details.","expandable":false,"children":[{"name":"AdminPaymentCollectionsRes","type":"[AdminPaymentCollectionsRes](../../../medusa/types/medusa.AdminPaymentCollectionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The payment collection's details.","expandable":false,"children":[{"name":"payment_collection","type":"[PaymentCollection](../../../payment_models/classes/payment_models.PaymentCollection/page.mdx)","description":"Payment Collection details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"region_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"completed_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"status","type":"[PaymentCollectionStatus](../../../utils/enums/utils.PaymentCollectionStatus/page.mdx)","description":"","optional":false,"defaultValue":"PaymentCollectionStatus.NOT_PAID","expandable":false,"children":[{"name":"NOT_PAID","type":"`\"not_paid\"`","description":"The payment collection isn't paid.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"AWAITING","type":"`\"awaiting\"`","description":"The payment collection is awaiting payment.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"AUTHORIZED","type":"`\"authorized\"`","description":"The payment collection is authorized.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PARTIALLY_AUTHORIZED","type":"`\"partially_authorized\"`","description":"Some of the payments in the payment collection are authorized.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"CANCELED","type":"`\"canceled\"`","description":"The payment collection is canceled.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"payment_providers","type":"Collection&#60;[PaymentProvider](../../../payment_models/classes/payment_models.PaymentProvider/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_enabled","type":"`boolean`","description":"","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`\"is_enabled\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"payment_sessions","type":"Collection&#60;[PaymentSession](../../../payment_models/classes/payment_models.PaymentSession/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`Record<string, unknown>`","description":"","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"context","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultLine truncated
### update
Update a payment collection's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.paymentCollections.update(paymentCollectionId, {
description
})
.then(({ payment_collection }) => {
console.log(payment_collection.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminUpdatePaymentCollectionsReq](../../../medusa/classes/medusa.AdminUpdatePaymentCollectionsReq/page.mdx)","description":"The attributes to update in the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"description","type":"`string`","description":"A description to create or update the payment collection.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"A set of key-value pairs to hold additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPaymentCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the payment collection's details.","expandable":false,"children":[{"name":"AdminPaymentCollectionsRes","type":"[AdminPaymentCollectionsRes](../../../medusa/types/medusa.AdminPaymentCollectionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The payment collection's details.","expandable":false,"children":[{"name":"payment_collection","type":"[PaymentCollection](../../../payment_models/classes/payment_models.PaymentCollection/page.mdx)","description":"Payment Collection details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"region_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"completed_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"status","type":"[PaymentCollectionStatus](../../../utils/enums/utils.PaymentCollectionStatus/page.mdx)","description":"","optional":false,"defaultValue":"PaymentCollectionStatus.NOT_PAID","expandable":false,"children":[{"name":"NOT_PAID","type":"`\"not_paid\"`","description":"The payment collection isn't paid.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"AWAITING","type":"`\"awaiting\"`","description":"The payment collection is awaiting payment.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"AUTHORIZED","type":"`\"authorized\"`","description":"The payment collection is authorized.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PARTIALLY_AUTHORIZED","type":"`\"partially_authorized\"`","description":"Some of the payments in the payment collection are authorized.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"CANCELED","type":"`\"canceled\"`","description":"The payment collection is canceled.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"payment_providers","type":"Collection&#60;[PaymentProvider](../../../payment_models/classes/payment_models.PaymentProvider/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_enabled","type":"`boolean`","description":"","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`\"is_enabled\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"payment_sessions","type":"Collection&#60;[PaymentSession](../../../payment_models/classes/payment_models.PaymentSession/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`Record<string, unknown>`","description":"","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"context","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultLine truncated
### delete
Delete a payment collection. Only payment collections with the statuses `canceled` or `not_paid` can be deleted.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.paymentCollections.delete(paymentCollectionId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPaymentCollectionDeleteRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"AdminPaymentCollectionDeleteRes","type":"[AdminPaymentCollectionDeleteRes](../../../medusa/types/medusa.AdminPaymentCollectionDeleteRes/page.mdx)","optional":false,"defaultValue":"","description":"The details of deleting a payment collection.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the deleted Payment Collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`\"payment_collection\"`","description":"The type of the object that was deleted.","optional":false,"defaultValue":"payment_collection","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether or not the Payment Collection was deleted.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### markAsAuthorized
Set the status of a payment collection as `authorized`. This will also change the `authorized_amount` of the payment collection.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.paymentCollections.markAsAuthorized(paymentCollectionId)
.then(({ payment_collection }) => {
console.log(payment_collection.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="markAsAuthorized"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPaymentCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the payment collection's details.","expandable":false,"children":[{"name":"AdminPaymentCollectionsRes","type":"[AdminPaymentCollectionsRes](../../../medusa/types/medusa.AdminPaymentCollectionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The payment collection's details.","expandable":false,"children":[{"name":"payment_collection","type":"[PaymentCollection](../../../payment_models/classes/payment_models.PaymentCollection/page.mdx)","description":"Payment Collection details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"region_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"completed_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"status","type":"[PaymentCollectionStatus](../../../utils/enums/utils.PaymentCollectionStatus/page.mdx)","description":"","optional":false,"defaultValue":"PaymentCollectionStatus.NOT_PAID","expandable":false,"children":[{"name":"NOT_PAID","type":"`\"not_paid\"`","description":"The payment collection isn't paid.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"AWAITING","type":"`\"awaiting\"`","description":"The payment collection is awaiting payment.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"AUTHORIZED","type":"`\"authorized\"`","description":"The payment collection is authorized.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PARTIALLY_AUTHORIZED","type":"`\"partially_authorized\"`","description":"Some of the payments in the payment collection are authorized.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"CANCELED","type":"`\"canceled\"`","description":"The payment collection is canceled.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"payment_providers","type":"Collection&#60;[PaymentProvider](../../../payment_models/classes/payment_models.PaymentProvider/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_enabled","type":"`boolean`","description":"","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`\"is_enabled\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"payment_sessions","type":"Collection&#60;[PaymentSession](../../../payment_models/classes/payment_models.PaymentSession/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`Record<string, unknown>`","description":"","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"context","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultLine truncated
@@ -0,0 +1,93 @@
---
slug: /references/js-client/AdminPaymentsResource
---
import { TypeList } from "docs-ui"
# AdminPaymentsResource
This class is used to send requests to [Admin Payment API Routes](https://docs.medusajs.com/api/admin#payments). All its method
are available in the JS Client under the `medusa.admin.payments` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A payment can be related to an order, swap, return, or more. It can be captured or refunded.
## Methods
### retrieve
Retrieve a payment's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.payments.retrieve(paymentId)
.then(({ payment }) => {
console.log(payment.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The payment's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[GetPaymentsParams](../../../medusa/classes/medusa.GetPaymentsParams/page.mdx)","description":"Configurations to apply on the retrieved payment.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPaymentRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the payment's details.","expandable":false,"children":[{"name":"AdminPaymentRes","type":"[AdminPaymentRes](../../../medusa/types/medusa.AdminPaymentRes/page.mdx)","optional":false,"defaultValue":"","description":"The payment's details.","expandable":false,"children":[{"name":"payment","type":"[Payment](../../../payment_models/classes/payment_models.Payment/page.mdx)","description":"Payment details","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"order_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customer_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"data","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"captured_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"canceled_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"refunds","type":"Collection&#60;[Refund](../../../payment_models/classes/payment_models.Refund/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payment","type":"[Payment](../../../payment_models/classes/payment_models.Payment/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]}]},{"name":"captures","type":"Collection&#60;[Capture](../../../payment_models/classes/payment_models.Capture/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandablLine truncated
### capturePayment
Capture a payment.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.payments.capturePayment(paymentId)
.then(({ payment }) => {
console.log(payment.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The payment's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="capturePayment"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPaymentRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the payment's details.","expandable":false,"children":[{"name":"AdminPaymentRes","type":"[AdminPaymentRes](../../../medusa/types/medusa.AdminPaymentRes/page.mdx)","optional":false,"defaultValue":"","description":"The payment's details.","expandable":false,"children":[{"name":"payment","type":"[Payment](../../../payment_models/classes/payment_models.Payment/page.mdx)","description":"Payment details","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"order_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customer_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"data","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"captured_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"canceled_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"refunds","type":"Collection&#60;[Refund](../../../payment_models/classes/payment_models.Refund/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payment","type":"[Payment](../../../payment_models/classes/payment_models.Payment/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]}]},{"name":"captures","type":"Collection&#60;[Capture](../../../payment_models/classes/payment_models.Capture/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandablLine truncated
### refundPayment
Refund a payment. The payment must be captured first.
#### Example
```ts
import { RefundReason } from "@medusajs/medusa";
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.payments.refundPayment(paymentId, {
amount: 1000,
reason: RefundReason.RETURN,
note: "Do not like it",
})
.then(({ refund }) => {
console.log(refund.amount);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The payment's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostPaymentRefundsReq](../../../medusa/classes/medusa.AdminPostPaymentRefundsReq/page.mdx)","description":"The refund to be created.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"amount","type":"`number`","description":"The amount to refund.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reason","type":"`RefundReason`","description":"The reason for the Refund.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"note","type":"`string`","description":"A note with additional details about the Refund.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="refundPayment"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminRefundRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the refund's details.","expandable":false,"children":[{"name":"AdminRefundRes","type":"[AdminRefundRes](../../../medusa/types/medusa.AdminRefundRes/page.mdx)","optional":false,"defaultValue":"","description":"The refund's details.","expandable":false,"children":[{"name":"refund","type":"[Refund](../../../payment_models/classes/payment_models.Refund/page.mdx)","description":"Refund details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"payment","type":"[Payment](../../../payment_models/classes/payment_models.Payment/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"order_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customer_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"data","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"captured_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"canceled_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"refunds","type":"Collection&#60;[Refund](../../../payment_models/classes/payment_models.Refund/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"captures","type":"Collection&#60;[Capture](../../../payment_models/classes/payment_models.Capture/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payment_collection","type":"[PaymentCollection](../../../payment_models/classes/payment_models.PaymentCollection/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payment_collection_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payment_session","type":"[PaymentSession](../../../payment_models/classes/payment_models.PaymentSession/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"captured_amount","type":"`number`","description":"COMPUTED PROPERTIES START *","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"refunded_amount","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[EntityDateColumns](../../../types/DAL/types/types.DAL.EntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"created_at","type":"`Date`","description":Line truncated
@@ -0,0 +1,373 @@
---
slug: /references/js-client/AdminPriceListResource
---
import { TypeList } from "docs-ui"
# AdminPriceListResource
This class is used to send requests to [Admin Price List API Routes](https://docs.medusajs.com/api/admin#price-lists). All its method
are available in the JS Client under the `medusa.admin.priceLists` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A price list are special prices applied to products based on a set of conditions, such as customer group.
Related Guide: [How to manage price lists](https://docs.medusajs.com/modules/price-lists/admin/manage-price-lists).
## Methods
### create
Create a price list.
#### Example
```ts
medusa.admin.priceLists.create({
name: "New Price List",
description: "A new price list",
type: PriceListType.SALE,
prices: [
{
amount: 1000,
variant_id,
currency_code: "eur"
}
]
})
.then(({ price_list }) => {
console.log(price_list.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostPriceListsPriceListReq](../../../medusa/classes/medusa.AdminPostPriceListsPriceListReq/page.mdx)","description":"The price list to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"name","type":"`string`","description":"The name of the Price List.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The description of the Price List.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[PriceListType](../../../medusa/enums/medusa.PriceListType-1/page.mdx)","description":"The type of the Price List.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"SALE","type":"`\"sale\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"OVERRIDE","type":"`\"override\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"prices","type":"[AdminPriceListPricesCreateReq](../../../medusa/classes/medusa.AdminPriceListPricesCreateReq/page.mdx)[]","description":"The prices of the Price List.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"amount","type":"`number`","description":"The amount to charge for the Product Variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_id","type":"`string`","description":"The ID of the Variant for which the price is used.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`string`","description":"The ID of the Region for which the price is used. This is only required if `currecny\\_code` is not provided.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The 3 character ISO currency code for which the price will be used. This is only required if `region\\_id` is not provided.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"min_quantity","type":"`number`","description":"The minimum quantity for which the price will be used.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"max_quantity","type":"`number`","description":"The maximum quantity for which the price will be used.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"starts_at","type":"`Date`","description":"The date with timezone that the Price List starts being valid.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ends_at","type":"`Date`","description":"The date with timezone that the Price List ends being valid.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PriceListStatus](../../../medusa/enums/medusa.PriceListStatus-1/page.mdx)","description":"The status of the Price List. If the status is set to `draft`, the prices created in the price list will not be available of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"ACTIVE","type":"`\"active\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"DRAFT","type":"`\"draft\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customer_groups","type":"[CustomerGroup](../../../medusa/classes/medusa.CustomerGroup/page.mdx)[]","description":"An array of customer groups that the Price List applies to.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of a customer group","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"includes_tax","type":"`boolean`","description":"Tax included in prices of price list","optional":true,"defaultValue":"","expandable":false,"featureFlag":"tax_inclusive_pricing","children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPriceListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the price list details.","expandable":false,"children":[{"name":"AdminPriceListRes","type":"[AdminPriceListRes](../../../medusa/types/medusa.AdminPriceListRes/page.mdx)","optional":false,"defaultValue":"","description":"The price list's details.","expandable":false,"children":[{"name":"price_list","type":"[PriceList](../../../pricing_models/classes/pricing_models.PriceList/page.mdx)","description":"Price List details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"`OptionalFields`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PriceListStatus](../../../medusa/enums/medusa.PriceListStatus-1/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"ACTIVE","type":"`\"active\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"DRAFT","type":"`\"draft\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"type","type":"[PriceListType](../../../medusa/enums/medusa.PriceListType-1/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"SALE","type":"`\"sale\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"OVERRIDE","type":"`\"override\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"starts_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"ends_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"prices","type":"Collection&#60;[Price](../../../pricing_models/classes/pricing_models.Price/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"`Record<string, unknown>`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"min_quantity","type":"`null` \\| `number`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"max_quantity","type":"`null` \\| `number`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"price_set_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rules_count","type":"`number`","description":"","optional":false,"defaultValue":"0","expandable":false,"children":[]},{"name":"price_rules","type":"Collection&#60;[PriceRule](../../../pricing_models/classes/pricing_models.PriceRule/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"price_list_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"price_list","type":"`null` \\| [PriceList](../../../pricing_models/classes/pricing_models.PriceList/page.mdx)","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"price_set","type":"[PriceSet](../../../pricing_models/classes/pricing_models.PriceSet/page.mdx)","description":"","Line truncated
### update
Update a price list's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.update(priceListId, {
name: "New Price List"
})
.then(({ price_list }) => {
console.log(price_list.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the price list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostPriceListsPriceListPriceListReq](../../../medusa/classes/medusa.AdminPostPriceListsPriceListPriceListReq/page.mdx)","description":"The attributes to update in the price list.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"name","type":"`string`","description":"The name of the Price List","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The description of the Price List.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"starts_at","type":"`null` \\| `Date`","description":"The date with timezone that the Price List starts being valid.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ends_at","type":"`null` \\| `Date`","description":"The date with timezone that the Price List ends being valid.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PriceListStatus](../../../medusa/enums/medusa.PriceListStatus-1/page.mdx)","description":"The status of the Price List. If the status is set to `draft`, the prices created in the price list will not be available of the customer.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"ACTIVE","type":"`\"active\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"DRAFT","type":"`\"draft\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"type","type":"[PriceListType](../../../medusa/enums/medusa.PriceListType-1/page.mdx)","description":"The type of the Price List.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"SALE","type":"`\"sale\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"OVERRIDE","type":"`\"override\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"prices","type":"[AdminPriceListPricesUpdateReq](../../../medusa/classes/medusa.AdminPriceListPricesUpdateReq/page.mdx)[]","description":"The prices of the Price List.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"variant_id","type":"`string`","description":"The ID of the Variant for which the price is used.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number`","description":"The amount to charge for the Product Variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"The ID of the price.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`string`","description":"The ID of the Region for which the price is used. This is only required if `currecny\\_code` is not provided.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The 3 character ISO currency code for which the price will be used. This is only required if `region\\_id` is not provided.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"min_quantity","type":"`number`","description":"The minimum quantity for which the price will be used.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"max_quantity","type":"`number`","description":"The maximum quantity for which the price will be used.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customer_groups","type":"[CustomerGroup](../../../medusa/classes/medusa.CustomerGroup-1/page.mdx)[]","description":"An array of customer groups that the Price List applies to.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of a customer group","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"includes_tax","type":"`boolean`","description":"Tax included in prices of price list","optional":true,"defaultValue":"","expandable":false,"featureFlag":"tax_inclusive_pricing","children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPriceListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the price list details.","expandable":false,"children":[{"name":"AdminPriceListRes","type":"[AdminPriceListRes](../../../medusa/types/medusa.AdminPriceListRes/page.mdx)","optional":false,"defaultValue":"","description":"The price list's details.","expandable":false,"children":[{"name":"price_list","type":"[PriceList](../../../pricing_models/classes/pricing_models.PriceList/page.mdx)","description":"Price List details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"`OptionalFields`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PriceListStatus](../../../medusa/enums/medusa.PriceListStatus-1/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"ACTIVE","type":"`\"active\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"DRAFT","type":"`\"draft\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"type","type":"[PriceListType](../../../medusa/enums/medusa.PriceListType-1/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"SALE","type":"`\"sale\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"OVERRIDE","type":"`\"override\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"starts_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"ends_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"prices","type":"Collection&#60;[Price](../../../pricing_models/classes/pricing_models.Price/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"`Record<string, unknown>`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"min_quantity","type":"`null` \\| `number`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"max_quantity","type":"`null` \\| `number`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"price_set_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rules_count","type":"`number`","description":"","optional":false,"defaultValue":"0","expandable":false,"children":[]},{"name":"price_rules","type":"Collection&#60;[PriceRule](../../../pricing_models/classes/pricing_models.PriceRule/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"price_list_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"price_list","type":"`null` \\| [PriceList](../../../pricing_models/classes/pricing_models.PriceList/page.mdx)","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"price_set","type":"[PriceSet](../../../pricing_models/classes/pricing_models.PriceSet/page.mdx)","description":"","Line truncated
### delete
Delete a price list and its associated prices.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.delete(priceListId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the price list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"[DeleteResponse](../../../medusa/interfaces/medusa.DeleteResponse/page.mdx)","optional":false,"defaultValue":"","description":"The response returned for a \n\n`DELETE`\n\n request.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the deleted item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the deleted item.","optional":false,"defaultValue":"product-collection","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether the item was deleted successfully.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### retrieve
Retrieve a price list's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.retrieve(priceListId)
.then(({ price_list }) => {
console.log(price_list.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the price list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPriceListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the price list details.","expandable":false,"children":[{"name":"AdminPriceListRes","type":"[AdminPriceListRes](../../../medusa/types/medusa.AdminPriceListRes/page.mdx)","optional":false,"defaultValue":"","description":"The price list's details.","expandable":false,"children":[{"name":"price_list","type":"[PriceList](../../../pricing_models/classes/pricing_models.PriceList/page.mdx)","description":"Price List details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"`OptionalFields`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PriceListStatus](../../../medusa/enums/medusa.PriceListStatus-1/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"ACTIVE","type":"`\"active\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"DRAFT","type":"`\"draft\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"type","type":"[PriceListType](../../../medusa/enums/medusa.PriceListType-1/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"SALE","type":"`\"sale\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"OVERRIDE","type":"`\"override\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"starts_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"ends_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"prices","type":"Collection&#60;[Price](../../../pricing_models/classes/pricing_models.Price/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"`Record<string, unknown>`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"min_quantity","type":"`null` \\| `number`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"max_quantity","type":"`null` \\| `number`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"price_set_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rules_count","type":"`number`","description":"","optional":false,"defaultValue":"0","expandable":false,"children":[]},{"name":"price_rules","type":"Collection&#60;[PriceRule](../../../pricing_models/classes/pricing_models.PriceRule/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"price_list_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"price_list","type":"`null` \\| [PriceList](../../../pricing_models/classes/pricing_models.PriceList/page.mdx)","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"price_set","type":"[PriceSet](../../../pricing_models/classes/pricing_models.PriceSet/page.mdx)","description":"","Line truncated
### list
Retrieve a list of price lists. The price lists can be filtered by fields such as `q` or `status` passed in the `query` parameter. The price lists can also be sorted or paginated.
#### Example
To list price lists:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.list()
.then(({ price_lists, limit, offset, count }) => {
console.log(price_lists.length);
})
```
To specify relations that should be retrieved within the price lists:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.list({
expand: "prices"
})
.then(({ price_lists, limit, offset, count }) => {
console.log(price_lists.length);
})
```
By default, only the first `10` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.list({
expand: "prices",
limit,
offset
})
.then(({ price_lists, limit, offset, count }) => {
console.log(price_lists.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetPriceListPaginationParams](../../../medusa/classes/medusa.AdminGetPriceListPaginationParams/page.mdx)","description":"Filters and pagination configurations to apply on the retrieved price lists.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":true,"defaultValue":"10","expandable":false,"children":[]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"IDs to filter price lists by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"q","type":"`string`","description":"Search terms to search price lists' description, name, and customer group's name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PriceListStatus](../../../medusa/enums/medusa.PriceListStatus/page.mdx)[]","description":"Statuses to filter price lists by.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"ACTIVE","type":"`\"active\"`","description":"The price list is active, meaning its prices are applied to customers.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"DRAFT","type":"`\"draft\"`","description":"The price list is a draft, meaning its not yet applied to customers.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"name","type":"`string`","description":"Name to filter price lists by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_groups","type":"`string`[]","description":"Filter price lists by their associated customer groups.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"Description to filter price lists by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[PriceListType](../../../medusa/enums/medusa.PriceListType/page.mdx)[]","description":"Types to filter price lists by.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"SALE","type":"`\"sale\"`","description":"The price list is used for a sale.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"OVERRIDE","type":"`\"override\"`","description":"The price list is used to override original prices for specific conditions.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the price lists' `created_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"updated_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the price lists' `updated_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name"Line truncated
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPriceListsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of price lists with pagination fields.","expandable":false,"children":[{"name":"AdminPriceListsListRes","type":"[AdminPriceListsListRes](../../../medusa/types/medusa.AdminPriceListsListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of price lists with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"price_lists","type":"[PriceList](../../../pricing_models/classes/pricing_models.PriceList/page.mdx)[]","description":"An array of price lists details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"`OptionalFields`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PriceListStatus](../../../medusa/enums/medusa.PriceListStatus-1/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"ACTIVE","type":"`\"active\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"DRAFT","type":"`\"draft\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"type","type":"[PriceListType](../../../medusa/enums/medusa.PriceListType-1/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"SALE","type":"`\"sale\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"OVERRIDE","type":"`\"override\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"starts_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"ends_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"prices","type":"Collection&#60;[Price](../../../pricing_models/classes/pricing_models.Price/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"`Record<string, unknown>`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"min_quantity","type":"`null` \\| `number`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"max_quantity","type":"`null` \\| `number`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"price_set_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rules_count","type":"`number`","description":"","optional":false,"defaultValue":"0","expandable":false,"children":[]},{"name":"price_rules","type":"Collection&#60;[PriceRule](../../../pricing_models/classes/pricing_models.PriceRule/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"price_list_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"price_list","type":"`null` \\| [PriceList](../../../pricing_models/classes/pricing_models.PriceList/page.mdx)","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":Line truncated
### listProducts
Retrieve a price list's products. The products can be filtered by fields such as `q` or `status` passed in the `query` parameter. The products can also be sorted or paginated.
#### Example
To list products in a price list:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.listProducts(priceListId)
.then(({ products, limit, offset, count }) => {
console.log(products.length);
})
```
To specify relations that should be retrieved within the products:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.listProducts(priceListId, {
expand: "variants"
})
.then(({ products, limit, offset, count }) => {
console.log(products.length);
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.listProducts(priceListId, {
expand: "variants",
limit,
offset
})
.then(({ products, limit, offset, count }) => {
console.log(products.length);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the price list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetPriceListsPriceListProductsParams](../../../medusa/classes/medusa.AdminGetPriceListsPriceListProductsParams/page.mdx)","description":"Filters and pagination configurations applied on the retrieved products.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string` \\| `string`[]","description":"ID to filter products by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"q","type":"`string`","description":"Search term to search products' title, description, product variant's title and sku, and product collection's title.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../product/enums/product.ProductStatus/page.mdx)[]","description":"Statuses to filter products by.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"DRAFT","type":"`\"draft\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PROPOSED","type":"`\"proposed\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PUBLISHED","type":"`\"published\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"REJECTED","type":"`\"rejected\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"collection_id","type":"`string`[]","description":"Filter products by their associated collection ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"tags","type":"`string`[]","description":"Tags to filter products by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"Title to filter products by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"Description to filter products by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"Handle to filter products by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"Filter products by whether they're gift cards.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`string`","description":"Type to filter products by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the products' `created_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"updated_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the products' `updated_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"deletLine truncated
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPriceListsProductsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of products with pagination fields.","expandable":false,"children":[{"name":"AdminPriceListsProductsListRes","type":"[AdminPriceListsProductsListRes](../../../medusa/types/medusa.AdminPriceListsProductsListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of products with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"[Product](../../../product_models/classes/product_models.Product/page.mdx)[]","description":"An array of products details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"DRAFT","type":"`\"draft\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PROPOSED","type":"`\"proposed\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PUBLISHED","type":"`\"published\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"REJECTED","type":"`\"rejected\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"values","type":"Collection&#60;[ProductOptionValue](../../../product_models/classes/product_models.ProductOptionValue/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOptionValue](../../../product_models/classes/product_models.ProductOptionValue/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optionaLine truncated
### addPrices
Add or update a list of prices in a price list.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.addPrices(priceListId, {
prices: [
{
amount: 1000,
variant_id,
currency_code: "eur"
}
]
})
.then(({ price_list }) => {
console.log(price_list.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the price list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostPriceListPricesPricesReq](../../../medusa/classes/medusa.AdminPostPriceListPricesPricesReq/page.mdx)","description":"The details of prices to add or update.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"prices","type":"[AdminPriceListPricesUpdateReq](../../../medusa/classes/medusa.AdminPriceListPricesUpdateReq/page.mdx)[]","description":"The prices to update or add.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"variant_id","type":"`string`","description":"The ID of the Variant for which the price is used.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number`","description":"The amount to charge for the Product Variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"The ID of the price.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`string`","description":"The ID of the Region for which the price is used. This is only required if `currecny\\_code` is not provided.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The 3 character ISO currency code for which the price will be used. This is only required if `region\\_id` is not provided.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"min_quantity","type":"`number`","description":"The minimum quantity for which the price will be used.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"max_quantity","type":"`number`","description":"The maximum quantity for which the price will be used.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"override","type":"`boolean`","description":"If set to `true`, the prices will replace all existing prices associated with the Price List.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addPrices"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPriceListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the price list's details.","expandable":false,"children":[{"name":"AdminPriceListRes","type":"[AdminPriceListRes](../../../medusa/types/medusa.AdminPriceListRes/page.mdx)","optional":false,"defaultValue":"","description":"The price list's details.","expandable":false,"children":[{"name":"price_list","type":"[PriceList](../../../pricing_models/classes/pricing_models.PriceList/page.mdx)","description":"Price List details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"`OptionalFields`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PriceListStatus](../../../medusa/enums/medusa.PriceListStatus-1/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"ACTIVE","type":"`\"active\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"DRAFT","type":"`\"draft\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"type","type":"[PriceListType](../../../medusa/enums/medusa.PriceListType-1/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"SALE","type":"`\"sale\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"OVERRIDE","type":"`\"override\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"starts_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"ends_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"prices","type":"Collection&#60;[Price](../../../pricing_models/classes/pricing_models.Price/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"`Record<string, unknown>`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"min_quantity","type":"`null` \\| `number`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"max_quantity","type":"`null` \\| `number`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"price_set_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rules_count","type":"`number`","description":"","optional":false,"defaultValue":"0","expandable":false,"children":[]},{"name":"price_rules","type":"Collection&#60;[PriceRule](../../../pricing_models/classes/pricing_models.PriceRule/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"price_list_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"price_list","type":"`null` \\| [PriceList](../../../pricing_models/classes/pricing_models.PriceList/page.mdx)","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"price_set","type":"[PriceSet](../../../pricing_models/classes/pricing_models.PriceSet/page.mdx)","description":""Line truncated
### deletePrices
Delete a list of prices in a price list
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.deletePrices(priceListId, {
price_ids: [
price_id
]
})
.then(({ ids, object, deleted }) => {
console.log(ids.length);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the price list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminDeletePriceListPricesPricesReq](../../../medusa/classes/medusa.AdminDeletePriceListPricesPricesReq/page.mdx)","description":"The prices to delete.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"price_ids","type":"`string`[]","description":"The IDs of the prices to delete.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deletePrices"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPriceListDeleteBatchRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"AdminPriceListDeleteBatchRes","type":"[AdminPriceListDeleteBatchRes](../../../medusa/types/medusa.AdminPriceListDeleteBatchRes/page.mdx)","optional":false,"defaultValue":"","description":"The details of deleting a price list.","expandable":false,"children":[{"name":"ids","type":"`string`[]","description":"The IDs of the deleted prices.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether or not the items were deleted.","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the object that was deleted. A price is also named `money-amount`.","optional":false,"defaultValue":"money-amount","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deletePrices"/>
### deleteProductPrices
Delete all the prices related to a specific product in a price list.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.deleteProductPrices(priceListId, productId)
.then(({ ids, object, deleted }) => {
console.log(ids.length);
})
```
#### Parameters
<TypeList types={[{"name":"priceListId","type":"`string`","description":"The ID of the price list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"productId","type":"`string`","description":"The product's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteProductPrices"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPriceListDeleteBatchRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"AdminPriceListDeleteBatchRes","type":"[AdminPriceListDeleteBatchRes](../../../medusa/types/medusa.AdminPriceListDeleteBatchRes/page.mdx)","optional":false,"defaultValue":"","description":"The details of deleting a price list.","expandable":false,"children":[{"name":"ids","type":"`string`[]","description":"The IDs of the deleted prices.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether or not the items were deleted.","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the object that was deleted. A price is also named `money-amount`.","optional":false,"defaultValue":"money-amount","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteProductPrices"/>
### deleteVariantPrices
Delete all the prices related to a specific product variant in a price list.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.deleteVariantPrices(priceListId, variantId)
.then(({ ids, object, deleted }) => {
console.log(ids);
})
```
#### Parameters
<TypeList types={[{"name":"priceListId","type":"`string`","description":"The ID of the price list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variantId","type":"`string`","description":"The ID of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteVariantPrices"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPriceListDeleteBatchRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"AdminPriceListDeleteBatchRes","type":"[AdminPriceListDeleteBatchRes](../../../medusa/types/medusa.AdminPriceListDeleteBatchRes/page.mdx)","optional":false,"defaultValue":"","description":"The details of deleting a price list.","expandable":false,"children":[{"name":"ids","type":"`string`[]","description":"The IDs of the deleted prices.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether or not the items were deleted.","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the object that was deleted. A price is also named `money-amount`.","optional":false,"defaultValue":"money-amount","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteVariantPrices"/>
### deleteProductsPrices
Delete all the prices associated with multiple products in a price list.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.deleteProductsPrices(priceListId, {
product_ids: [
productId1,
productId2,
]
})
.then(({ ids, object, deleted }) => {
console.log(ids.length);
})
```
#### Parameters
<TypeList types={[{"name":"priceListId","type":"`string`","description":"The ID of the price list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminDeletePriceListsPriceListProductsPricesBatchReq](../../../medusa/classes/medusa.AdminDeletePriceListsPriceListProductsPricesBatchReq/page.mdx)","description":"The products whose prices should be deleted.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"product_ids","type":"`string`[]","description":"The IDs of the products to delete their associated prices.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteProductsPrices"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPriceListDeleteBatchRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"AdminPriceListDeleteBatchRes","type":"[AdminPriceListDeleteBatchRes](../../../medusa/types/medusa.AdminPriceListDeleteBatchRes/page.mdx)","optional":false,"defaultValue":"","description":"The details of deleting a price list.","expandable":false,"children":[{"name":"ids","type":"`string`[]","description":"The IDs of the deleted prices.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether or not the items were deleted.","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the object that was deleted. A price is also named `money-amount`.","optional":false,"defaultValue":"money-amount","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteProductsPrices"/>
@@ -0,0 +1,257 @@
---
slug: /references/js-client/AdminProductCategoriesResource
---
import { TypeList } from "docs-ui"
# AdminProductCategoriesResource
:::note
To use this resource, make sure to [enable its feature flag: product_categories](https://docs.medusajs.com/development/feature-flags/toggle)
:::
This class is used to send requests to [Admin Product Category API Routes](https://docs.medusajs.com/api/admin#product-categories). All its method
are available in the JS Client under the `medusa.admin.productCategories` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Products can be categoriezed into categories. A product can be added into more than one category.
Related Guide: [How to manage product categories](https://docs.medusajs.com/modules/products/admin/manage-categories).
## Methods
### retrieve
Retrieve a product category's details.
#### Example
A simple example that retrieves an order by its ID:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productCategories.retrieve(productCategoryId)
.then(({ product_category }) => {
console.log(product_category.id);
})
```
To specify relations that should be retrieved:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productCategories.retrieve(productCategoryId, {
expand: "category_children"
})
.then(({ product_category }) => {
console.log(product_category.id);
})
```
#### Parameters
<TypeList types={[{"name":"productCategoryId","type":"`string`","description":"The ID of the product category.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetProductCategoryParams](../../../medusa/classes/medusa.AdminGetProductCategoryParams/page.mdx)","description":"Configurations to apply on the retrieved product category.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductCategoriesCategoryRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product category's details.","expandable":false,"children":[{"name":"AdminProductCategoriesCategoryRes","type":"[AdminProductCategoriesCategoryRes](../../../medusa/types/medusa.AdminProductCategoriesCategoryRes/page.mdx)","optional":false,"defaultValue":"","description":"The product category's details.","expandable":false,"children":[{"name":"product_category","type":"[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx)","description":"Product category details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"category_children","type":"Collection&#60;[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"category_children","type":"Collection&#60;[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"Collection&#60;[Product](../../../product_models/classes/product_models.Product/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"mpath","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_active","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_internal","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rank","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"parent_category_id","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"parent_category","type":"[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"products","type":"Collection&#60;[Product](../../../product_models/classes/product_models.Product/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection","type":"`null` \\| [ProductCollection](../../../product_models/classes/product_models.ProductCollection/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tLine truncated
### create
Create a product category.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productCategories.create({
name: "Skinny Jeans",
})
.then(({ product_category }) => {
console.log(product_category.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostProductCategoriesReq](../../../medusa/classes/medusa.AdminPostProductCategoriesReq/page.mdx)","description":"The product category's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"name","type":"`string`","description":"The name of the product category","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs to hold additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The description of the product category.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"The handle of the product category. If none is provided, the kebab-case version of the name will be used. This field can be used as a slug in URLs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_internal","type":"`boolean`","description":"If set to `true`, the product category will only be available to admins.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_active","type":"`boolean`","description":"If set to `false`, the product category will not be available in the storefront.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"parent_category_id","type":"`null` \\| `string`","description":"The ID of the parent product category","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductCategoriesCategoryRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product category's details.","expandable":false,"children":[{"name":"AdminProductCategoriesCategoryRes","type":"[AdminProductCategoriesCategoryRes](../../../medusa/types/medusa.AdminProductCategoriesCategoryRes/page.mdx)","optional":false,"defaultValue":"","description":"The product category's details.","expandable":false,"children":[{"name":"product_category","type":"[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx)","description":"Product category details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"category_children","type":"Collection&#60;[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"category_children","type":"Collection&#60;[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"Collection&#60;[Product](../../../product_models/classes/product_models.Product/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"mpath","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_active","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_internal","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rank","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"parent_category_id","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"parent_category","type":"[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"products","type":"Collection&#60;[Product](../../../product_models/classes/product_models.Product/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection","type":"`null` \\| [ProductCollection](../../../product_models/classes/product_models.ProductCollection/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tLine truncated
### update
Updates a product category.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productCategories.update(productCategoryId, {
name: "Skinny Jeans"
})
.then(({ product_category }) => {
console.log(product_category.id);
})
```
#### Parameters
<TypeList types={[{"name":"productCategoryId","type":"`string`","description":"The ID of the product category.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostProductCategoriesCategoryReq](../../../medusa/classes/medusa.AdminPostProductCategoriesCategoryReq/page.mdx)","description":"The attributes to update in the product category.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"name","type":"`string`","description":"The name to identify the Product Category by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"A handle to be used in slugs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rank","type":"`number`","description":"The rank of the category in the tree node (starting from 0)","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs to hold additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"An optional text field to describe the Product Category by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_internal","type":"`boolean`","description":"A flag to make product category an internal category for admins","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_active","type":"`boolean`","description":"A flag to make product category visible/hidden in the store front","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"parent_category_id","type":"`null` \\| `string`","description":"The ID of the parent product category","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductCategoriesCategoryRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product category's details.","expandable":false,"children":[{"name":"AdminProductCategoriesCategoryRes","type":"[AdminProductCategoriesCategoryRes](../../../medusa/types/medusa.AdminProductCategoriesCategoryRes/page.mdx)","optional":false,"defaultValue":"","description":"The product category's details.","expandable":false,"children":[{"name":"product_category","type":"[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx)","description":"Product category details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"category_children","type":"Collection&#60;[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"category_children","type":"Collection&#60;[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"Collection&#60;[Product](../../../product_models/classes/product_models.Product/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"mpath","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_active","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_internal","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rank","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"parent_category_id","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"parent_category","type":"[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"products","type":"Collection&#60;[Product](../../../product_models/classes/product_models.Product/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection","type":"`null` \\| [ProductCollection](../../../product_models/classes/product_models.ProductCollection/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tLine truncated
### list
Retrieve a list of product categories. The product categories can be filtered by fields such as `q` or `handle` passed in the `query` parameter.
The product categories can also be paginated.
#### Example
To list product categories:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productCategories.list()
.then(({ product_categories, limit, offset, count }) => {
console.log(product_categories.length);
})
```
To specify relations that should be retrieved within the product category:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productCategories.list({
expand: "category_children"
})
.then(({ product_categories, limit, offset, count }) => {
console.log(product_categories.length);
})
```
By default, only the first `100` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productCategories.list({
expand: "category_children",
limit,
offset
})
.then(({ product_categories, limit, offset, count }) => {
console.log(product_categories.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetProductCategoriesParams](../../../medusa/classes/medusa.AdminGetProductCategoriesParams/page.mdx)","description":"Filters and pagination configurations to apply on the retrieved product categories.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Search term to search product categories' names and handles.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"Handle to filter product categories by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"include_descendants_tree","type":"`boolean`","description":"Whether to include child product categories in the response.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_internal","type":"`boolean`","description":"Filter product categories by whether they're internal.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_active","type":"`boolean`","description":"Filter product categories by whether they're active.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"parent_category_id","type":"`null` \\| `string`","description":"Filter product categories by their associated parent ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"Limit the number of product categories returned in the list. The default is `100`.","optional":true,"defaultValue":"20","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductCategoriesListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of product categories with pagination fields.","expandable":false,"children":[{"name":"AdminProductCategoriesListRes","type":"[AdminProductCategoriesListRes](../../../medusa/types/medusa.AdminProductCategoriesListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of product categories with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_categories","type":"[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx)[]","description":"An array of product category details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"category_children","type":"Collection&#60;[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"category_children","type":"Collection&#60;[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"Collection&#60;[Product](../../../product_models/classes/product_models.Product/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"mpath","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_active","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_internal","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rank","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"parent_category_id","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"parent_category","type":"[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"products","type":"Collection&#60;[Product](../../../product_models/classes/product_models.Product/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","opLine truncated
### delete
Delete a product category. This does not delete associated products.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productCategories.delete(productCategoryId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"productCategoryId","type":"`string`","description":"The ID of the product category.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"[DeleteResponse](../../../medusa/interfaces/medusa.DeleteResponse/page.mdx)","optional":false,"defaultValue":"","description":"The response returned for a \n\n`DELETE`\n\n request.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the deleted item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the deleted item.","optional":false,"defaultValue":"product-collection","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether the item was deleted successfully.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### removeProducts
Remove a list of products from a product category.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productCategories.removeProducts(productCategoryId, {
product_ids: [
{
id: productId
}
]
})
.then(({ product_category }) => {
console.log(product_category.id);
})
```
#### Parameters
<TypeList types={[{"name":"productCategoryId","type":"`string`","description":"The ID of the product category.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminDeleteProductCategoriesCategoryProductsBatchReq](../../../medusa/classes/medusa.AdminDeleteProductCategoriesCategoryProductsBatchReq/page.mdx)","description":"The products to delete.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"product_ids","type":"[ProductBatchProductCategory](../../../medusa/classes/medusa.ProductBatchProductCategory/page.mdx)[]","description":"The IDs of the products to delete from the product category.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeProducts"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductCategoriesCategoryRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product category's details.","expandable":false,"children":[{"name":"AdminProductCategoriesCategoryRes","type":"[AdminProductCategoriesCategoryRes](../../../medusa/types/medusa.AdminProductCategoriesCategoryRes/page.mdx)","optional":false,"defaultValue":"","description":"The product category's details.","expandable":false,"children":[{"name":"product_category","type":"[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx)","description":"Product category details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"category_children","type":"Collection&#60;[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"category_children","type":"Collection&#60;[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"Collection&#60;[Product](../../../product_models/classes/product_models.Product/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"mpath","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_active","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_internal","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rank","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"parent_category_id","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"parent_category","type":"[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"products","type":"Collection&#60;[Product](../../../product_models/classes/product_models.Product/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection","type":"`null` \\| [ProductCollection](../../../product_models/classes/product_models.ProductCollection/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tLine truncated
### addProducts
Add a list of products to a product category.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productCategories.addProducts(productCategoryId, {
product_ids: [
{
id: productId
}
]
})
.then(({ product_category }) => {
console.log(product_category.id);
})
```
#### Parameters
<TypeList types={[{"name":"productCategoryId","type":"`string`","description":"The ID of the product category.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostProductCategoriesCategoryProductsBatchReq](../../../medusa/classes/medusa.AdminPostProductCategoriesCategoryProductsBatchReq/page.mdx)","description":"The products to add.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"product_ids","type":"[ProductBatchProductCategory](../../../medusa/classes/medusa.ProductBatchProductCategory/page.mdx)[]","description":"The IDs of the products to add to the product category","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the product","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addProducts"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductCategoriesCategoryRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product category's details.","expandable":false,"children":[{"name":"AdminProductCategoriesCategoryRes","type":"[AdminProductCategoriesCategoryRes](../../../medusa/types/medusa.AdminProductCategoriesCategoryRes/page.mdx)","optional":false,"defaultValue":"","description":"The product category's details.","expandable":false,"children":[{"name":"product_category","type":"[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx)","description":"Product category details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"category_children","type":"Collection&#60;[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"category_children","type":"Collection&#60;[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"Collection&#60;[Product](../../../product_models/classes/product_models.Product/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"mpath","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_active","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_internal","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rank","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"parent_category_id","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"parent_category","type":"[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"products","type":"Collection&#60;[Product](../../../product_models/classes/product_models.Product/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection","type":"`null` \\| [ProductCollection](../../../product_models/classes/product_models.ProductCollection/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tLine truncated
@@ -0,0 +1,58 @@
---
slug: /references/js-client/AdminProductTagsResource
---
import { TypeList } from "docs-ui"
# AdminProductTagsResource
This class is used to send requests to [Admin Product Tag API Routes](https://docs.medusajs.com/api/admin#product-tags). All its method
are available in the JS Client under the `medusa.admin.productTags` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Product tags are string values created when you create or update a product with a new tag.
Products can have more than one tag, and products can share tags. This allows admins to associate products to similar tags that can be used to filter products.
## Methods
### list
Retrieve a list of product tags. The product tags can be filtered by fields such as `q` or `value` passed in the `query` parameter. The product tags can also be sorted or paginated.
#### Example
To list product tags:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productTags.list()
.then(({ product_tags }) => {
console.log(product_tags.length);
})
```
By default, only the first `10` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productTags.list({
limit,
offset
})
.then(({ product_tags }) => {
console.log(product_tags.length);
})
```
#### Parameters
<TypeList types={[{"name":"query","type":"[AdminGetProductTagsParams](../../../medusa/classes/medusa.AdminGetProductTagsParams/page.mdx)","description":"Filters and pagination configurations to apply on the retrieved product tags.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":false,"defaultValue":"10","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":false,"defaultValue":"0","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[] \\| [StringComparisonOperator](../../../medusa/classes/medusa.StringComparisonOperator/page.mdx)","description":"IDs to filter product tags by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"q","type":"`string`","description":"Search term to search product tags' value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string` \\| `string`[] \\| [StringComparisonOperator](../../../medusa/classes/medusa.StringComparisonOperator/page.mdx)","description":"Values to search product tags by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the product tags' `created_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"updated_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the product tags' `updated_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_condition_id","type":"`string`","description":"Filter product tags by their associated discount condition's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductTagsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of product tags with pagination fields.","expandable":false,"children":[{"name":"AdminProductTagsListRes","type":"[AdminProductTagsListRes](../../../medusa/types/medusa.AdminProductTagsListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of product tags with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_tags","type":"[ProductTag](../../../product_models/classes/product_models.ProductTag/page.mdx)[]","description":"An array of product tag details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"Collection&#60;[Product](../../../product_models/classes/product_models.Product/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection","type":"`null` \\| [ProductCollection](../../../product_models/classes/product_models.ProductCollection/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`null` \\| [ProductType](../../../product_models/classes/product_models.ProductType/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tags","type":"Collection&#60;[ProductTag](../../../product_models/classes/product_models.ProductTag/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"images","type":"Collection&#60;[Image](../../../product_models/classes/product_models.Image/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"categories","type":"Collection&#60;[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discountable","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description",Line truncated
@@ -0,0 +1,59 @@
---
slug: /references/js-client/AdminProductTypesResource
---
import { TypeList } from "docs-ui"
# AdminProductTypesResource
This class is used to send requests to [Admin Product Type API Routes](https://docs.medusajs.com/api/admin#product-types). All its method
are available in the JS Client under the `medusa.admin.productTypes` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Product types are string values created when you create or update a product with a new type.
Products can have one type, and products can share types. This allows admins to associate products with a type that can be used to filter products.
## Methods
### list
Retrieve a list of product types. The product types can be filtered by fields such as `q` or `value` passed in the `query` parameter.
The product types can also be sorted or paginated.
#### Example
To list product types:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productTypes.list()
.then(({ product_types }) => {
console.log(product_types.length);
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productTypes.list({
limit,
offset
})
.then(({ product_types }) => {
console.log(product_types.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetProductTypesParams](../../../medusa/classes/medusa.AdminGetProductTypesParams/page.mdx)","description":"Filters and pagination configurations to apply on the retrieved product types.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string` \\| `string`[] \\| [StringComparisonOperator](../../../medusa/classes/medusa.StringComparisonOperator/page.mdx)","description":"IDs to filter product types by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"q","type":"`string`","description":"Search terms to search product types' value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string` \\| `string`[] \\| [StringComparisonOperator](../../../medusa/classes/medusa.StringComparisonOperator/page.mdx)","description":"Values to filter product types by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the product types' `created_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"updated_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the product types' `updated_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_condition_id","type":"`string`","description":"Filter product types by their associated discount condition's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":true,"defaultValue":"20","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductTypesListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of product types with pagination fields.","expandable":false,"children":[{"name":"AdminProductTypesListRes","type":"[AdminProductTypesListRes](../../../medusa/types/medusa.AdminProductTypesListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of product types with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_types","type":"[ProductType](../../../product_models/classes/product_models.ProductType/page.mdx)[]","description":"An array of product types details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
@@ -0,0 +1,420 @@
---
slug: /references/js-client/AdminProductsResource
---
import { TypeList } from "docs-ui"
# AdminProductsResource
This class is used to send requests to [Admin Product API Routes](https://docs.medusajs.com/api/admin#products). All its method
are available in the JS Client under the `medusa.admin.products` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Products are saleable items in a store. This also includes [saleable gift cards](https://docs.medusajs.com/modules/gift-cards/admin/manage-gift-cards#manage-gift-card-product) in a store.
Related Guide: [How to manage products](https://docs.medusajs.com/modules/products/admin/manage-products).
## Methods
### create
Create a new Product. This API Route can also be used to create a gift card if the `is_giftcard` field is set to `true`.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.create({
title: "Shirt",
is_giftcard: false,
discountable: true
})
.then(({ product }) => {
console.log(product.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostProductsReq](../../../medusa/classes/medusa.AdminPostProductsReq/page.mdx)","description":"The product to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"title","type":"`string`","description":"The title of the Product","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"A flag to indicate if the Product represents a Gift Card. Purchasing Products with this flag set to `true` will result in a Gift Card being created.","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"discountable","type":"`boolean`","description":"A flag to indicate if discounts can be applied to the Line Items generated from this Product","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"subtitle","type":"`string`","description":"The subtitle of the Product","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The description of the Product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"images","type":"`string`[]","description":"An array of images of the Product. Each value in the array is a URL to the image. You can use the upload API Routes to upload the image and obtain a URL.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`string`","description":"The thumbnail to use for the Product. The value is a URL to the thumbnail. You can use the upload API Routes to upload the thumbnail and obtain a URL.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"A unique handle to identify the Product by. If not provided, the kebab-case version of the product title will be used. This can be used as a slug in URLs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../product/enums/product.ProductStatus/page.mdx)","description":"The status of the product. The product is shown to the customer only if its status is `published`.","optional":true,"defaultValue":"ProductStatus.DRAFT","expandable":false,"children":[{"name":"DRAFT","type":"`\"draft\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PROPOSED","type":"`\"proposed\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PUBLISHED","type":"`\"published\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"REJECTED","type":"`\"rejected\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"type","type":"[ProductTypeReq](../../../medusa/classes/medusa.ProductTypeReq/page.mdx)","description":"The Product Type to associate the Product with.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string`","description":"The value of the product type.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"The ID of the product type. It's only required when referring to an existing product type.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"collection_id","type":"`string`","description":"The ID of the Product Collection the Product belongs to.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"tags","type":"[ProductTagReq](../../../medusa/classes/medusa.ProductTagReq/page.mdx)[]","description":"Product Tags to associate the Product with.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string`","description":"The value of the Tag. If the `id` is provided, the value of the existing tag will be updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"The ID of an existing Product Tag. If not provided, a new product tag will be created.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"sales_channels","type":"[ProductSalesChannelReq](../../../medusa/classes/medusa.ProductSalesChannelReq/page.mdx)[]","description":"Sales channels to associate the Product with.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of an existing Sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"categories","type":"[ProductProductCategoryReq](../../../medusa/classes/medusa.ProductProductCategoryReq/page.mdx)[]","description":"Product categories to add the Product to.","optional":true,"defaultValue":"","expandable":false,"featureFlag":"product_categories","children":[{"name":"id","type":"`string`","description":"The ID of a Product Category.","optionaLine truncated
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product's details.","expandable":false,"children":[{"name":"AdminProductsRes","type":"[AdminProductsRes](../../../medusa/types/medusa.AdminProductsRes/page.mdx)","optional":false,"defaultValue":"","description":"The product's details.","expandable":false,"children":[{"name":"product","type":"[Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"Product details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"DRAFT","type":"`\"draft\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PROPOSED","type":"`\"proposed\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PUBLISHED","type":"`\"published\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"REJECTED","type":"`\"rejected\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"values","type":"Collection&#60;[ProductOptionValue](../../../product_models/classes/product_models.ProductOptionValue/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOptionValue](../../../product_models/classes/product_models.ProductOptionValue/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"sku","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"barcode","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ean","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"upc","type":"`null` \\| `string`","description":"","optionaLine truncated
### retrieve
Retrieve a product's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.retrieve(productId)
.then(({ product }) => {
console.log(product.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The product's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product's details.","expandable":false,"children":[{"name":"AdminProductsRes","type":"[AdminProductsRes](../../../medusa/types/medusa.AdminProductsRes/page.mdx)","optional":false,"defaultValue":"","description":"The product's details.","expandable":false,"children":[{"name":"product","type":"[Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"Product details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"DRAFT","type":"`\"draft\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PROPOSED","type":"`\"proposed\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PUBLISHED","type":"`\"published\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"REJECTED","type":"`\"rejected\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"values","type":"Collection&#60;[ProductOptionValue](../../../product_models/classes/product_models.ProductOptionValue/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOptionValue](../../../product_models/classes/product_models.ProductOptionValue/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"sku","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"barcode","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ean","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"upc","type":"`null` \\| `string`","description":"","optionaLine truncated
### update
Update a Product's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.update(productId, {
title: "Shirt",
})
.then(({ product }) => {
console.log(product.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The product's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostProductsProductReq](../../../medusa/classes/medusa.AdminPostProductsProductReq/page.mdx)","description":"The attributes to update in a product.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"title","type":"`string`","description":"The title of the Product","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`string`","description":"The subtitle of the Product","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The description of the Product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"discountable","type":"`boolean`","description":"A flag to indicate if discounts can be applied to the Line Items generated from this Product","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"images","type":"`string`[]","description":"An array of images of the Product. Each value in the array is a URL to the image. You can use the upload API Routes to upload the image and obtain a URL.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`string`","description":"The thumbnail to use for the Product. The value is a URL to the thumbnail. You can use the upload API Routes to upload the thumbnail and obtain a URL.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"A unique handle to identify the Product by. If not provided, the kebab-case version of the product title will be used. This can be used as a slug in URLs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../product/enums/product.ProductStatus/page.mdx)","description":"The status of the product. The product is shown to the customer only if its status is `published`.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"DRAFT","type":"`\"draft\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PROPOSED","type":"`\"proposed\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PUBLISHED","type":"`\"published\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"REJECTED","type":"`\"rejected\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"type","type":"[ProductTypeReq](../../../medusa/classes/medusa.ProductTypeReq/page.mdx)","description":"The Product Type to associate the Product with.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string`","description":"The value of the product type.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"The ID of the product type. It's only required when referring to an existing product type.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"collection_id","type":"`string`","description":"The ID of the Product Collection the Product belongs to.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"tags","type":"[ProductTagReq](../../../medusa/classes/medusa.ProductTagReq/page.mdx)[]","description":"Product Tags to associate the Product with.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string`","description":"The value of the Tag. If the `id` is provided, the value of the existing tag will be updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"The ID of an existing Product Tag. If not provided, a new product tag will be created.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"sales_channels","type":"`null` \\| [ProductSalesChannelReq](../../../medusa/classes/medusa.ProductSalesChannelReq/page.mdx)[]","description":"Sales channels to associate the Product with.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"categories","type":"[ProductProductCategoryReq](../../../medusa/classes/medusa.ProductProductCategoryReq/page.mdx)[]","description":"Product categories to add the Product to.","optional":true,"defaultValue":"","expandable":false,"featureFlag":"product_categories","children":[{"name":"id","type":"`string`","description":"The ID of a Product Category.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"variants","type":"[ProductVariantReq](../../../medusa/classes/medusa.ProductVariantReq-1/page.mdx)[]","description":"An array of Product Variants to create with the Product. Each product variant must have a uniLine truncated
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product's details.","expandable":false,"children":[{"name":"AdminProductsRes","type":"[AdminProductsRes](../../../medusa/types/medusa.AdminProductsRes/page.mdx)","optional":false,"defaultValue":"","description":"The product's details.","expandable":false,"children":[{"name":"product","type":"[Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"Product details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"DRAFT","type":"`\"draft\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PROPOSED","type":"`\"proposed\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PUBLISHED","type":"`\"published\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"REJECTED","type":"`\"rejected\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"values","type":"Collection&#60;[ProductOptionValue](../../../product_models/classes/product_models.ProductOptionValue/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOptionValue](../../../product_models/classes/product_models.ProductOptionValue/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"sku","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"barcode","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ean","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"upc","type":"`null` \\| `string`","description":"","optionaLine truncated
### delete
Delete a product and its associated product variants and options.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.delete(productId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The product's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsDeleteRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"AdminProductsDeleteRes","type":"[AdminProductsDeleteRes](../../../medusa/types/medusa.AdminProductsDeleteRes/page.mdx)","optional":false,"defaultValue":"","description":"The details of deleting a product.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the deleted Product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`\"product\"`","description":"The type of the object that was deleted.","optional":false,"defaultValue":"product","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether or not the items were deleted.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### list
Retrieve a list of products. The products can be filtered by fields such as `q` or `status` passed in the `query` parameter. The products can also be sorted or paginated.
#### Example
To list products:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.list()
.then(({ products, limit, offset, count }) => {
console.log(products.length);
})
```
To specify relations that should be retrieved within the products:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.list({
expand: "images"
})
.then(({ products, limit, offset, count }) => {
console.log(products.length);
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.list({
expand: "images",
limit,
offset
})
.then(({ products, limit, offset, count }) => {
console.log(products.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetProductsParams](../../../medusa/classes/medusa.AdminGetProductsParams/page.mdx)","description":"Filters and pagination configurations to apply on the retrieved products.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":true,"defaultValue":"50","expandable":false,"children":[]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"IDs to filter products by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"q","type":"`string`","description":"Search term to search products' title, description, variants' title and sku, and collections' title.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../product/enums/product.ProductStatus/page.mdx)[]","description":"Statuses to filter products by.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"DRAFT","type":"`\"draft\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PROPOSED","type":"`\"proposed\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PUBLISHED","type":"`\"published\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"REJECTED","type":"`\"rejected\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"price_list_id","type":"`string`[]","description":"Filter products by their associated price lists' ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"collection_id","type":"`string`[]","description":"Filter products by their associated product collection's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"tags","type":"`string`[]","description":"Filter products by their associated tags' value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"Title to filter products by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"Description to filter products by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"Handle to filter products by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"Filter products by whether they're gift cards.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type_id","type":"`string`[]","description":"Filter products by their associated product type's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"sales_channel_id","type":"`string`[]","description":"Filter products by their associated sales channels' ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_condition_id","type":"`string`","description":"Filter products by their associated discount condition's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"category_id","type":"`string`[]","description":"Filter products by their associated product category's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"include_category_children","type":"`boolean`","description":"Whether to include product category children in the response.","optional":true,"defaultValue":"","expandable":false,"featureFlag":"product_categories","children":[]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description"Line truncated
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of products with pagination fields.","expandable":false,"children":[{"name":"AdminProductsListRes","type":"[AdminProductsListRes](../../../medusa/types/medusa.AdminProductsListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of products with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"([PricedProduct](../../../medusa/types/medusa.PricedProduct/page.mdx) \\| [Product](../../../product_models/classes/product_models.Product/page.mdx))[]","description":"An array of products details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### listTags
Retrieve a list of Product Tags with how many times each is used in products.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.listTags()
.then(({ tags }) => {
console.log(tags.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listTags"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsListTagsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of tags.","expandable":false,"children":[{"name":"AdminProductsListTagsRes","type":"[AdminProductsListTagsRes](../../../medusa/types/medusa.AdminProductsListTagsRes/page.mdx)","optional":false,"defaultValue":"","description":"The usage details of product tags.","expandable":false,"children":[{"name":"tags","type":"Pick&#60;ProductTag, \"id\" \\| \"value\"&#62; & `object`[]","description":"An array of product tags details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"usage_count","type":"`number`","description":"The number of products that use this tag.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listTags"/>
### setMetadata
Set the metadata of a product. It can be any key-value pair, which allows adding custom data to a product. Learn about how you can update and delete the metadata attribute
[here](https://docs.medusajs.com/development/entities/overview#metadata-attribute).
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.setMetadata(productId, {
key: "test",
value: "true"
})
.then(({ product }) => {
console.log(product.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The product's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostProductsProductMetadataReq](../../../medusa/classes/medusa.AdminPostProductsProductMetadataReq/page.mdx)","description":"The metadata details to add, update, or delete.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"key","type":"`string`","description":"The metadata key","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string`","description":"The metadata value","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="setMetadata"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product's details.","expandable":false,"children":[{"name":"AdminProductsRes","type":"[AdminProductsRes](../../../medusa/types/medusa.AdminProductsRes/page.mdx)","optional":false,"defaultValue":"","description":"The product's details.","expandable":false,"children":[{"name":"product","type":"[Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"Product details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"DRAFT","type":"`\"draft\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PROPOSED","type":"`\"proposed\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PUBLISHED","type":"`\"published\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"REJECTED","type":"`\"rejected\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"values","type":"Collection&#60;[ProductOptionValue](../../../product_models/classes/product_models.ProductOptionValue/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOptionValue](../../../product_models/classes/product_models.ProductOptionValue/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"sku","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"barcode","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ean","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"upc","type":"`null` \\| `string`","description":"","optionaLine truncated
### createVariant
Create a product variant associated with a product. Each product variant must have a unique combination of product option values.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.createVariant(productId, {
title: "Color",
prices: [
{
amount: 1000,
currency_code: "eur"
}
],
options: [
{
option_id,
value: "S"
}
],
inventory_quantity: 100
})
.then(({ product }) => {
console.log(product.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product that the variant belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostProductsProductVariantsReq](../../../medusa/classes/medusa.AdminPostProductsProductVariantsReq/page.mdx)","description":"The product variant to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"title","type":"`string`","description":"The title of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"prices","type":"[ProductVariantPricesCreateReq](../../../medusa/classes/medusa.ProductVariantPricesCreateReq/page.mdx)[]","description":"An array of product variant prices. A product variant can have different prices for each region or currency code.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"amount","type":"`number`","description":"The price amount.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`string`","description":"The ID of the Region the price will be used in. This is only required if `currency\\_code` is not provided.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The 3 character ISO currency code the price will be used in. This is only required if `region\\_id` is not provided.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"min_quantity","type":"`number`","description":"The minimum quantity required to be added to the cart for the price to be used.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"max_quantity","type":"`number`","description":"The maximum quantity required to be added to the cart for the price to be used.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"sku","type":"`string`","description":"The unique SKU of the product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ean","type":"`string`","description":"The EAN number of the product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"upc","type":"`string`","description":"The UPC number of the product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"barcode","type":"`string`","description":"A generic GTIN field of the product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"hs_code","type":"`string`","description":"The Harmonized System code of the product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"inventory_quantity","type":"`number`","description":"The amount of stock kept of the product variant.","optional":true,"defaultValue":"0","expandable":false,"children":[]},{"name":"allow_backorder","type":"`boolean`","description":"Whether the product variant can be purchased when out of stock.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"manage_inventory","type":"`boolean`","description":"Whether Medusa should keep track of the inventory of this product variant.","optional":true,"defaultValue":"true","expandable":false,"children":[]},{"name":"weight","type":"`number`","description":"The wieght of the product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`number`","description":"The length of the product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`number`","description":"The height of the product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`number`","description":"The width of the product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`string`","description":"The country of origin of the product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"mid_code","type":"`string`","description":"The Manufacturer Identification code of the product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"material","type":"`string`","description":"The material composition of the product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs with additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"[ProductVariantOptionReq](../../../medusa/classes/medusa.ProductVariantOptionReq-1/page.mdx)[]","description":"An array of Product Option values that the variant corresponds to.","optional":true,"defaultValue":"[]","expandable":false,"children":[{"name":"value","type":"`string`","description":"A value toLine truncated
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product's details. You can access the variant under the `variants` property.","expandable":false,"children":[{"name":"AdminProductsRes","type":"[AdminProductsRes](../../../medusa/types/medusa.AdminProductsRes/page.mdx)","optional":false,"defaultValue":"","description":"The product's details.","expandable":false,"children":[{"name":"product","type":"[Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"Product details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"DRAFT","type":"`\"draft\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PROPOSED","type":"`\"proposed\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PUBLISHED","type":"`\"published\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"REJECTED","type":"`\"rejected\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"values","type":"Collection&#60;[ProductOptionValue](../../../product_models/classes/product_models.ProductOptionValue/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOptionValue](../../../product_models/classes/product_models.ProductOptionValue/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"sku","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"barcode","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ean","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"uLine truncated
### updateVariant
Update a product variant's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.updateVariant(productId, variantId, {
title: "Color",
prices: [
{
amount: 1000,
currency_code: "eur"
}
],
options: [
{
option_id,
value: "S"
}
],
inventory_quantity: 100
})
.then(({ product }) => {
console.log(product.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product that the variant belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variantId","type":"`string`","description":"The ID of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostProductsProductVariantsVariantReq](../../../medusa/classes/medusa.AdminPostProductsProductVariantsVariantReq/page.mdx)","description":"The attributes to update in the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"title","type":"`string`","description":"The title of the product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"sku","type":"`string`","description":"The unique SKU of the product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ean","type":"`string`","description":"The EAN number of the item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"upc","type":"`string`","description":"The UPC number of the item.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"barcode","type":"`string`","description":"A generic GTIN field of the product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"hs_code","type":"`string`","description":"The Harmonized System code of the product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"inventory_quantity","type":"`number`","description":"The amount of stock kept of the product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"allow_backorder","type":"`boolean`","description":"Whether the product variant can be purchased when out of stock.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"manage_inventory","type":"`boolean`","description":"Whether Medusa should keep track of the inventory of this product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`number`","description":"The weight of the product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`number`","description":"The length of the product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`number`","description":"The height of the product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`number`","description":"The width of the product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`string`","description":"The country of origin of the product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"mid_code","type":"`string`","description":"The Manufacturer Identification code of the product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"material","type":"`string`","description":"The material composition of the product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs with additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"prices","type":"[ProductVariantPricesUpdateReq](../../../medusa/classes/medusa.ProductVariantPricesUpdateReq/page.mdx)[]","description":"An array of product variant prices. A product variant can have different prices for each region or currency code.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"amount","type":"`number`","description":"The price amount.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"The ID of the Price. If provided, the existing price will be updated. Otherwise, a new price will be created.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`string`","description":"The ID of the Region the price will be used in. This is only required if `currency\\_code` is not provided.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The 3 character ISO currency code the price will be used in. This is only required if `region\\_id` is not provided.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"min_quantity","type":"`number`","description":"The minimum quantity required to be added to the cart for the price to be used.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"max_quantity","type":"`number`","description":"The maximum quantity required to be added to the cart for the price to be used.","optional":true,"deLine truncated
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product's details. You can access the variant under the `variants` property.","expandable":false,"children":[{"name":"AdminProductsRes","type":"[AdminProductsRes](../../../medusa/types/medusa.AdminProductsRes/page.mdx)","optional":false,"defaultValue":"","description":"The product's details.","expandable":false,"children":[{"name":"product","type":"[Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"Product details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"DRAFT","type":"`\"draft\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PROPOSED","type":"`\"proposed\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PUBLISHED","type":"`\"published\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"REJECTED","type":"`\"rejected\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"values","type":"Collection&#60;[ProductOptionValue](../../../product_models/classes/product_models.ProductOptionValue/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOptionValue](../../../product_models/classes/product_models.ProductOptionValue/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"sku","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"barcode","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ean","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"uLine truncated
### deleteVariant
Delete a product variant.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.deleteVariant(productId, variantId)
.then(({ variant_id, object, deleted, product }) => {
console.log(product.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product that the variant belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variantId","type":"`string`","description":"The ID of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteVariant"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsDeleteVariantRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"AdminProductsDeleteVariantRes","type":"[AdminProductsDeleteVariantRes](../../../medusa/types/medusa.AdminProductsDeleteVariantRes/page.mdx)","optional":false,"defaultValue":"","description":"The details of deleting a product's variant.","expandable":false,"children":[{"name":"variant_id","type":"`string`","description":"The ID of the deleted Product Variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`\"product-variant\"`","description":"The type of the object that was deleted.","optional":false,"defaultValue":"product-variant","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether or not the items were deleted.","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"product","type":"[Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"Product details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"DRAFT","type":"`\"draft\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PROPOSED","type":"`\"proposed\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PUBLISHED","type":"`\"published\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"REJECTED","type":"`\"rejected\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"values","type":"Collection&#60;[ProductOptionValue](../../../product_models/classes/product_models.ProductOptionValue/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOptionValue](../../../product_models/classes/product_models.ProductOptionValue/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandableLine truncated
### listVariants
List the product variants associated with a product. The product variants can be filtered by fields such as `q` or `manage_inventory` passed in the `query` parameter. The product variants can also be sorted or paginated.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.listVariants(productId, {
limit: 10,
})
.then(({ variants, limit, offset, count }) => {
console.log(variants.length);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product that the variants belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetProductsVariantsParams](../../../medusa/classes/medusa.AdminGetProductsVariantsParams/page.mdx)","description":"Filters and pagination configurations to apply on the retrieved product variants. If undefined, the first 100 records are retrieved.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string` \\| `string`[]","description":"IDs to filter product variants by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":true,"defaultValue":"100","expandable":false,"children":[]},{"name":"q","type":"`string`","description":"Search term to search product variants' title, sku, and products' title.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"inventory_quantity","type":"`number` \\| [NumericalComparisonOperator](../../../medusa/classes/medusa.NumericalComparisonOperator/page.mdx)","description":"Number filters to apply on product variants' `inventory_quantity` field.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"manage_inventory","type":"`boolean`","description":"Filter product variants by whether their inventory is managed or not.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"allow_backorder","type":"`boolean`","description":"Filter product variants by whether they are allowed to be backordered or not.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the product variants' `created_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"updated_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the product variants' `updated_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listVariants"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsListVariantsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of product variants with pagination fields.","expandable":false,"children":[{"name":"AdminProductsListVariantsRes","type":"[AdminProductsListVariantsRes](../../../medusa/types/medusa.AdminProductsListVariantsRes/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variants","type":"[ProductVariant](../../../medusa_react/types/medusa_react.ProductVariant/page.mdx)[]","description":"An array of product variants details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listVariants"/>
### addOption
Add a product option to a product.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.addOption(productId, {
title: "Size"
})
.then(({ product }) => {
console.log(product.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The product's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostProductsProductOptionsReq](../../../medusa/classes/medusa.AdminPostProductsProductOptionsReq/page.mdx)","description":"The option to add.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"title","type":"`string`","description":"The title the Product Option.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addOption"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product's details. You can access the variant under the `options` property.","expandable":false,"children":[{"name":"AdminProductsRes","type":"[AdminProductsRes](../../../medusa/types/medusa.AdminProductsRes/page.mdx)","optional":false,"defaultValue":"","description":"The product's details.","expandable":false,"children":[{"name":"product","type":"[Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"Product details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"DRAFT","type":"`\"draft\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PROPOSED","type":"`\"proposed\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PUBLISHED","type":"`\"published\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"REJECTED","type":"`\"rejected\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"values","type":"Collection&#60;[ProductOptionValue](../../../product_models/classes/product_models.ProductOptionValue/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOptionValue](../../../product_models/classes/product_models.ProductOptionValue/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"sku","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"barcode","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ean","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"upLine truncated
### updateOption
Update a product option's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.updateOption(productId, optionId, {
title: "Size"
})
.then(({ product }) => {
console.log(product.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product that the option belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"optionId","type":"`string`","description":"The ID of the product option.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostProductsProductOptionsOption](../../../medusa/classes/medusa.AdminPostProductsProductOptionsOption/page.mdx)","description":"The attributes to update in the product option.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"title","type":"`string`","description":"The title of the Product Option","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateOption"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product's details. You can access the variant under the `options` property.","expandable":false,"children":[{"name":"AdminProductsRes","type":"[AdminProductsRes](../../../medusa/types/medusa.AdminProductsRes/page.mdx)","optional":false,"defaultValue":"","description":"The product's details.","expandable":false,"children":[{"name":"product","type":"[Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"Product details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"DRAFT","type":"`\"draft\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PROPOSED","type":"`\"proposed\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PUBLISHED","type":"`\"published\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"REJECTED","type":"`\"rejected\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"values","type":"Collection&#60;[ProductOptionValue](../../../product_models/classes/product_models.ProductOptionValue/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOptionValue](../../../product_models/classes/product_models.ProductOptionValue/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"sku","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"barcode","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ean","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"upLine truncated
### deleteOption
Delete a product option. If there are product variants that use this product option, they must be deleted before deleting the product option.
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product that the option belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"optionId","type":"`string`","description":"The ID of the product option.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteOption"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsDeleteOptionRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"AdminProductsDeleteOptionRes","type":"[AdminProductsDeleteOptionRes](../../../medusa/types/medusa.AdminProductsDeleteOptionRes/page.mdx)","optional":false,"defaultValue":"","description":"The details of deleting a product's option.","expandable":false,"children":[{"name":"option_id","type":"`string`","description":"The ID of the deleted Product Option","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`\"option\"`","description":"The type of the object that was deleted.","optional":false,"defaultValue":"option","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether or not the items were deleted.","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"product","type":"[Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"Product details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"DRAFT","type":"`\"draft\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PROPOSED","type":"`\"proposed\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PUBLISHED","type":"`\"published\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"REJECTED","type":"`\"rejected\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"values","type":"Collection&#60;[ProductOptionValue](../../../product_models/classes/product_models.ProductOptionValue/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product","type":"`null` \\| [Product](../../../product_models/classes/product_models.Product/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOptionValue](../../../product_models/classes/product_models.ProductOptionValue/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"nLine truncated
@@ -0,0 +1,270 @@
---
slug: /references/js-client/AdminPublishableApiKeyResource
---
import { TypeList } from "docs-ui"
# AdminPublishableApiKeyResource
This class is used to send requests to [Admin Publishable API Key API Routes](https://docs.medusajs.com/api/admin#publishable-api-keys). All its method
are available in the JS Client under the `medusa.admin.publishableApiKeys` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Publishable API Keys can be used to scope Store API calls with an API key, determining what resources are retrieved when querying the API.
For example, a publishable API key can be associated with one or more sales channels. When it is passed in the header of a request to the List Product store API Route,
the sales channels are inferred from the key and only products associated with those sales channels are retrieved.
Admins can manage publishable API keys and their associated resources. Currently, only Sales Channels are supported as a resource.
Related Guide: [How to manage publishable API keys](https://docs.medusajs.com/development/publishable-api-keys/admin/manage-publishable-api-keys).
## Methods
### retrieve
Retrieve a publishable API key's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.publishableApiKeys.retrieve(publishableApiKeyId)
.then(({ publishable_api_key }) => {
console.log(publishable_api_key.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the publishable API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPublishableApiKeysRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the publishable API key's details.","expandable":false,"children":[{"name":"AdminPublishableApiKeysRes","type":"[AdminPublishableApiKeysRes](../../../medusa/types/medusa.AdminPublishableApiKeysRes/page.mdx)","optional":false,"defaultValue":"","description":"The publishable API key's details.","expandable":false,"children":[{"name":"publishable_api_key","type":"`PublishableApiKey`","description":"Publishable API key details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of publishable API keys. The publishable API keys can be filtered by fields such as `q` passed in `query`. The publishable API keys can also be paginated.
#### Example
To list publishable API keys:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.publishableApiKeys.list()
.then(({ publishable_api_keys, count, limit, offset }) => {
console.log(publishable_api_keys)
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.publishableApiKeys.list({
limit,
offset
})
.then(({ publishable_api_keys, count, limit, offset }) => {
console.log(publishable_api_keys)
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[GetPublishableApiKeysParams](../../../medusa/classes/medusa.GetPublishableApiKeysParams/page.mdx)","description":"Filters and pagination configurations to apply on the retrieved publishable API keys.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Search term to search publishable API keys' titles.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"A field to sort-order the retrieved publishable API keys by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the publishable API keys' `created_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"updated_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the publishable API keys' `updated_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"revoked_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the publishable API keys' `revoked_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":true,"defaultValue":"20","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPublishableApiKeysListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of publishable API keys with pagination fields.","expandable":false,"children":[{"name":"AdminPublishableApiKeysListRes","type":"[AdminPublishableApiKeysListRes](../../../medusa/types/medusa.AdminPublishableApiKeysListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of publishable API keys with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"publishable_api_keys","type":"`PublishableApiKey`[]","description":"An array of publishable API keys details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### create
Create a publishable API key.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.publishableApiKeys.create({
title
})
.then(({ publishable_api_key }) => {
console.log(publishable_api_key.id)
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostPublishableApiKeysReq](../../../medusa/classes/medusa.AdminPostPublishableApiKeysReq/page.mdx)","description":"The publishable API key to be created.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"title","type":"`string`","description":"The title of the publishable API key","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPublishableApiKeysRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the publishbale API key's details.","expandable":false,"children":[{"name":"AdminPublishableApiKeysRes","type":"[AdminPublishableApiKeysRes](../../../medusa/types/medusa.AdminPublishableApiKeysRes/page.mdx)","optional":false,"defaultValue":"","description":"The publishable API key's details.","expandable":false,"children":[{"name":"publishable_api_key","type":"`PublishableApiKey`","description":"Publishable API key details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update a publishable API key's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.publishableApiKeys.update(publishableApiKeyId, {
title: "new title"
})
.then(({ publishable_api_key }) => {
console.log(publishable_api_key.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the publishable API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostPublishableApiKeysPublishableApiKeyReq](../../../medusa/classes/medusa.AdminPostPublishableApiKeysPublishableApiKeyReq/page.mdx)","description":"The attributes to update in the publishable API key.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"title","type":"`string`","description":"The title of the Publishable API Key.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPublishableApiKeysRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the publishbale API key's details.","expandable":false,"children":[{"name":"AdminPublishableApiKeysRes","type":"[AdminPublishableApiKeysRes](../../../medusa/types/medusa.AdminPublishableApiKeysRes/page.mdx)","optional":false,"defaultValue":"","description":"The publishable API key's details.","expandable":false,"children":[{"name":"publishable_api_key","type":"`PublishableApiKey`","description":"Publishable API key details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete a publishable API key. Associated resources, such as sales channels, are not deleted.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.publishableApiKeys.delete(publishableApiKeyId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the publishable API key","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the delete operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"[DeleteResponse](../../../medusa/interfaces/medusa.DeleteResponse/page.mdx)","optional":false,"defaultValue":"","description":"The response returned for a \n\n`DELETE`\n\n request.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the deleted item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the deleted item.","optional":false,"defaultValue":"product-collection","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether the item was deleted successfully.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### revoke
Revoke a publishable API key. Revoking the publishable API Key can't be undone, and the key can't be used in future requests.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.publishableApiKeys.revoke(publishableApiKeyId)
.then(({ publishable_api_key }) => {
console.log(publishable_api_key.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the publishable API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="revoke"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPublishableApiKeysRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the publishbale API key's details.","expandable":false,"children":[{"name":"AdminPublishableApiKeysRes","type":"[AdminPublishableApiKeysRes](../../../medusa/types/medusa.AdminPublishableApiKeysRes/page.mdx)","optional":false,"defaultValue":"","description":"The publishable API key's details.","expandable":false,"children":[{"name":"publishable_api_key","type":"`PublishableApiKey`","description":"Publishable API key details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="revoke"/>
### addSalesChannelsBatch
Add a list of sales channels to a publishable API key.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.publishableApiKeys.addSalesChannelsBatch(publishableApiKeyId, {
sales_channel_ids: [
{
id: channelId
}
]
})
.then(({ publishable_api_key }) => {
console.log(publishable_api_key.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the publishable API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostPublishableApiKeySalesChannelsBatchReq](../../../medusa/classes/medusa.AdminPostPublishableApiKeySalesChannelsBatchReq/page.mdx)","description":"The sales channels to add.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"sales_channel_ids","type":"[ProductBatchSalesChannel](../../../medusa/classes/medusa.ProductBatchSalesChannel/page.mdx)[]","description":"The IDs of the sales channels to add to the publishable API key","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the sales channel","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addSalesChannelsBatch"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPublishableApiKeysRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the publishbale API key's details.","expandable":false,"children":[{"name":"AdminPublishableApiKeysRes","type":"[AdminPublishableApiKeysRes](../../../medusa/types/medusa.AdminPublishableApiKeysRes/page.mdx)","optional":false,"defaultValue":"","description":"The publishable API key's details.","expandable":false,"children":[{"name":"publishable_api_key","type":"`PublishableApiKey`","description":"Publishable API key details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addSalesChannelsBatch"/>
### deleteSalesChannelsBatch
Remove a list of sales channels from a publishable API key. This doesn't delete the sales channels and only removes the association between them and the publishable API key.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.publishableApiKeys.deleteSalesChannelsBatch(publishableApiKeyId, {
sales_channel_ids: [
{
id: channelId
}
]
})
.then(({ publishable_api_key }) => {
console.log(publishable_api_key.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the publishable API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminDeletePublishableApiKeySalesChannelsBatchReq](../../../medusa/classes/medusa.AdminDeletePublishableApiKeySalesChannelsBatchReq/page.mdx)","description":"The sales channels to delete from the publishable API key.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"sales_channel_ids","type":"[ProductBatchSalesChannel](../../../medusa/classes/medusa.ProductBatchSalesChannel/page.mdx)[]","description":"The IDs of the sales channels to remove from the publishable API key","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the sales channel","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteSalesChannelsBatch"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPublishableApiKeysRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the publishbale API key's details.","expandable":false,"children":[{"name":"AdminPublishableApiKeysRes","type":"[AdminPublishableApiKeysRes](../../../medusa/types/medusa.AdminPublishableApiKeysRes/page.mdx)","optional":false,"defaultValue":"","description":"The publishable API key's details.","expandable":false,"children":[{"name":"publishable_api_key","type":"`PublishableApiKey`","description":"Publishable API key details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteSalesChannelsBatch"/>
### listSalesChannels
List the sales channels associated with a publishable API key. The sales channels can be filtered by fields such as `q` passed in the `query` parameter.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.publishableApiKeys.listSalesChannels()
.then(({ sales_channels }) => {
console.log(sales_channels.length)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the publishable API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[GetPublishableApiKeySalesChannelsParams](../../../medusa/classes/medusa.GetPublishableApiKeySalesChannelsParams/page.mdx)","description":"Filters to apply on the retrieved sales channels.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Search term to search sales channels' names and descriptions.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listSalesChannels"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPublishableApiKeysListSalesChannelsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of sales channels.","expandable":false,"children":[{"name":"AdminPublishableApiKeysListSalesChannelsRes","type":"[AdminPublishableApiKeysListSalesChannelsRes](../../../medusa/types/medusa.AdminPublishableApiKeysListSalesChannelsRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of sales channel.","expandable":false,"children":[{"name":"sales_channels","type":"[SalesChannel](../../../sales_channel_models/classes/sales_channel_models.SalesChannel/page.mdx)[]","description":"An array of sales channels details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"is_disabled","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`SalesChannelOptionalProps`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listSalesChannels"/>
@@ -0,0 +1,345 @@
---
slug: /references/js-client/AdminRegionsResource
---
import { TypeList } from "docs-ui"
# AdminRegionsResource
This class is used to send requests to [Admin Region API Routes](https://docs.medusajs.com/api/admin#regions). All its method
are available in the JS Client under the `medusa.admin.regions` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Regions are different countries or geographical regions that the commerce store serves customers in.
Admins can manage these regions, their providers, and more.
Related Guide: [How to manage regions](https://docs.medusajs.com/modules/regions-and-currencies/admin/manage-regions).
## Methods
### create
Create a region.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.create({
name: "Europe",
currency_code: "eur",
tax_rate: 0,
payment_providers: [
"manual"
],
fulfillment_providers: [
"manual"
],
countries: [
"DK"
]
})
.then(({ region }) => {
console.log(region.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostRegionsReq](../../../medusa/classes/medusa.AdminPostRegionsReq/page.mdx)","description":"The region to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"name","type":"`string`","description":"The name of the Region","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The 3 character ISO currency code to use in the Region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rate","type":"`number`","description":"The tax rate to use in the Region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payment_providers","type":"`string`[]","description":"A list of Payment Provider IDs that can be used in the Region","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillment_providers","type":"`string`[]","description":"A list of Fulfillment Provider IDs that can be used in the Region","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"countries","type":"`string`[]","description":"A list of countries' 2 ISO characters that should be included in the Region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_code","type":"`string`","description":"The tax code of the Region.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"includes_tax","type":"`boolean`","description":"Whether taxes are included in the prices of the region.","optional":true,"defaultValue":"","expandable":false,"featureFlag":"tax_inclusive_pricing","children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminRegionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the region's details.","expandable":false,"children":[{"name":"AdminRegionsRes","type":"[AdminRegionsRes](../../../medusa/types/medusa.AdminRegionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The region's details.","expandable":false,"children":[{"name":"region","type":"[Region](../../../region_models/classes/region_models.Region/page.mdx)","description":"Region details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"automatic_taxes","type":"`boolean`","description":"","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"countries","type":"Collection&#60;[Country](../../../region_models/classes/region_models.Country/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"iso_2","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"iso_3","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"num_code","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"null","expandable":false,"children":[]},{"name":"region","type":"`null` \\| [Region](../../../region_models/classes/region_models.Region/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`RegionOptionalProps`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update a region's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.update(regionId, {
name: "Europe"
})
.then(({ region }) => {
console.log(region.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The region's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostRegionsRegionReq](../../../medusa/classes/medusa.AdminPostRegionsRegionReq/page.mdx)","description":"The attributes to update in the region.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"name","type":"`string`","description":"The name of the Region","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"The 3 character ISO currency code to use in the Region.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_code","type":"`string`","description":"The tax code of the Region.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rate","type":"`number`","description":"The tax rate to use in the Region.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gift_cards_taxable","type":"`boolean`","description":"If set to `true`, taxes will be applied on gift cards.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"automatic_taxes","type":"`boolean`","description":"If set to `true`, the Medusa backend will automatically calculate taxes for carts in this region. If set to `false`, the taxes must be calculated manually.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_provider_id","type":"`null` \\| `string`","description":"The ID of the tax provider to use. If none provided, the system tax provider is used.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"payment_providers","type":"`string`[]","description":"A list of Payment Provider IDs that can be used in the Region","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillment_providers","type":"`string`[]","description":"A list of Fulfillment Provider IDs that can be used in the Region","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"countries","type":"`string`[]","description":"A list of countries' 2 ISO characters that should be included in the Region.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"includes_tax","type":"`boolean`","description":"Whether taxes are included in the prices of the region.","optional":true,"defaultValue":"","expandable":false,"featureFlag":"tax_inclusive_pricing","children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminRegionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the region's details.","expandable":false,"children":[{"name":"AdminRegionsRes","type":"[AdminRegionsRes](../../../medusa/types/medusa.AdminRegionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The region's details.","expandable":false,"children":[{"name":"region","type":"[Region](../../../region_models/classes/region_models.Region/page.mdx)","description":"Region details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"automatic_taxes","type":"`boolean`","description":"","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"countries","type":"Collection&#60;[Country](../../../region_models/classes/region_models.Country/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"iso_2","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"iso_3","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"num_code","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"null","expandable":false,"children":[]},{"name":"region","type":"`null` \\| [Region](../../../region_models/classes/region_models.Region/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`RegionOptionalProps`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete a region. Associated resources, such as providers or currencies are not deleted. Associated tax rates are deleted.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.delete(regionId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The region's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"[DeleteResponse](../../../medusa/interfaces/medusa.DeleteResponse/page.mdx)","optional":false,"defaultValue":"","description":"The response returned for a \n\n`DELETE`\n\n request.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the deleted item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the deleted item.","optional":false,"defaultValue":"product-collection","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether the item was deleted successfully.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### retrieve
Retrieve a region's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.retrieve(regionId)
.then(({ region }) => {
console.log(region.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The region's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetRegionsRegionParams](../../../medusa/classes/medusa.AdminGetRegionsRegionParams/page.mdx)","description":"Query params","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminRegionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the region's details.","expandable":false,"children":[{"name":"AdminRegionsRes","type":"[AdminRegionsRes](../../../medusa/types/medusa.AdminRegionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The region's details.","expandable":false,"children":[{"name":"region","type":"[Region](../../../region_models/classes/region_models.Region/page.mdx)","description":"Region details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"automatic_taxes","type":"`boolean`","description":"","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"countries","type":"Collection&#60;[Country](../../../region_models/classes/region_models.Country/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"iso_2","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"iso_3","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"num_code","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"null","expandable":false,"children":[]},{"name":"region","type":"`null` \\| [Region](../../../region_models/classes/region_models.Region/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`RegionOptionalProps`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of Regions. The regions can be filtered by fields such as `created_at` passed in the `query` parameter. The regions can also be paginated.
#### Example
To list regions:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.list()
.then(({ regions, limit, offset, count }) => {
console.log(regions.length);
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.list({
limit,
offset
})
.then(({ regions, limit, offset, count }) => {
console.log(regions.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetRegionsParams](../../../medusa/classes/medusa.AdminGetRegionsParams/page.mdx)","description":"Filters and pagination configurations to apply on the retrieved regions.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Search parameter for regions.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the regions' `created_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"updated_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the regions' `updated_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"deleted_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the regions' `deleted_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":true,"defaultValue":"20","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminRegionsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of regions with pagination fields.","expandable":false,"children":[{"name":"AdminRegionsListRes","type":"[AdminRegionsListRes](../../../medusa/types/medusa.AdminRegionsListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of regions with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"regions","type":"[Region](../../../region_models/classes/region_models.Region/page.mdx)[]","description":"An array of regions details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"automatic_taxes","type":"`boolean`","description":"","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"countries","type":"Collection&#60;[Country](../../../region_models/classes/region_models.Country/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"iso_2","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"iso_3","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"num_code","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"null","expandable":false,"children":[]},{"name":"region","type":"`null` \\| [Region](../../../region_models/classes/region_models.Region/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`RegionOptionalProps`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### addCountry
Add a country to the list of countries in a region.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.addCountry(regionId, {
country_code: "dk"
})
.then(({ region }) => {
console.log(region.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The region's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostRegionsRegionCountriesReq](../../../medusa/classes/medusa.AdminPostRegionsRegionCountriesReq/page.mdx)","description":"The country to add.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"country_code","type":"`string`","description":"The 2 character ISO code for the Country.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addCountry"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminRegionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the region's details.","expandable":false,"children":[{"name":"AdminRegionsRes","type":"[AdminRegionsRes](../../../medusa/types/medusa.AdminRegionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The region's details.","expandable":false,"children":[{"name":"region","type":"[Region](../../../region_models/classes/region_models.Region/page.mdx)","description":"Region details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"automatic_taxes","type":"`boolean`","description":"","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"countries","type":"Collection&#60;[Country](../../../region_models/classes/region_models.Country/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"iso_2","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"iso_3","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"num_code","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"null","expandable":false,"children":[]},{"name":"region","type":"`null` \\| [Region](../../../region_models/classes/region_models.Region/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`RegionOptionalProps`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addCountry"/>
### deleteCountry
Delete a country from the list of countries in a region. The country will still be available in the system, and it can be used in other regions.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.deleteCountry(regionId, "dk")
.then(({ region }) => {
console.log(region.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The region's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"The code of the country to delete from the region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteCountry"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminRegionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the region's details.","expandable":false,"children":[{"name":"AdminRegionsRes","type":"[AdminRegionsRes](../../../medusa/types/medusa.AdminRegionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The region's details.","expandable":false,"children":[{"name":"region","type":"[Region](../../../region_models/classes/region_models.Region/page.mdx)","description":"Region details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"automatic_taxes","type":"`boolean`","description":"","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"countries","type":"Collection&#60;[Country](../../../region_models/classes/region_models.Country/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"iso_2","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"iso_3","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"num_code","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"null","expandable":false,"children":[]},{"name":"region","type":"`null` \\| [Region](../../../region_models/classes/region_models.Region/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`RegionOptionalProps`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteCountry"/>
### addFulfillmentProvider
Add a fulfillment provider to the list of fulfullment providers in a region.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.addFulfillmentProvider(regionId, {
provider_id: "manual"
})
.then(({ region }) => {
console.log(region.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The region's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostRegionsRegionFulfillmentProvidersReq](../../../medusa/classes/medusa.AdminPostRegionsRegionFulfillmentProvidersReq/page.mdx)","description":"The fulfillment provider to add.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"provider_id","type":"`string`","description":"The ID of the Fulfillment Provider.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addFulfillmentProvider"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminRegionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the region's details.","expandable":false,"children":[{"name":"AdminRegionsRes","type":"[AdminRegionsRes](../../../medusa/types/medusa.AdminRegionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The region's details.","expandable":false,"children":[{"name":"region","type":"[Region](../../../region_models/classes/region_models.Region/page.mdx)","description":"Region details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"automatic_taxes","type":"`boolean`","description":"","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"countries","type":"Collection&#60;[Country](../../../region_models/classes/region_models.Country/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"iso_2","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"iso_3","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"num_code","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"null","expandable":false,"children":[]},{"name":"region","type":"`null` \\| [Region](../../../region_models/classes/region_models.Region/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`RegionOptionalProps`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addFulfillmentProvider"/>
### deleteFulfillmentProvider
Delete a fulfillment provider from a region. The fulfillment provider will still be available for usage in other regions.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.deleteFulfillmentProvider(regionId, "manual")
.then(({ region }) => {
console.log(region.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The region's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The ID of the fulfillment provider to delete from the region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteFulfillmentProvider"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminRegionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the region's details.","expandable":false,"children":[{"name":"AdminRegionsRes","type":"[AdminRegionsRes](../../../medusa/types/medusa.AdminRegionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The region's details.","expandable":false,"children":[{"name":"region","type":"[Region](../../../region_models/classes/region_models.Region/page.mdx)","description":"Region details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"automatic_taxes","type":"`boolean`","description":"","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"countries","type":"Collection&#60;[Country](../../../region_models/classes/region_models.Country/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"iso_2","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"iso_3","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"num_code","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"null","expandable":false,"children":[]},{"name":"region","type":"`null` \\| [Region](../../../region_models/classes/region_models.Region/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`RegionOptionalProps`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteFulfillmentProvider"/>
### retrieveFulfillmentOptions
Retrieve a list of fulfillment options available in a region.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.retrieveFulfillmentOptions(regionId)
.then(({ fulfillment_options }) => {
console.log(fulfillment_options.length);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The region's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieveFulfillmentOptions"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminGetRegionsRegionFulfillmentOptionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of fulfillment options.","expandable":false,"children":[{"name":"AdminGetRegionsRegionFulfillmentOptionsRes","type":"[AdminGetRegionsRegionFulfillmentOptionsRes](../../../medusa/classes/medusa.AdminGetRegionsRegionFulfillmentOptionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of fulfillment options in a region.","expandable":false,"children":[{"name":"constructor","type":"() => [AdminGetRegionsRegionFulfillmentOptionsRes](../../../medusa/classes/medusa.AdminGetRegionsRegionFulfillmentOptionsRes/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillment_options","type":"[FulfillmentOption](../../../medusa/classes/medusa.FulfillmentOption/page.mdx)[]","description":"Fulfillment providers details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"provider_id","type":"`string`","description":"ID of the fulfillment provider","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`unknown`[]","description":"fulfillment provider options","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieveFulfillmentOptions"/>
### addPaymentProvider
Add a payment provider to the list of payment providers in a region.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.addPaymentProvider(regionId, {
provider_id: "manual"
})
.then(({ region }) => {
console.log(region.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The region's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostRegionsRegionPaymentProvidersReq](../../../medusa/classes/medusa.AdminPostRegionsRegionPaymentProvidersReq/page.mdx)","description":"The payment provider to add.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"provider_id","type":"`string`","description":"The ID of the Payment Provider.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addPaymentProvider"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminRegionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the region's details.","expandable":false,"children":[{"name":"AdminRegionsRes","type":"[AdminRegionsRes](../../../medusa/types/medusa.AdminRegionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The region's details.","expandable":false,"children":[{"name":"region","type":"[Region](../../../region_models/classes/region_models.Region/page.mdx)","description":"Region details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"automatic_taxes","type":"`boolean`","description":"","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"countries","type":"Collection&#60;[Country](../../../region_models/classes/region_models.Country/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"iso_2","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"iso_3","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"num_code","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"null","expandable":false,"children":[]},{"name":"region","type":"`null` \\| [Region](../../../region_models/classes/region_models.Region/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`RegionOptionalProps`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addPaymentProvider"/>
### deletePaymentProvider
Delete a payment provider from a region. The payment provider will still be available for usage in other regions.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.deletePaymentProvider(regionId, "manual")
.then(({ region }) => {
console.log(region.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The region's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The ID of the payment provider to delete from the region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deletePaymentProvider"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminRegionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the region's details.","expandable":false,"children":[{"name":"AdminRegionsRes","type":"[AdminRegionsRes](../../../medusa/types/medusa.AdminRegionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The region's details.","expandable":false,"children":[{"name":"region","type":"[Region](../../../region_models/classes/region_models.Region/page.mdx)","description":"Region details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"automatic_taxes","type":"`boolean`","description":"","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"countries","type":"Collection&#60;[Country](../../../region_models/classes/region_models.Country/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"iso_2","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"iso_3","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"num_code","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"null","expandable":false,"children":[]},{"name":"region","type":"`null` \\| [Region](../../../region_models/classes/region_models.Region/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`RegionOptionalProps`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deletePaymentProvider"/>
@@ -0,0 +1,179 @@
---
slug: /references/js-client/AdminReservationsResource
---
import { TypeList } from "docs-ui"
# AdminReservationsResource
This class is used to send requests to [Admin Reservation API Routes](https://docs.medusajs.com/api/admin#reservations). To use these API Routes, make sure to install the
[@medusajs/inventory](https://docs.medusajs.com/modules/multiwarehouse/install-modules#inventory-module) module in your Medusa backend.
All methods in this class require [authentication](../../../modules/user/page.mdx). The methods
are available in the JS Client under the `medusa.admin.reservations` property.
Reservations, provided by the [Inventory Module](https://docs.medusajs.com/modules/multiwarehouse/inventory-module), are quantities of an item that are reserved, typically when an order is placed but not yet fulfilled.
Reservations can be associated with any resources, but commonly with line items of an order.
Related Guide: [How to manage item allocations in orders](https://docs.medusajs.com/modules/multiwarehouse/admin/manage-item-allocations-in-orders).
## Methods
### retrieve
Retrieve a reservation's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.reservations.retrieve(reservationId)
.then(({ reservation }) => {
console.log(reservation.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The reservation's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, unknown>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminReservationsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the reservation's details.","expandable":false,"children":[{"name":"AdminReservationsRes","type":"[AdminReservationsRes](../../../medusa/types/medusa.AdminReservationsRes/page.mdx)","optional":false,"defaultValue":"","description":"The reservation's details.","expandable":false,"children":[{"name":"reservation","type":"[ReservationItemDTO](../../../medusa/types/medusa.ReservationItemDTO/page.mdx)","description":"Reservation details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The id of the reservation item","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"location_id","type":"`string`","description":"The id of the location of the reservation","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"inventory_item_id","type":"`string`","description":"The id of the inventory item the reservation relates to","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"`number`","description":"The id of the reservation item","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>` \\| `null`","description":"An optional key-value map with additional details","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The date with timezone at which the resource was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The date with timezone at which the resource was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date` \\| `null`","description":"The date with timezone at which the resource was deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"line_item_id","type":"`string` \\| `null`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string` \\| `null`","description":"Description of the reservation item","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`string` \\| `null`","description":"UserId of user who created the reservation item","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of reservations. The reservations can be filtered by fields such as `location_id` or `quantity` passed in the `query` parameter. The reservations can also be paginated.
#### Example
To list reservations:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.reservations.list()
.then(({ reservations, count, limit, offset }) => {
console.log(reservations.length)
})
```
To specify relations that should be retrieved within the reservations:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.reservations.list({
expand: "location"
})
.then(({ reservations, count, limit, offset }) => {
console.log(reservations.length)
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.reservations.list({
expand: "location",
limit,
offset
})
.then(({ reservations, count, limit, offset }) => {
console.log(reservations.length)
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, unknown>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetReservationsParams](../../../medusa/classes/medusa.AdminGetReservationsParams/page.mdx)","description":"Filters and pagination parameters to apply on the retrieved reservations.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"location_id","type":"`string` \\| `string`[]","description":"Location IDs to filter reservations by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"inventory_item_id","type":"`string`[]","description":"Inventory item IDs to filter reservations by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"line_item_id","type":"`string`[]","description":"Line item IDs to filter reservations by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`string`[]","description":"\"Create by\" user IDs to filter reservations by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"[NumericalComparisonOperator](../../../medusa/classes/medusa.NumericalComparisonOperator/page.mdx)","description":"Numerical filters to apply on the reservations' `quantity` field.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`number`","description":"The filtered number must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`number`","description":"The filtered number must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`number`","description":"The filtered number must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`number`","description":"The filtered number must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the reservations' `created_at` field.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"updated_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the reservations' `updated_at` field.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"description","type":"`string` \\| [StringComparisonOperator](../../../medusa/classes/medusa.StringComparisonOperator/page.mdx)","description":"String filters to apply on the reservations' `description` field.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,Line truncated
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminReservationsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of reservations with pagination fields.","expandable":false,"children":[{"name":"AdminReservationsListRes","type":"[AdminReservationsListRes](../../../medusa/types/medusa.AdminReservationsListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of reservations with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reservations","type":"[ReservationItemDTO](../../../medusa/types/medusa.ReservationItemDTO/page.mdx)[]","description":"An array of reservations details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The id of the reservation item","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"location_id","type":"`string`","description":"The id of the location of the reservation","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"inventory_item_id","type":"`string`","description":"The id of the inventory item the reservation relates to","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"`number`","description":"The id of the reservation item","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>` \\| `null`","description":"An optional key-value map with additional details","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The date with timezone at which the resource was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The date with timezone at which the resource was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date` \\| `null`","description":"The date with timezone at which the resource was deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"line_item_id","type":"`string` \\| `null`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string` \\| `null`","description":"Description of the reservation item","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`string` \\| `null`","description":"UserId of user who created the reservation item","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### create
Create a reservation which can be associated with any resource, such as an order's line item.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.reservations.create({
line_item_id: "item_123",
location_id: "loc_123",
inventory_item_id: "iitem_123",
quantity: 1
})
.then(({ reservation }) => {
console.log(reservation.id);
});
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostReservationsReq](../../../medusa/classes/medusa.AdminPostReservationsReq/page.mdx)","description":"The reservation to be created.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"location_id","type":"`string`","description":"The ID of the location of the reservation.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"inventory_item_id","type":"`string`","description":"The ID of the inventory item the reservation is associated with.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"`number`","description":"The quantity to reserve.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"line_item_id","type":"`string`","description":"The ID of the line item of the reservation.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The reservation's description.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs with additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, unknown>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminReservationsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the reservation's details.","expandable":false,"children":[{"name":"AdminReservationsRes","type":"[AdminReservationsRes](../../../medusa/types/medusa.AdminReservationsRes/page.mdx)","optional":false,"defaultValue":"","description":"The reservation's details.","expandable":false,"children":[{"name":"reservation","type":"[ReservationItemDTO](../../../medusa/types/medusa.ReservationItemDTO/page.mdx)","description":"Reservation details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The id of the reservation item","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"location_id","type":"`string`","description":"The id of the location of the reservation","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"inventory_item_id","type":"`string`","description":"The id of the inventory item the reservation relates to","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"`number`","description":"The id of the reservation item","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>` \\| `null`","description":"An optional key-value map with additional details","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The date with timezone at which the resource was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The date with timezone at which the resource was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date` \\| `null`","description":"The date with timezone at which the resource was deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"line_item_id","type":"`string` \\| `null`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string` \\| `null`","description":"Description of the reservation item","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`string` \\| `null`","description":"UserId of user who created the reservation item","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update a reservation's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.reservations.update(reservationId, {
quantity: 3
})
.then(({ reservation }) => {
console.log(reservation.id);
});
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the reservation.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostReservationsReservationReq](../../../medusa/classes/medusa.AdminPostReservationsReservationReq/page.mdx)","description":"The attributes to update in the reservation.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"quantity","type":"`number`","description":"The quantity to reserve.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"location_id","type":"`string`","description":"The ID of the location associated with the reservation.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The reservation's description.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs with additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, unknown>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminReservationsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the reservation's details.","expandable":false,"children":[{"name":"AdminReservationsRes","type":"[AdminReservationsRes](../../../medusa/types/medusa.AdminReservationsRes/page.mdx)","optional":false,"defaultValue":"","description":"The reservation's details.","expandable":false,"children":[{"name":"reservation","type":"[ReservationItemDTO](../../../medusa/types/medusa.ReservationItemDTO/page.mdx)","description":"Reservation details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The id of the reservation item","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"location_id","type":"`string`","description":"The id of the location of the reservation","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"inventory_item_id","type":"`string`","description":"The id of the inventory item the reservation relates to","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"`number`","description":"The id of the reservation item","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>` \\| `null`","description":"An optional key-value map with additional details","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The date with timezone at which the resource was created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The date with timezone at which the resource was updated.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date` \\| `null`","description":"The date with timezone at which the resource was deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"line_item_id","type":"`string` \\| `null`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string` \\| `null`","description":"Description of the reservation item","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`string` \\| `null`","description":"UserId of user who created the reservation item","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete a reservation. Associated resources, such as the line item, will not be deleted.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.reservations.delete(reservationId)
.then(({ id, object, deleted }) => {
console.log(id);
});
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the reservation.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, unknown>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"[DeleteResponse](../../../medusa/interfaces/medusa.DeleteResponse/page.mdx)","optional":false,"defaultValue":"","description":"The response returned for a \n\n`DELETE`\n\n request.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the deleted item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the deleted item.","optional":false,"defaultValue":"product-collection","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether the item was deleted successfully.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
@@ -0,0 +1,144 @@
---
slug: /references/js-client/AdminReturnReasonsResource
---
import { TypeList } from "docs-ui"
# AdminReturnReasonsResource
This class is used to send requests to [Admin Return Reason API Routes](https://docs.medusajs.com/api/admin#return-reasons). All its method
are available in the JS Client under the `medusa.admin.returnReasons` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Return reasons are key-value pairs that are used to specify why an order return is being created.
Admins can manage available return reasons, and they can be used by both admins and customers when creating a return.
Related Guide: [How to manage return reasons](https://docs.medusajs.com/modules/orders/admin/manage-returns#manage-return-reasons).
## Methods
### create
Create a return reason.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.returnReasons.create({
label: "Damaged",
value: "damaged"
})
.then(({ return_reason }) => {
console.log(return_reason.id);
});
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostReturnReasonsReq](../../../medusa/classes/medusa.AdminPostReturnReasonsReq/page.mdx)","description":"The return reason to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string`","description":"A unique value of the return reason.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"label","type":"`string`","description":"The label to display to the Customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"parent_return_reason_id","type":"`string`","description":"The ID of the parent return reason.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The description of the Reason.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs with additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminReturnReasonsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the return reason's details.","expandable":false,"children":[{"name":"AdminReturnReasonsRes","type":"[AdminReturnReasonsRes](../../../medusa/types/medusa.AdminReturnReasonsRes/page.mdx)","optional":false,"defaultValue":"","description":"The return reason's details.","expandable":false,"children":[{"name":"return_reason","type":"`ReturnReason`","description":"The return reason's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update a return reason's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.returnReasons.update(returnReasonId, {
label: "Damaged"
})
.then(({ return_reason }) => {
console.log(return_reason.id);
});
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The return reason's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostReturnReasonsReasonReq](../../../medusa/classes/medusa.AdminPostReturnReasonsReasonReq/page.mdx)","description":"The attributes to update in the return reason.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"label","type":"`string`","description":"The label to display to the Customer.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string`","description":"A unique value of the return reason.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The description of the Reason.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs with additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminReturnReasonsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the return reason's details.","expandable":false,"children":[{"name":"AdminReturnReasonsRes","type":"[AdminReturnReasonsRes](../../../medusa/types/medusa.AdminReturnReasonsRes/page.mdx)","optional":false,"defaultValue":"","description":"The return reason's details.","expandable":false,"children":[{"name":"return_reason","type":"`ReturnReason`","description":"The return reason's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete a return reason.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.returnReasons.delete(returnReasonId)
.then(({ id, object, deleted }) => {
console.log(id);
});
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the return reason.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"[DeleteResponse](../../../medusa/interfaces/medusa.DeleteResponse/page.mdx)","optional":false,"defaultValue":"","description":"The response returned for a \n\n`DELETE`\n\n request.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the deleted item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the deleted item.","optional":false,"defaultValue":"product-collection","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether the item was deleted successfully.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### retrieve
Retrieve a return reason's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.returnReasons.retrieve(returnReasonId)
.then(({ return_reason }) => {
console.log(return_reason.id);
});
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The return reason's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminReturnReasonsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the return reason's details.","expandable":false,"children":[{"name":"AdminReturnReasonsRes","type":"[AdminReturnReasonsRes](../../../medusa/types/medusa.AdminReturnReasonsRes/page.mdx)","optional":false,"defaultValue":"","description":"The return reason's details.","expandable":false,"children":[{"name":"return_reason","type":"`ReturnReason`","description":"The return reason's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of return reasons.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.returnReasons.list()
.then(({ return_reasons }) => {
console.log(return_reasons.length);
});
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminReturnReasonsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of return reasons.","expandable":false,"children":[{"name":"AdminReturnReasonsListRes","type":"[AdminReturnReasonsListRes](../../../medusa/types/medusa.AdminReturnReasonsListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of return reasons.","expandable":false,"children":[{"name":"return_reasons","type":"`ReturnReason`[]","description":"The list of return reasons.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
@@ -0,0 +1,115 @@
---
slug: /references/js-client/AdminReturnsResource
---
import { TypeList } from "docs-ui"
# AdminReturnsResource
This class is used to send requests to [Admin Return API Routes](https://docs.medusajs.com/api/admin#returns). All its method
are available in the JS Client under the `medusa.admin.returns` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A return can be created by a customer or an admin to return items in an order.
Admins can manage these returns and change their state.
Related Guide: [How to manage returns](https://docs.medusajs.com/modules/orders/admin/manage-returns).
## Methods
### cancel
Register a return as canceled. The return can be associated with an order, claim, or swap.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.returns.cancel(returnId)
.then(({ order }) => {
console.log(order.id);
});
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The return's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancel"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminReturnsCancelRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the order associated with the return. If the return is associated with a claim or a swap, then it'll be the order\nthat the claim or swap belongs to.","expandable":false,"children":[{"name":"AdminReturnsCancelRes","type":"[AdminReturnsCancelRes](../../../medusa/types/medusa.AdminReturnsCancelRes/page.mdx)","optional":false,"defaultValue":"","description":"The associated order's details.","expandable":false,"children":[{"name":"order","type":"[Order](../../../types/types/types.Order/page.mdx)","description":"Order details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancel"/>
### receive
Mark a return as received. This also updates the status of associated order, claim, or swap accordingly.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.returns.receive(returnId, {
items: [
{
item_id,
quantity: 1
}
]
})
.then((data) => {
console.log(data.return.id);
});
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The return's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostReturnsReturnReceiveReq](../../../medusa/classes/medusa.AdminPostReturnsReturnReceiveReq/page.mdx)","description":"The received return.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"items","type":"[Item](../../../medusa/classes/medusa.Item-4/page.mdx)[]","description":"The Line Items that have been received.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"item_id","type":"`string`","description":"The ID of the Line Item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"`number`","description":"The quantity of the Line Item.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"refund","type":"`number`","description":"The amount to refund.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"location_id","type":"`string`","description":"The ID of the location to return items from.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="receive"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminReturnsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the return's details.","expandable":false,"children":[{"name":"AdminReturnsRes","type":"[AdminReturnsRes](../../../medusa/types/medusa.AdminReturnsRes/page.mdx)","optional":false,"defaultValue":"","description":"The return's details.","expandable":false,"children":[{"name":"return","type":"`Return`","description":"Return details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="receive"/>
### list
Retrieve a list of Returns. The returns can be paginated.
#### Example
To list returns:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.returns.list()
.then(({ returns, limit, offset, count }) => {
console.log(returns.length)
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.returns.list({
limit,
offset
})
.then(({ returns, limit, offset, count }) => {
console.log(returns.length)
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetReturnsParams](../../../medusa/classes/medusa.AdminGetReturnsParams/page.mdx)","description":"Paignation configurations to be applied on the retrieved returns.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":true,"defaultValue":"50","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminReturnsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of returns with pagination fields.","expandable":false,"children":[{"name":"AdminReturnsListRes","type":"[AdminReturnsListRes](../../../medusa/types/medusa.AdminReturnsListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of returns with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"returns","type":"`Return`[]","description":"An array of returns details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
@@ -0,0 +1,290 @@
---
slug: /references/js-client/AdminSalesChannelsResource
---
import { TypeList } from "docs-ui"
# AdminSalesChannelsResource
This class is used to send requests to [Admin Sales Channel API Routes](https://docs.medusajs.com/api/admin#sales-channels). All its method
are available in the JS Client under the `medusa.admin.salesChannels` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A sales channel indicates a channel where products can be sold in. For example, a webshop or a mobile app.
Admins can manage sales channels and the products available in them.
Related Guide: [How to manage sales channels](https://docs.medusajs.com/modules/sales-channels/admin/manage).
## Methods
### retrieve
Retrieve a sales channel's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.salesChannels.retrieve(salesChannelId)
.then(({ sales_channel }) => {
console.log(sales_channel.id)
})
```
#### Parameters
<TypeList types={[{"name":"salesChannelId","type":"`string`","description":"The sales channel's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminSalesChannelsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the sales channel's details.","expandable":false,"children":[{"name":"AdminSalesChannelsRes","type":"[AdminSalesChannelsRes](../../../medusa/types/medusa.AdminSalesChannelsRes/page.mdx)","optional":false,"defaultValue":"","description":"The sales channel's details.","expandable":false,"children":[{"name":"sales_channel","type":"[SalesChannel](../../../sales_channel_models/classes/sales_channel_models.SalesChannel/page.mdx)","description":"Sales Channel's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"is_disabled","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`SalesChannelOptionalProps`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### create
Create a sales channel.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.salesChannels.create({
name: "App",
description: "Mobile app"
})
.then(({ sales_channel }) => {
console.log(sales_channel.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostSalesChannelsReq](../../../medusa/classes/medusa.AdminPostSalesChannelsReq/page.mdx)","description":"The sales channel to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"name","type":"`string`","description":"The name of the Sales Channel","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The description of the Sales Channel","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_disabled","type":"`boolean`","description":"Whether the Sales Channel is disabled.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminSalesChannelsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the sales channel's details.","expandable":false,"children":[{"name":"AdminSalesChannelsRes","type":"[AdminSalesChannelsRes](../../../medusa/types/medusa.AdminSalesChannelsRes/page.mdx)","optional":false,"defaultValue":"","description":"The sales channel's details.","expandable":false,"children":[{"name":"sales_channel","type":"[SalesChannel](../../../sales_channel_models/classes/sales_channel_models.SalesChannel/page.mdx)","description":"Sales Channel's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"is_disabled","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`SalesChannelOptionalProps`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update a sales channel's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.salesChannels.update(salesChannelId, {
name: "App"
})
.then(({ sales_channel }) => {
console.log(sales_channel.id)
})
```
#### Parameters
<TypeList types={[{"name":"salesChannelId","type":"`string`","description":"The sales channel's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostSalesChannelsSalesChannelReq](../../../medusa/classes/medusa.AdminPostSalesChannelsSalesChannelReq/page.mdx)","description":"The attributes to update in the sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"name","type":"`string`","description":"The name of the sales channel","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"The description of the sales channel.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_disabled","type":"`boolean`","description":"Whether the Sales Channel is disabled.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminSalesChannelsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the sales channel's details.","expandable":false,"children":[{"name":"AdminSalesChannelsRes","type":"[AdminSalesChannelsRes](../../../medusa/types/medusa.AdminSalesChannelsRes/page.mdx)","optional":false,"defaultValue":"","description":"The sales channel's details.","expandable":false,"children":[{"name":"sales_channel","type":"[SalesChannel](../../../sales_channel_models/classes/sales_channel_models.SalesChannel/page.mdx)","description":"Sales Channel's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"is_disabled","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`SalesChannelOptionalProps`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### list
Retrieve a list of sales channels. The sales channels can be filtered by fields such as `q` or `name` passed in the `query` parameter. The sales channels can also be sorted or paginated.
#### Example
To list sales channels:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.salesChannels.list()
.then(({ sales_channels, limit, offset, count }) => {
console.log(sales_channels.length)
})
```
To specify relations that should be retrieved within the sales channels:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.salesChannels.list({
expand: "locations"
})
.then(({ sales_channels, limit, offset, count }) => {
console.log(sales_channels.length)
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.salesChannels.list({
expand: "locations",
limit,
offset
})
.then(({ sales_channels, limit, offset, count }) => {
console.log(sales_channels.length)
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetSalesChannelsParams](../../../medusa/classes/medusa.AdminGetSalesChannelsParams/page.mdx)","description":"Filters and pagination configurations applied on the retrieved sales channels.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"ID to filter sales channels by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"q","type":"`string`","description":"Search term to search sales channels' names and descriptions.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"Name to filter sales channels by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"Description to filter sales channels by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on sales channels' `created_at` field.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"updated_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on sales channels' `updated_at` field.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"deleted_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on sales channels' `deleted_at` field.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"Limit the number ofLine truncated
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminSalesChannelsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of sales channels with pagination fields.","expandable":false,"children":[{"name":"AdminSalesChannelsListRes","type":"[AdminSalesChannelsListRes](../../../medusa/types/medusa.AdminSalesChannelsListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of sales channels with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"sales_channels","type":"[SalesChannel](../../../sales_channel_models/classes/sales_channel_models.SalesChannel/page.mdx)[]","description":"An array of sales channels details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"is_disabled","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`SalesChannelOptionalProps`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### delete
Delete a sales channel. Associated products, stock locations, and other resources are not deleted.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.salesChannels.delete(salesChannelId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
#### Parameters
<TypeList types={[{"name":"salesChannelId","type":"`string`","description":"The sales channel's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"[DeleteResponse](../../../medusa/interfaces/medusa.DeleteResponse/page.mdx)","optional":false,"defaultValue":"","description":"The response returned for a \n\n`DELETE`\n\n request.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the deleted item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the deleted item.","optional":false,"defaultValue":"product-collection","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether the item was deleted successfully.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### removeProducts
Remove a list of products from a sales channel. This doesn't delete the product. It only removes the association between the product and the sales channel.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.salesChannels.removeProducts(salesChannelId, {
product_ids: [
{
id: productId
}
]
})
.then(({ sales_channel }) => {
console.log(sales_channel.id)
})
```
#### Parameters
<TypeList types={[{"name":"salesChannelId","type":"`string`","description":"The sales channel's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminDeleteSalesChannelsChannelProductsBatchReq](../../../medusa/classes/medusa.AdminDeleteSalesChannelsChannelProductsBatchReq/page.mdx)","description":"The products to remove from the sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"product_ids","type":"[ProductBatchSalesChannel](../../../medusa/classes/medusa.ProductBatchSalesChannel/page.mdx)[]","description":"The IDs of the products to remove from the sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the sales channel","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeProducts"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminSalesChannelsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the sales channel's details.","expandable":false,"children":[{"name":"AdminSalesChannelsRes","type":"[AdminSalesChannelsRes](../../../medusa/types/medusa.AdminSalesChannelsRes/page.mdx)","optional":false,"defaultValue":"","description":"The sales channel's details.","expandable":false,"children":[{"name":"sales_channel","type":"[SalesChannel](../../../sales_channel_models/classes/sales_channel_models.SalesChannel/page.mdx)","description":"Sales Channel's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"is_disabled","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`SalesChannelOptionalProps`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeProducts"/>
### addProducts
Add a list of products to a sales channel.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.salesChannels.addProducts(salesChannelId, {
product_ids: [
{
id: productId
}
]
})
.then(({ sales_channel }) => {
console.log(sales_channel.id)
})
```
#### Parameters
<TypeList types={[{"name":"salesChannelId","type":"`string`","description":"The sales channel's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostSalesChannelsChannelProductsBatchReq](../../../medusa/classes/medusa.AdminPostSalesChannelsChannelProductsBatchReq/page.mdx)","description":"The products to add to the sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"product_ids","type":"[ProductBatchSalesChannel](../../../medusa/classes/medusa.ProductBatchSalesChannel/page.mdx)[]","description":"The IDs of the products to add to the sales channel","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the sales channel","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addProducts"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminSalesChannelsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the sales channel's details.","expandable":false,"children":[{"name":"AdminSalesChannelsRes","type":"[AdminSalesChannelsRes](../../../medusa/types/medusa.AdminSalesChannelsRes/page.mdx)","optional":false,"defaultValue":"","description":"The sales channel's details.","expandable":false,"children":[{"name":"sales_channel","type":"[SalesChannel](../../../sales_channel_models/classes/sales_channel_models.SalesChannel/page.mdx)","description":"Sales Channel's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"is_disabled","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`SalesChannelOptionalProps`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addProducts"/>
### addLocation
Associate a stock location with a sales channel. It requires the
[@medusajs/stock-location](https://docs.medusajs.com/modules/multiwarehouse/install-modules#stock-location-module) module to be installed in
your Medusa backend.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.salesChannels.addLocation(salesChannelId, {
location_id: "loc_123"
})
.then(({ sales_channel }) => {
console.log(sales_channel.id)
})
```
#### Parameters
<TypeList types={[{"name":"salesChannelId","type":"`string`","description":"The sales channel's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostSalesChannelsChannelStockLocationsReq](../../../medusa/classes/medusa.AdminPostSalesChannelsChannelStockLocationsReq/page.mdx)","description":"The stock location to associate with the sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"location_id","type":"`string`","description":"The ID of the stock location","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addLocation"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminSalesChannelsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the sales channel's details.","expandable":false,"children":[{"name":"AdminSalesChannelsRes","type":"[AdminSalesChannelsRes](../../../medusa/types/medusa.AdminSalesChannelsRes/page.mdx)","optional":false,"defaultValue":"","description":"The sales channel's details.","expandable":false,"children":[{"name":"sales_channel","type":"[SalesChannel](../../../sales_channel_models/classes/sales_channel_models.SalesChannel/page.mdx)","description":"Sales Channel's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"is_disabled","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`SalesChannelOptionalProps`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addLocation"/>
### removeLocation
Remove a stock location from a sales channel. This only removes the association between the stock location and the sales channel. It does not delete the stock location.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.salesChannels.removeLocation(salesChannelId, {
location_id: "loc_id"
})
.then(({ sales_channel }) => {
console.log(sales_channel.id);
})
```
#### Parameters
<TypeList types={[{"name":"salesChannelId","type":"`string`","description":"The sales channel's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminDeleteSalesChannelsChannelStockLocationsReq](../../../medusa/classes/medusa.AdminDeleteSalesChannelsChannelStockLocationsReq/page.mdx)","description":"The stock location to remove from the sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"location_id","type":"`string`","description":"The ID of the stock location","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeLocation"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminSalesChannelsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the sales channel's details.","expandable":false,"children":[{"name":"AdminSalesChannelsRes","type":"[AdminSalesChannelsRes](../../../medusa/types/medusa.AdminSalesChannelsRes/page.mdx)","optional":false,"defaultValue":"","description":"The sales channel's details.","expandable":false,"children":[{"name":"sales_channel","type":"[SalesChannel](../../../sales_channel_models/classes/sales_channel_models.SalesChannel/page.mdx)","description":"Sales Channel's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"is_disabled","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`SalesChannelOptionalProps`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeLocation"/>
@@ -0,0 +1,155 @@
---
slug: /references/js-client/AdminShippingOptionsResource
---
import { TypeList } from "docs-ui"
# AdminShippingOptionsResource
This class is used to send requests to [Admin Shipping Option API Routes](https://docs.medusajs.com/api/admin#shipping-options). All its method
are available in the JS Client under the `medusa.admin.shippingOptions` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A shipping option is used to define the available shipping methods during checkout or when creating a return.
Admins can create an unlimited number of shipping options, each associated with a shipping profile and fulfillment provider, among other resources.
Related Guide: [Shipping Option architecture](https://docs.medusajs.com/modules/carts-and-checkout/shipping#shipping-option).
## Methods
### create
Create a shipping option.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingOptions.create({
name: "PostFake",
region_id,
provider_id,
data: {
},
price_type: "flat_rate"
})
.then(({ shipping_option }) => {
console.log(shipping_option.id)
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostShippingOptionsReq](../../../medusa/classes/medusa.AdminPostShippingOptionsReq/page.mdx)","description":"The shipping option to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"name","type":"`string`","description":"The name of the Shipping Option","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`string`","description":"The ID of the Region in which the Shipping Option will be available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The ID of the Fulfillment Provider that handles the Shipping Option.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`Record<string, unknown>`","description":"The data needed for the Fulfillment Provider to handle shipping with this Shipping Option.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"price_type","type":"[ShippingOptionPriceType](../../../medusa/types/medusa.ShippingOptionPriceType/page.mdx)","description":"The type of the Shipping Option price. `flat\\_rate` indicates fixed pricing, whereas `calculated` indicates that the price will be calculated each time by the fulfillment provider.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"profile_id","type":"`string`","description":"The ID of the Shipping Profile to add the Shipping Option to.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number`","description":"The amount to charge for the Shipping Option. If the `price\\_type` is set to `calculated`, this amount will not actually be used.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"requirements","type":"[OptionRequirement](../../../medusa/classes/medusa.OptionRequirement/page.mdx)[]","description":"The requirements that must be satisfied for the Shipping Option to be available.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"type","type":"`RequirementType`","description":"The type of the requirement","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number`","description":"The amount to compare with.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"admin_only","type":"`boolean`","description":"If set to `true`, the shipping option can only be used when creating draft orders.","optional":true,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_return","type":"`boolean`","description":"Whether the Shipping Option can be used for returns or during checkout.","optional":true,"defaultValue":"false","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs with additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"includes_tax","type":"`boolean`","description":"Tax included in prices of shipping option","optional":true,"defaultValue":"","expandable":false,"featureFlag":"tax_inclusive_pricing","children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminShippingOptionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the shipping option's details.","expandable":false,"children":[{"name":"AdminShippingOptionsRes","type":"[AdminShippingOptionsRes](../../../medusa/types/medusa.AdminShippingOptionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The shipping option's details.","expandable":false,"children":[{"name":"shipping_option","type":"[ShippingOption](../../../fulfillment_models/classes/fulfillment_models.ShippingOption/page.mdx)","description":"Shipping option details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"price_type","type":"[ShippingOptionPriceType](../../../utils/FulfillmentUtils/enums/utils.FulfillmentUtils.ShippingOptionPriceType/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"CALCULATED","type":"`\"calculated\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"FLAT","type":"`\"flat\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"service_zone_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_profile_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_option_type_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"data","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"service_zone","type":"[ServiceZone](../../../fulfillment_models/classes/fulfillment_models.ServiceZone/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"fulfillment_set_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillment_set","type":"[FulfillmentSet](../../../fulfillment_models/classes/fulfillment_models.FulfillmentSet/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"geo_zones","type":"Collection&#60;[GeoZone](../../../fulfillment_models/classes/fulfillment_models.GeoZone/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_options","type":"Collection&#60;[ShippingOption](../../../fulfillment_models/classes/fulfillment_models.ShippingOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"shipping_profile","type":"`null` \\| [ShippingProfile](../../../fulfillment_models/classes/fulfillment_models.ShippingProfile/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider","type":"`null` \\| [FulfillmentProvider](../../../fulfillment_models/classes/fulfillment_models.FulfillmentProvider/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ShippingOptionType](../../../fulfillment_models/classes/fulfillment_models.ShippingOptionType/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"chiLine truncated
### update
Update a shipping option's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingOptions.update(optionId, {
name: "PostFake",
requirements: [
{
id,
type: "max_subtotal",
amount: 1000
}
]
})
.then(({ shipping_option }) => {
console.log(shipping_option.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The shipping option's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostShippingOptionsOptionReq](../../../medusa/classes/medusa.AdminPostShippingOptionsOptionReq/page.mdx)","description":"The attributes to update in the shipping option.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"name","type":"`string`","description":"The name of the Shipping Option","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"requirements","type":"[OptionRequirement](../../../medusa/classes/medusa.OptionRequirement-1/page.mdx)[]","description":"The requirements that must be satisfied for the Shipping Option to be available.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of an existing requirement. If an ID is passed, the existing requirement's details are updated. Otherwise, a new requirement is created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`string`","description":"The type of the requirement","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number`","description":"The amount to compare with.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"amount","type":"`number`","description":"The amount to charge for the Shipping Option. If the `price\\_type` of the shipping option is `calculated`, this amount will not actually be used.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"price_type","type":"[ShippingOptionPriceType](../../../medusa/types/medusa.ShippingOptionPriceType/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"admin_only","type":"`boolean`","description":"If set to `true`, the shipping option can only be used when creating draft orders.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs with additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"includes_tax","type":"`boolean`","description":"Tax included in prices of shipping option","optional":true,"defaultValue":"","expandable":false,"featureFlag":"tax_inclusive_pricing","children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminShippingOptionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the shipping option's details.","expandable":false,"children":[{"name":"AdminShippingOptionsRes","type":"[AdminShippingOptionsRes](../../../medusa/types/medusa.AdminShippingOptionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The shipping option's details.","expandable":false,"children":[{"name":"shipping_option","type":"[ShippingOption](../../../fulfillment_models/classes/fulfillment_models.ShippingOption/page.mdx)","description":"Shipping option details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"price_type","type":"[ShippingOptionPriceType](../../../utils/FulfillmentUtils/enums/utils.FulfillmentUtils.ShippingOptionPriceType/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"CALCULATED","type":"`\"calculated\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"FLAT","type":"`\"flat\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"service_zone_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_profile_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_option_type_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"data","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"service_zone","type":"[ServiceZone](../../../fulfillment_models/classes/fulfillment_models.ServiceZone/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"fulfillment_set_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillment_set","type":"[FulfillmentSet](../../../fulfillment_models/classes/fulfillment_models.FulfillmentSet/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"geo_zones","type":"Collection&#60;[GeoZone](../../../fulfillment_models/classes/fulfillment_models.GeoZone/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_options","type":"Collection&#60;[ShippingOption](../../../fulfillment_models/classes/fulfillment_models.ShippingOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"shipping_profile","type":"`null` \\| [ShippingProfile](../../../fulfillment_models/classes/fulfillment_models.ShippingProfile/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider","type":"`null` \\| [FulfillmentProvider](../../../fulfillment_models/classes/fulfillment_models.FulfillmentProvider/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ShippingOptionType](../../../fulfillment_models/classes/fulfillment_models.ShippingOptionType/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"chiLine truncated
### delete
Delete a shipping option. Once deleted, it can't be used when creating orders or returns.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingOptions.delete(optionId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The shipping option's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"[DeleteResponse](../../../medusa/interfaces/medusa.DeleteResponse/page.mdx)","optional":false,"defaultValue":"","description":"The response returned for a \n\n`DELETE`\n\n request.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the deleted item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the deleted item.","optional":false,"defaultValue":"product-collection","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether the item was deleted successfully.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### retrieve
Retrieve a shipping option's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingOptions.retrieve(optionId)
.then(({ shipping_option }) => {
console.log(shipping_option.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The shipping option's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminShippingOptionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the shipping option's details.","expandable":false,"children":[{"name":"AdminShippingOptionsRes","type":"[AdminShippingOptionsRes](../../../medusa/types/medusa.AdminShippingOptionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The shipping option's details.","expandable":false,"children":[{"name":"shipping_option","type":"[ShippingOption](../../../fulfillment_models/classes/fulfillment_models.ShippingOption/page.mdx)","description":"Shipping option details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"price_type","type":"[ShippingOptionPriceType](../../../utils/FulfillmentUtils/enums/utils.FulfillmentUtils.ShippingOptionPriceType/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"CALCULATED","type":"`\"calculated\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"FLAT","type":"`\"flat\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"service_zone_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_profile_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_option_type_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"data","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"service_zone","type":"[ServiceZone](../../../fulfillment_models/classes/fulfillment_models.ServiceZone/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"fulfillment_set_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillment_set","type":"[FulfillmentSet](../../../fulfillment_models/classes/fulfillment_models.FulfillmentSet/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"geo_zones","type":"Collection&#60;[GeoZone](../../../fulfillment_models/classes/fulfillment_models.GeoZone/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_options","type":"Collection&#60;[ShippingOption](../../../fulfillment_models/classes/fulfillment_models.ShippingOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"shipping_profile","type":"`null` \\| [ShippingProfile](../../../fulfillment_models/classes/fulfillment_models.ShippingProfile/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider","type":"`null` \\| [FulfillmentProvider](../../../fulfillment_models/classes/fulfillment_models.FulfillmentProvider/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ShippingOptionType](../../../fulfillment_models/classes/fulfillment_models.ShippingOptionType/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"chiLine truncated
### list
Retrieve a list of shipping options. The shipping options can be filtered by fields such as `region_id` or `is_return` passed in the `query` parameter.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingOptions.list()
.then(({ shipping_options, count }) => {
console.log(shipping_options.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetShippingOptionsParams](../../../medusa/classes/medusa.AdminGetShippingOptionsParams/page.mdx)","description":"Filters to apply on the retrieved shipping options.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string` \\| `string`[]","description":"IDs to filter shipping options by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"Name to filter shipping options by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`string`","description":"Filter by a region ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_return","type":"`boolean`","description":"Filter by whether the shipping option is used for returns or orders.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"admin_only","type":"`boolean`","description":"Filter by whether the shipping options are available for admin users only.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"q","type":"`string`","description":"Filter shipping options by a search query.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on shipping options' `created_at` field.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"updated_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on shipping options' `updated_at` field.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"deleted_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on shipping options' `deleted_at` field.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned shipping options.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned shipping options.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","descripLine truncated
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminShippingOptionsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of shipping options.","expandable":false,"children":[{"name":"AdminShippingOptionsListRes","type":"[AdminShippingOptionsListRes](../../../medusa/types/medusa.AdminShippingOptionsListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of shipping options with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_options","type":"[ShippingOption](../../../fulfillment_models/classes/fulfillment_models.ShippingOption/page.mdx)[]","description":"An array of shipping options details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"price_type","type":"[ShippingOptionPriceType](../../../utils/FulfillmentUtils/enums/utils.FulfillmentUtils.ShippingOptionPriceType/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"CALCULATED","type":"`\"calculated\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"FLAT","type":"`\"flat\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"service_zone_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_profile_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_option_type_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"data","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"service_zone","type":"[ServiceZone](../../../fulfillment_models/classes/fulfillment_models.ServiceZone/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"fulfillment_set_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillment_set","type":"[FulfillmentSet](../../../fulfillment_models/classes/fulfillment_models.FulfillmentSet/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"geo_zones","type":"Collection&#60;[GeoZone](../../../fulfillment_models/classes/fulfillment_models.GeoZone/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_options","type":"Collection&#60;[ShippingOption](../../../fulfillment_models/classes/fulfillment_models.ShippingOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"shipping_profile","type":"`null` \\| [ShippingProfile](../../../fulfillment_modelsLine truncated
@@ -0,0 +1,145 @@
---
slug: /references/js-client/AdminShippingProfilesResource
---
import { TypeList } from "docs-ui"
# AdminShippingProfilesResource
This class is used to send requests to [Admin Shipping Profile API Routes](https://docs.medusajs.com/api/admin#shipping-profiles). All its method
are available in the JS Client under the `medusa.admin.shippingProfiles` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A shipping profile is used to group products that can be shipped in the same manner.
They are created by the admin and they're not associated with a fulfillment provider.
Related Guide: [Shipping Profile architecture](https://docs.medusajs.com/modules/carts-and-checkout/shipping#shipping-profile).
## Methods
### create
Create a shipping profile.
#### Example
```ts
import { ShippingProfileType } from "@medusajs/medusa"
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingProfiles.create({
name: "Large Products",
type: ShippingProfileType.DEFAULT
})
.then(({ shipping_profile }) => {
console.log(shipping_profile.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostShippingProfilesReq](../../../medusa/classes/medusa.AdminPostShippingProfilesReq/page.mdx)","description":"The shipping profile to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"name","type":"`string`","description":"The name of the Shipping Profile","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`ShippingProfileType`","description":"The type of the Shipping Profile","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs with additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminShippingProfilesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the shipping profile's details.","expandable":false,"children":[{"name":"AdminShippingProfilesRes","type":"[AdminShippingProfilesRes](../../../medusa/types/medusa.AdminShippingProfilesRes/page.mdx)","optional":false,"defaultValue":"","description":"The shipping profile's details.","expandable":false,"children":[{"name":"shipping_profile","type":"[ShippingProfile](../../../fulfillment_models/classes/fulfillment_models.ShippingProfile/page.mdx)","description":"Shipping profile details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_options","type":"Collection&#60;[ShippingOption](../../../fulfillment_models/classes/fulfillment_models.ShippingOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"price_type","type":"[ShippingOptionPriceType](../../../utils/FulfillmentUtils/enums/utils.FulfillmentUtils.ShippingOptionPriceType/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"service_zone_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_profile_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_option_type_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"data","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"service_zone","type":"[ServiceZone](../../../fulfillment_models/classes/fulfillment_models.ServiceZone/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_profile","type":"`null` \\| [ShippingProfile](../../../fulfillment_models/classes/fulfillment_models.ShippingProfile/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider","type":"`null` \\| [FulfillmentProvider](../../../fulfillment_models/classes/fulfillment_models.FulfillmentProvider/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ShippingOptionType](../../../fulfillment_models/classes/fulfillment_models.ShippingOptionType/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rules","type":"Collection&#60;[ShippingOptionRule](../../../fulfillment_models/classes/fulfillment_models.ShippingOptionRule/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillments","type":"Collection&#60;[Fulfillment](../../../fulfillment_models/classes/fulfillment_models.Fulfillment/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValueLine truncated
### update
Update a shipping profile's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingProfiles.update(shippingProfileId, {
name: 'Large Products'
})
.then(({ shipping_profile }) => {
console.log(shipping_profile.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The shipping profile's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostShippingProfilesProfileReq](../../../medusa/classes/medusa.AdminPostShippingProfilesProfileReq/page.mdx)","description":"The attributes to update in the shipping profile.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"name","type":"`string`","description":"The name of the Shipping Profile","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs with additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`ShippingProfileType`","description":"The type of the Shipping Profile","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"`string`[]","description":"product IDs to associate with the Shipping Profile","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_options","type":"`string`[]","description":"Shipping option IDs to associate with the Shipping Profile","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminShippingProfilesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the shipping profile's details.","expandable":false,"children":[{"name":"AdminShippingProfilesRes","type":"[AdminShippingProfilesRes](../../../medusa/types/medusa.AdminShippingProfilesRes/page.mdx)","optional":false,"defaultValue":"","description":"The shipping profile's details.","expandable":false,"children":[{"name":"shipping_profile","type":"[ShippingProfile](../../../fulfillment_models/classes/fulfillment_models.ShippingProfile/page.mdx)","description":"Shipping profile details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_options","type":"Collection&#60;[ShippingOption](../../../fulfillment_models/classes/fulfillment_models.ShippingOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"price_type","type":"[ShippingOptionPriceType](../../../utils/FulfillmentUtils/enums/utils.FulfillmentUtils.ShippingOptionPriceType/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"service_zone_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_profile_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_option_type_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"data","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"service_zone","type":"[ServiceZone](../../../fulfillment_models/classes/fulfillment_models.ServiceZone/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_profile","type":"`null` \\| [ShippingProfile](../../../fulfillment_models/classes/fulfillment_models.ShippingProfile/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider","type":"`null` \\| [FulfillmentProvider](../../../fulfillment_models/classes/fulfillment_models.FulfillmentProvider/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ShippingOptionType](../../../fulfillment_models/classes/fulfillment_models.ShippingOptionType/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rules","type":"Collection&#60;[ShippingOptionRule](../../../fulfillment_models/classes/fulfillment_models.ShippingOptionRule/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillments","type":"Collection&#60;[Fulfillment](../../../fulfillment_models/classes/fulfillment_models.Fulfillment/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValueLine truncated
### delete
Delete a shipping profile. Associated shipping options are deleted as well.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingProfiles.delete(profileId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The shipping profile's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"[DeleteResponse](../../../medusa/interfaces/medusa.DeleteResponse/page.mdx)","optional":false,"defaultValue":"","description":"The response returned for a \n\n`DELETE`\n\n request.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the deleted item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the deleted item.","optional":false,"defaultValue":"product-collection","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether the item was deleted successfully.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### retrieve
Retrieve a shipping profile's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingProfiles.retrieve(profileId)
.then(({ shipping_profile }) => {
console.log(shipping_profile.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The shipping profile's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminShippingProfilesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the shipping profile's details.","expandable":false,"children":[{"name":"AdminShippingProfilesRes","type":"[AdminShippingProfilesRes](../../../medusa/types/medusa.AdminShippingProfilesRes/page.mdx)","optional":false,"defaultValue":"","description":"The shipping profile's details.","expandable":false,"children":[{"name":"shipping_profile","type":"[ShippingProfile](../../../fulfillment_models/classes/fulfillment_models.ShippingProfile/page.mdx)","description":"Shipping profile details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_options","type":"Collection&#60;[ShippingOption](../../../fulfillment_models/classes/fulfillment_models.ShippingOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"price_type","type":"[ShippingOptionPriceType](../../../utils/FulfillmentUtils/enums/utils.FulfillmentUtils.ShippingOptionPriceType/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"service_zone_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_profile_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_option_type_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"data","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"service_zone","type":"[ServiceZone](../../../fulfillment_models/classes/fulfillment_models.ServiceZone/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_profile","type":"`null` \\| [ShippingProfile](../../../fulfillment_models/classes/fulfillment_models.ShippingProfile/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider","type":"`null` \\| [FulfillmentProvider](../../../fulfillment_models/classes/fulfillment_models.FulfillmentProvider/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ShippingOptionType](../../../fulfillment_models/classes/fulfillment_models.ShippingOptionType/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rules","type":"Collection&#60;[ShippingOptionRule](../../../fulfillment_models/classes/fulfillment_models.ShippingOptionRule/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillments","type":"Collection&#60;[Fulfillment](../../../fulfillment_models/classes/fulfillment_models.Fulfillment/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValueLine truncated
### list
Retrieve a list of shipping profiles.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingProfiles.list()
.then(({ shipping_profiles }) => {
console.log(shipping_profiles.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminShippingProfilesListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of shipping profiles.","expandable":false,"children":[{"name":"AdminShippingProfilesListRes","type":"[AdminShippingProfilesListRes](../../../medusa/types/medusa.AdminShippingProfilesListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of shipping profiles.","expandable":false,"children":[{"name":"shipping_profiles","type":"[ShippingProfile](../../../fulfillment_models/classes/fulfillment_models.ShippingProfile/page.mdx)[]","description":"An array of shipping profiles details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_options","type":"Collection&#60;[ShippingOption](../../../fulfillment_models/classes/fulfillment_models.ShippingOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"price_type","type":"[ShippingOptionPriceType](../../../utils/FulfillmentUtils/enums/utils.FulfillmentUtils.ShippingOptionPriceType/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"service_zone_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_profile_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_option_type_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"data","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"service_zone","type":"[ServiceZone](../../../fulfillment_models/classes/fulfillment_models.ServiceZone/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_profile","type":"`null` \\| [ShippingProfile](../../../fulfillment_models/classes/fulfillment_models.ShippingProfile/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider","type":"`null` \\| [FulfillmentProvider](../../../fulfillment_models/classes/fulfillment_models.FulfillmentProvider/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"[ShippingOptionType](../../../fulfillment_models/classes/fulfillment_models.ShippingOptionType/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rules","type":"Collection&#60;[ShippingOptionRule](../../../fulfillment_models/classes/fulfillment_models.ShippingOptionRule/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillments","type":"Collection&#60;[Fulfillment](../../../fulfillment_models/classes/fulfillment_models.Fulfillment/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"",Line truncated
@@ -0,0 +1,177 @@
---
slug: /references/js-client/AdminStockLocationsResource
---
import { TypeList } from "docs-ui"
# AdminStockLocationsResource
This class is used to send requests to [Admin Stock Location API Routes](https://docs.medusajs.com/api/admin#stock-locations). To use these API Routes, make sure to install the
[@medusajs/stock-location](https://docs.medusajs.com/modules/multiwarehouse/install-modules#stock-location-module) module in your Medusa backend.
All methods in this class require [authentication](../../../modules/user/page.mdx). The methods
are available in the JS Client under the `medusa.admin.stockLocations` property.
A stock location, provided by the [Stock Location module](https://docs.medusajs.com/modules/multiwarehouse/stock-location-module), indicates a physical address that stock-kept items, such as physical products, can be stored in.
An admin can create and manage available stock locations.
Related Guide: [How to manage stock locations](https://docs.medusajs.com/modules/multiwarehouse/admin/manage-stock-locations).
## Methods
### create
Create a stock location.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.stockLocations.create({
name: "Main Warehouse",
})
.then(({ stock_location }) => {
console.log(stock_location.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostStockLocationsReq](../../../medusa/classes/medusa.AdminPostStockLocationsReq/page.mdx)","description":"The stock location to be created.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"name","type":"`string`","description":"the name of the stock location","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address","type":"[StockLocationAddress](../../../medusa/classes/medusa.StockLocationAddress/page.mdx)","description":"A new stock location address to create and associate with the stock location. Only required if `address\\_id` is not provided.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"address_1","type":"`string`","description":"Stock location address","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"The two character ISO code for the country.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`string`","description":"Stock location address' complement","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`string`","description":"Stock location address' company","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`string`","description":"Stock location address' city","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`string`","description":"Stock location address' phone number","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`string`","description":"Stock location address' postal code","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`string`","description":"Stock location address' province","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"address_id","type":"`string`","description":"the ID of an existing stock location address to associate with the stock location. Only required if `address` is not provided.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional key-value map with additional details","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminStockLocationsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the stock location's details.","expandable":false,"children":[{"name":"AdminStockLocationsRes","type":"[AdminStockLocationsRes](../../../medusa/types/medusa.AdminStockLocationsRes/page.mdx)","optional":false,"defaultValue":"","description":"The stock location's details.","expandable":false,"children":[{"name":"stock_location","type":"[StockLocationExpandedDTO](../../../medusa/types/medusa.StockLocationExpandedDTO/page.mdx)","description":"Stock location details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the stock location.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the stock location.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>` \\| `null`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_id","type":"`string`","description":"The associated address's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillment_sets","type":"[FulfillmentSetDTO](../../../medusa/interfaces/medusa.FulfillmentSetDTO/page.mdx)[]","description":"Fulfillment sets for the location","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`string`","description":"The type of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"service_zones","type":"[ServiceZoneDTO](../../../medusa/interfaces/medusa.ServiceZoneDTO/page.mdx)[]","description":"The service zones associated with the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The creation date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The update date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The deletion date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"created_at","type":"`string` \\| `Date`","description":"The creation date of the stock location.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The update date of the stock location.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date` \\| `null`","description":"The deletion date of the stock location.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address","type":"[StockLocationAddressDTO](../../../medusa/types/medusa.StockLocationAddressDTO/page.mdx)","description":"The address of the stock location.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"address_1","type":"`string`","description":"The address 1 of the stock location address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"The country code of the stock location address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The creation date of the stock location address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The update date of the stock location address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date` \\| `null`","description":"The deletion date of the stock location address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"The ID of the stock location address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`string` \\| `null`","description":"The address 2 of the stock location address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`string` Line truncated
### retrieve
Retrieve a stock location's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.stockLocations.retrieve(stockLocationId)
.then(({ stock_location }) => {
console.log(stock_location.id);
})
```
#### Parameters
<TypeList types={[{"name":"itemId","type":"`string`","description":"The stock location's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminStockLocationsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the stock location's details.","expandable":false,"children":[{"name":"AdminStockLocationsRes","type":"[AdminStockLocationsRes](../../../medusa/types/medusa.AdminStockLocationsRes/page.mdx)","optional":false,"defaultValue":"","description":"The stock location's details.","expandable":false,"children":[{"name":"stock_location","type":"[StockLocationExpandedDTO](../../../medusa/types/medusa.StockLocationExpandedDTO/page.mdx)","description":"Stock location details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the stock location.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the stock location.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>` \\| `null`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_id","type":"`string`","description":"The associated address's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillment_sets","type":"[FulfillmentSetDTO](../../../medusa/interfaces/medusa.FulfillmentSetDTO/page.mdx)[]","description":"Fulfillment sets for the location","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`string`","description":"The type of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"service_zones","type":"[ServiceZoneDTO](../../../medusa/interfaces/medusa.ServiceZoneDTO/page.mdx)[]","description":"The service zones associated with the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The creation date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The update date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The deletion date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"created_at","type":"`string` \\| `Date`","description":"The creation date of the stock location.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The update date of the stock location.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date` \\| `null`","description":"The deletion date of the stock location.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address","type":"[StockLocationAddressDTO](../../../medusa/types/medusa.StockLocationAddressDTO/page.mdx)","description":"The address of the stock location.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"address_1","type":"`string`","description":"The address 1 of the stock location address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"The country code of the stock location address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The creation date of the stock location address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The update date of the stock location address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date` \\| `null`","description":"The deletion date of the stock location address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"The ID of the stock location address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`string` \\| `null`","description":"The address 2 of the stock location address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`string` Line truncated
### update
Update a stock location's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.stockLocations.update(stockLocationId, {
name: 'Main Warehouse'
})
.then(({ stock_location }) => {
console.log(stock_location.id);
})
```
#### Parameters
<TypeList types={[{"name":"stockLocationId","type":"`string`","description":"The stock location's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostStockLocationsLocationReq](../../../medusa/classes/medusa.AdminPostStockLocationsLocationReq/page.mdx)","description":"The attributes to be updated in the stock location.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"name","type":"`string`","description":"the name of the stock location","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address","type":"[StockLocationAddress](../../../medusa/classes/medusa.StockLocationAddress-1/page.mdx)","description":"The data of an associated address to create or update.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"address_1","type":"`string`","description":"First line address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"Country code.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`string`","description":"Second line address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`string`","description":"Company.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"city","type":"`string`","description":"City.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`string`","description":"Phone.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"postal_code","type":"`string`","description":"Postal code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"province","type":"`string`","description":"Province.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"address_id","type":"`string`","description":"the stock location address ID","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional key-value map with additional details","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminStockLocationsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the stock location's details.","expandable":false,"children":[{"name":"AdminStockLocationsRes","type":"[AdminStockLocationsRes](../../../medusa/types/medusa.AdminStockLocationsRes/page.mdx)","optional":false,"defaultValue":"","description":"The stock location's details.","expandable":false,"children":[{"name":"stock_location","type":"[StockLocationExpandedDTO](../../../medusa/types/medusa.StockLocationExpandedDTO/page.mdx)","description":"Stock location details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the stock location.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the stock location.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>` \\| `null`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_id","type":"`string`","description":"The associated address's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillment_sets","type":"[FulfillmentSetDTO](../../../medusa/interfaces/medusa.FulfillmentSetDTO/page.mdx)[]","description":"Fulfillment sets for the location","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`string`","description":"The type of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"service_zones","type":"[ServiceZoneDTO](../../../medusa/interfaces/medusa.ServiceZoneDTO/page.mdx)[]","description":"The service zones associated with the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The creation date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The update date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The deletion date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"created_at","type":"`string` \\| `Date`","description":"The creation date of the stock location.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The update date of the stock location.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date` \\| `null`","description":"The deletion date of the stock location.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address","type":"[StockLocationAddressDTO](../../../medusa/types/medusa.StockLocationAddressDTO/page.mdx)","description":"The address of the stock location.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"address_1","type":"`string`","description":"The address 1 of the stock location address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"The country code of the stock location address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`string` \\| `Date`","description":"The creation date of the stock location address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`string` \\| `Date`","description":"The update date of the stock location address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`string` \\| `Date` \\| `null`","description":"The deletion date of the stock location address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"The ID of the stock location address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_2","type":"`string` \\| `null`","description":"The address 2 of the stock location address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`string` Line truncated
### delete
Delete a stock location.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.stockLocations.delete(stockLocationId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The stock location's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminStockLocationsDeleteRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"AdminStockLocationsDeleteRes","type":"[AdminStockLocationsDeleteRes](../../../medusa/types/medusa.AdminStockLocationsDeleteRes/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the item that was deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"T","description":"The type of the item that was deleted.","optional":false,"defaultValue":"stock_location","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether the item was deleted successfully.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### list
Retrieve a list of stock locations. The stock locations can be filtered by fields such as `name` or `created_at` passed in the `query` parameter.
The stock locations can also be sorted or paginated.
#### Example
To list stock locations:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.stockLocations.list()
.then(({ stock_locations, limit, offset, count }) => {
console.log(stock_locations.length);
})
```
To specify relations that should be retrieved within the stock locations:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.stockLocations.list({
expand: "address"
})
.then(({ stock_locations, limit, offset, count }) => {
console.log(stock_locations.length);
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.stockLocations.list({
expand: "address",
limit,
offset
})
.then(({ stock_locations, limit, offset, count }) => {
console.log(stock_locations.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetStockLocationsParams](../../../medusa/classes/medusa.AdminGetStockLocationsParams/page.mdx)","description":"Filters and pagination configurations to apply on the retrieved stock locations.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Search term to search stock location names.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"IDs to filter stock locations by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string` \\| `string`[]","description":"Names to filter stock locations by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"address_id","type":"`string` \\| `string`[]","description":"Filter stock locations by the ID of their associated addresses.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"sales_channel_id","type":"`string` \\| `string`[]","description":"Filter stock locations by the ID of their associated sales channels.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":true,"defaultValue":"20","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminStockLocationsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of stock locations with pagination fields.","expandable":false,"children":[{"name":"AdminStockLocationsListRes","type":"[AdminStockLocationsListRes](../../../medusa/types/medusa.AdminStockLocationsListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of stock locations with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The limit applied on the retrieved items.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before retrieving the list of items.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total count of items.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"stock_locations","type":"[StockLocationExpandedDTO](../../../medusa/types/medusa.StockLocationExpandedDTO/page.mdx)[]","description":"The list of stock locations.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"sales_channels","type":"`any`[]","description":"The list of sales channels.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
@@ -0,0 +1,164 @@
---
slug: /references/js-client/AdminStoresResource
---
import { TypeList } from "docs-ui"
# AdminStoresResource
This class is used to send requests to [Admin Store API Routes](https://docs.medusajs.com/api/admin#store). All its method
are available in the JS Client under the `medusa.admin.store` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A store indicates the general configurations and details about the commerce store. By default, there's only one store in the Medusa backend.
Admins can manage the store and its details or configurations.
## Methods
### update
Update the store's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.store.update({
name: "Medusa Store"
})
.then(({ store }) => {
console.log(store.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostStoreReq](../../../medusa/classes/medusa.AdminPostStoreReq/page.mdx)","description":"The attributes to update in the store.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"name","type":"`string`","description":"The name of the Store","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"swap_link_template","type":"`string`","description":"A template for Swap links - use `&#123;&#123;cart\\_id&#125;&#125;` to insert the Swap Cart ID","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"payment_link_template","type":"`string`","description":"A template for payment links - use `&#123;&#123;cart\\_id&#125;&#125;` to insert the Cart ID","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"invite_link_template","type":"`string`","description":"A template for invite links - use `&#123;&#123;invite\\_token&#125;&#125;` to insert the invite token","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"default_currency_code","type":"`string`","description":"The default currency code of the Store.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"currencies","type":"`string`[]","description":"Array of available currencies in the store. Each currency is in 3 character ISO code format.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional set of key-value pairs with additional information.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminStoresRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the store's details.","expandable":false,"children":[{"name":"AdminStoresRes","type":"[AdminStoresRes](../../../medusa/types/medusa.AdminStoresRes/page.mdx)","optional":false,"defaultValue":"","description":"The store's details.","expandable":false,"children":[{"name":"store","type":"[Store](../../../store_models/classes/store_models.Store/page.mdx)","description":"Store details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"supported_currency_codes","type":"`string`[]","description":"","optional":false,"defaultValue":"[]","expandable":false,"children":[]},{"name":"default_currency_code","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"default_sales_channel_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"default_region_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"default_location_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### addCurrency
Add a currency code to the available currencies in a store. This doesn't create new currencies, as currencies are defined within the Medusa backend.
To create a currency, you can [create a migration](https://docs.medusajs.com/development/entities/migrations/create) that inserts the currency into the database.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.store.addCurrency("eur")
.then(({ store }) => {
console.log(store.currencies);
})
```
#### Parameters
<TypeList types={[{"name":"currency_code","type":"`string`","description":"The code of the currency to add to the store.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addCurrency"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminStoresRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the store's details.","expandable":false,"children":[{"name":"AdminStoresRes","type":"[AdminStoresRes](../../../medusa/types/medusa.AdminStoresRes/page.mdx)","optional":false,"defaultValue":"","description":"The store's details.","expandable":false,"children":[{"name":"store","type":"[Store](../../../store_models/classes/store_models.Store/page.mdx)","description":"Store details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"supported_currency_codes","type":"`string`[]","description":"","optional":false,"defaultValue":"[]","expandable":false,"children":[]},{"name":"default_currency_code","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"default_sales_channel_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"default_region_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"default_location_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addCurrency"/>
### deleteCurrency
Delete a currency code from the available currencies in a store. This doesn't completely delete the currency and it can be added again later to the store.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.store.deleteCurrency("eur")
.then(({ store }) => {
console.log(store.currencies);
})
```
#### Parameters
<TypeList types={[{"name":"currency_code","type":"`string`","description":"The code of the currency to delete from the store.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteCurrency"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminStoresRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the store's details.","expandable":false,"children":[{"name":"AdminStoresRes","type":"[AdminStoresRes](../../../medusa/types/medusa.AdminStoresRes/page.mdx)","optional":false,"defaultValue":"","description":"The store's details.","expandable":false,"children":[{"name":"store","type":"[Store](../../../store_models/classes/store_models.Store/page.mdx)","description":"Store details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"supported_currency_codes","type":"`string`[]","description":"","optional":false,"defaultValue":"[]","expandable":false,"children":[]},{"name":"default_currency_code","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"default_sales_channel_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"default_region_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"default_location_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteCurrency"/>
### retrieve
Retrieve the store's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.store.retrieve()
.then(({ store }) => {
console.log(store.id);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminExtendedStoresRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the store's details.","expandable":false,"children":[{"name":"AdminExtendedStoresRes","type":"[AdminExtendedStoresRes](../../../medusa/types/medusa.AdminExtendedStoresRes/page.mdx)","optional":false,"defaultValue":"","description":"The store's details with additional details like payment and tax providers.","expandable":false,"children":[{"name":"store","type":"[ExtendedStoreDTO](../../../medusa/types/medusa.ExtendedStoreDTO/page.mdx)","description":"Store details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"supported_currency_codes","type":"`string`[]","description":"","optional":false,"defaultValue":"[]","expandable":false,"children":[]},{"name":"default_currency_code","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"default_sales_channel_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"default_region_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"default_location_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"payment_providers","type":"[PaymentProvider](../../../payment_models/classes/payment_models.PaymentProvider/page.mdx)[]","description":"The store's payment providers.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_enabled","type":"`boolean`","description":"","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`\"is_enabled\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"fulfillment_providers","type":"[FulfillmentProvider](../../../fulfillment_models/classes/fulfillment_models.FulfillmentProvider/page.mdx)[]","description":"The store's fulfillment providers.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_enabled","type":"`boolean`","description":"","optional":false,"defaultValue":"true","expandable":false,"children":[]}]},{"name":"feature_flags","type":"[FeatureFlagsResponse](../../../medusa/types/medusa.FeatureFlagsResponse/page.mdx)","description":"The feature flags enabled in the store's backend.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"key","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`boolean` \\| `Record<string, boolean>`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"modules","type":"[ModulesResponse](../../../medusa/types/medusa.ModulesResponse/page.mdx)","description":"The modules installed in the store's backend.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"module","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"resolution","type":"`string` \\| `false`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### listPaymentProviders
Retrieve a list of available payment providers in a store.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.store.listPaymentProviders()
.then(({ payment_providers }) => {
console.log(payment_providers.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listPaymentProviders"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPaymentProvidersList&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of payment providers.","expandable":false,"children":[{"name":"AdminPaymentProvidersList","type":"[AdminPaymentProvidersList](../../../medusa/types/medusa.AdminPaymentProvidersList/page.mdx)","optional":false,"defaultValue":"","description":"The list of payment providers in a store.","expandable":false,"children":[{"name":"payment_providers","type":"[PaymentProvider](../../../payment_models/classes/payment_models.PaymentProvider/page.mdx)[]","description":"An array of payment providers details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_enabled","type":"`boolean`","description":"","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`\"is_enabled\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listPaymentProviders"/>
### listTaxProviders
Retrieve a list of available tax providers in a store.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.store.listTaxProviders()
.then(({ tax_providers }) => {
console.log(tax_providers.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listTaxProviders"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminTaxProvidersList&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of tax providers.","expandable":false,"children":[{"name":"AdminTaxProvidersList","type":"[AdminTaxProvidersList](../../../medusa/types/medusa.AdminTaxProvidersList/page.mdx)","optional":false,"defaultValue":"","description":"The list of tax providers in a store.","expandable":false,"children":[{"name":"tax_providers","type":"[TaxProvider](../../../tax_models/classes/tax_models.TaxProvider/page.mdx)[]","description":"An array of tax providers details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_enabled","type":"`boolean`","description":"","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`\"is_enabled\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listTaxProviders"/>
@@ -0,0 +1,84 @@
---
slug: /references/js-client/AdminSwapsResource
---
import { TypeList } from "docs-ui"
# AdminSwapsResource
This class is used to send requests to [Admin Swap API Routes](https://docs.medusajs.com/api/admin#swaps). All its method
are available in the JS Client under the `medusa.admin.swaps` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A swap is created by a customer or an admin to exchange an item with a new one.
Creating a swap implicitely includes creating a return for the item being exchanged.
Related Guide: [How to manage swaps](https://docs.medusajs.com/modules/orders/admin/manage-swaps)
## Methods
### retrieve
Retrieve a swap's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.swaps.retrieve(swapId)
.then(({ swap }) => {
console.log(swap.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The swap's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminSwapsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the swap's details.","expandable":false,"children":[{"name":"AdminSwapsRes","type":"[AdminSwapsRes](../../../medusa/types/medusa.AdminSwapsRes/page.mdx)","optional":false,"defaultValue":"","description":"The swap's details.","expandable":false,"children":[{"name":"swap","type":"`Swap`","description":"Swap details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of swaps. The swaps can be paginated.
#### Example
To list swaps:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.swaps.list()
.then(({ swaps }) => {
console.log(swaps.length);
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.swaps.list({
limit,
offset
})
.then(({ swaps }) => {
console.log(swaps.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetSwapsParams](../../../medusa/classes/medusa.AdminGetSwapsParams/page.mdx)","description":"Pagination configurations to apply on the retrieved swaps.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":true,"defaultValue":"50","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminSwapsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of swaps with pagination fields.","expandable":false,"children":[{"name":"AdminSwapsListRes","type":"[AdminSwapsListRes](../../../medusa/types/medusa.AdminSwapsListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of swaps with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"swaps","type":"`Swap`[]","description":"An array of swaps details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
@@ -0,0 +1,360 @@
---
slug: /references/js-client/AdminTaxRatesResource
---
import { TypeList } from "docs-ui"
# AdminTaxRatesResource
This class is used to send requests to [Admin Tax Rate API Routes](https://docs.medusajs.com/api/admin#tax-rates). All its method
are available in the JS Client under the `medusa.admin.taxRates` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Each region has at least a default tax rate. Admins can create and manage additional tax rates that can be applied for certain conditions, such as for specific product types.
Related Guide: [How to manage tax rates](https://docs.medusajs.com/modules/taxes/admin/manage-tax-rates).
## Methods
### retrieve
Retrieve a tax rate's details.
#### Example
A simple example that retrieves a tax rate by its ID:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.retrieve(taxRateId)
.then(({ tax_rate }) => {
console.log(tax_rate.id);
})
```
To specify relations that should be retrieved:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.retrieve(taxRateId, {
expand: "shipping_options"
})
.then(({ tax_rate }) => {
console.log(tax_rate.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The tax rate's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetTaxRatesTaxRateParams](../../../medusa/classes/medusa.AdminGetTaxRatesTaxRateParams/page.mdx)","description":"Configurations to apply on retrieved tax rates.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`[]","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`[]","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminTaxRatesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the tax rate's details.","expandable":false,"children":[{"name":"AdminTaxRatesRes","type":"[AdminTaxRatesRes](../../../medusa/types/medusa.AdminTaxRatesRes/page.mdx)","optional":false,"defaultValue":"","description":"The tax rate's details.","expandable":false,"children":[{"name":"tax_rate","type":"[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx)","description":"Tax rate details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rate","type":"`null` \\| `number`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"code","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_combinable","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"tax_region_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_region","type":"[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"provider","type":"[TaxProvider](../../../tax_models/classes/tax_models.TaxProvider/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"province_code","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"parent_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"parent","type":"[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rates","type":"Collection&#60;[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"children","type":"Collection&#60;[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"rules","type":"Collection&#60;[TaxRateRule](../../../tax_models/classes/tax_models.TaxRateRule/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rate_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reference_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reference","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rate","type":"[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \Line truncated
### list
Retrieve a list of tax rates. The tax rates can be filtered by fields such as `name` or `rate` passed in the `query` parameter. The tax rates can also be paginated.
#### Example
To list tax rates:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.list()
.then(({ tax_rates, limit, offset, count }) => {
console.log(tax_rates.length);
})
```
To specify relations that should be retrieved within the tax rates:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.list({
expand: ["shipping_options"]
})
.then(({ tax_rates, limit, offset, count }) => {
console.log(tax_rates.length);
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.list({
expand: ["shipping_options"],
limit,
offset
})
.then(({ tax_rates, limit, offset, count }) => {
console.log(tax_rates.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetTaxRatesParams](../../../medusa/classes/medusa.AdminGetTaxRatesParams/page.mdx)","description":"Filters and pagination configurations applied to the retrieved tax rates.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"region_id","type":"`string` \\| `string`[]","description":"Filter tax rates by the IDs of their associates region.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"Name to filter tax rates by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string`","description":"Code to filter tax rates by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rate","type":"`number` \\| [NumericalComparisonOperator](../../../medusa/classes/medusa.NumericalComparisonOperator/page.mdx)","description":"Number filters to filter tax rates' `rate` field.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":true,"defaultValue":"50","expandable":false,"children":[]},{"name":"expand","type":"`string`[]","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`[]","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the tax rates' `update_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the customer tax rates' `created_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"deleted_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the tax rates' `deleted_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","Line truncated
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminTaxRatesListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of tax rates with pagination fields.","expandable":false,"children":[{"name":"AdminTaxRatesListRes","type":"[AdminTaxRatesListRes](../../../medusa/types/medusa.AdminTaxRatesListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of tax rates with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rates","type":"[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx)[]","description":"An array of tax rate details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rate","type":"`null` \\| `number`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"code","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_combinable","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"tax_region_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_region","type":"[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"provider","type":"[TaxProvider](../../../tax_models/classes/tax_models.TaxProvider/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"province_code","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"parent_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"parent","type":"[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rates","type":"Collection&#60;[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"children","type":"Collection&#60;[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"rules","type":"Collection&#60;[TaxRateRule](../../../tax_models/classes/tax_models.TaxRateRule/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"childrenLine truncated
### create
Create a tax rate.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.create({
code: "TEST",
name: "New Tax Rate",
region_id
})
.then(({ tax_rate }) => {
console.log(tax_rate.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostTaxRatesReq](../../../medusa/classes/medusa.AdminPostTaxRatesReq/page.mdx)","description":"The tax rate to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of the tax rate.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the tax rate.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`string`","description":"The ID of the Region that the tax rate belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rate","type":"`null` \\| `number`","description":"The numeric rate to charge.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"`string`[]","description":"The IDs of the products associated with this tax rate.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_options","type":"`string`[]","description":"The IDs of the shipping options associated with this tax rate","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_types","type":"`string`[]","description":"The IDs of the types of products associated with this tax rate","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminPostTaxRatesParams](../../../medusa/classes/medusa.AdminPostTaxRatesParams/page.mdx)","description":"Configurations to apply on the retrieved tax rate.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`[]","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`[]","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminTaxRatesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the tax rate's details.","expandable":false,"children":[{"name":"AdminTaxRatesRes","type":"[AdminTaxRatesRes](../../../medusa/types/medusa.AdminTaxRatesRes/page.mdx)","optional":false,"defaultValue":"","description":"The tax rate's details.","expandable":false,"children":[{"name":"tax_rate","type":"[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx)","description":"Tax rate details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rate","type":"`null` \\| `number`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"code","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_combinable","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"tax_region_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_region","type":"[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"provider","type":"[TaxProvider](../../../tax_models/classes/tax_models.TaxProvider/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"province_code","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"parent_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"parent","type":"[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rates","type":"Collection&#60;[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"children","type":"Collection&#60;[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"rules","type":"Collection&#60;[TaxRateRule](../../../tax_models/classes/tax_models.TaxRateRule/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rate_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reference_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reference","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rate","type":"[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \Line truncated
### update
Update a tax rate's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.update(taxRateId, {
name: "New Tax Rate"
})
.then(({ tax_rate }) => {
console.log(tax_rate.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The tax rate's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostTaxRatesTaxRateReq](../../../medusa/classes/medusa.AdminPostTaxRatesTaxRateReq/page.mdx)","description":"The attributes to update in the tax rate.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of the tax rate.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the tax rate.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`string`","description":"The ID of the Region that the tax rate belongs to.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rate","type":"`null` \\| `number`","description":"The numeric rate to charge.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"`string`[]","description":"The IDs of the products associated with this tax rate","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_options","type":"`string`[]","description":"The IDs of the shipping options associated with this tax rate","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"product_types","type":"`string`[]","description":"The IDs of the types of product types associated with this tax rate","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminPostTaxRatesTaxRateParams](../../../medusa/classes/medusa.AdminPostTaxRatesTaxRateParams/page.mdx)","description":"Configurations to apply on the retrieved tax rate.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`[]","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`[]","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminTaxRatesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the tax rate's details.","expandable":false,"children":[{"name":"AdminTaxRatesRes","type":"[AdminTaxRatesRes](../../../medusa/types/medusa.AdminTaxRatesRes/page.mdx)","optional":false,"defaultValue":"","description":"The tax rate's details.","expandable":false,"children":[{"name":"tax_rate","type":"[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx)","description":"Tax rate details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rate","type":"`null` \\| `number`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"code","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_combinable","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"tax_region_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_region","type":"[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"provider","type":"[TaxProvider](../../../tax_models/classes/tax_models.TaxProvider/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"province_code","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"parent_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"parent","type":"[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rates","type":"Collection&#60;[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"children","type":"Collection&#60;[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"rules","type":"Collection&#60;[TaxRateRule](../../../tax_models/classes/tax_models.TaxRateRule/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rate_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reference_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reference","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rate","type":"[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \Line truncated
### addProducts
Add products to a tax rate.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.addProducts(taxRateId, {
products: [
productId
]
})
.then(({ tax_rate }) => {
console.log(tax_rate.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The tax rate's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostTaxRatesTaxRateProductsReq](../../../medusa/classes/medusa.AdminPostTaxRatesTaxRateProductsReq/page.mdx)","description":"The products to add to the tax rate.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"products","type":"`string`[]","description":"The IDs of the products to associate with this tax rate","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminPostTaxRatesTaxRateProductsParams](../../../medusa/classes/medusa.AdminPostTaxRatesTaxRateProductsParams/page.mdx)","description":"Configurations to apply on the retrieved tax rate.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`[]","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`[]","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addProducts"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminTaxRatesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the tax rate's details.","expandable":false,"children":[{"name":"AdminTaxRatesRes","type":"[AdminTaxRatesRes](../../../medusa/types/medusa.AdminTaxRatesRes/page.mdx)","optional":false,"defaultValue":"","description":"The tax rate's details.","expandable":false,"children":[{"name":"tax_rate","type":"[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx)","description":"Tax rate details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rate","type":"`null` \\| `number`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"code","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_combinable","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"tax_region_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_region","type":"[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"provider","type":"[TaxProvider](../../../tax_models/classes/tax_models.TaxProvider/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"province_code","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"parent_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"parent","type":"[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rates","type":"Collection&#60;[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"children","type":"Collection&#60;[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"rules","type":"Collection&#60;[TaxRateRule](../../../tax_models/classes/tax_models.TaxRateRule/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rate_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reference_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reference","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rate","type":"[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \Line truncated
### addProductTypes
Add product types to a tax rate.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.addProductTypes(taxRateId, {
product_types: [
productTypeId
]
})
.then(({ tax_rate }) => {
console.log(tax_rate.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The tax rate's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostTaxRatesTaxRateProductTypesReq](../../../medusa/classes/medusa.AdminPostTaxRatesTaxRateProductTypesReq/page.mdx)","description":"The product types to add to the tax rate.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"product_types","type":"`string`[]","description":"The IDs of the types of products to associate with this tax rate","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetTaxRatesTaxRateParams](../../../medusa/classes/medusa.AdminGetTaxRatesTaxRateParams/page.mdx)","description":"Configurations to apply on the retrieved tax rate.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`[]","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`[]","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addProductTypes"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminTaxRatesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the tax rate's details.","expandable":false,"children":[{"name":"AdminTaxRatesRes","type":"[AdminTaxRatesRes](../../../medusa/types/medusa.AdminTaxRatesRes/page.mdx)","optional":false,"defaultValue":"","description":"The tax rate's details.","expandable":false,"children":[{"name":"tax_rate","type":"[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx)","description":"Tax rate details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rate","type":"`null` \\| `number`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"code","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_combinable","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"tax_region_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_region","type":"[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"provider","type":"[TaxProvider](../../../tax_models/classes/tax_models.TaxProvider/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"province_code","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"parent_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"parent","type":"[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rates","type":"Collection&#60;[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"children","type":"Collection&#60;[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"rules","type":"Collection&#60;[TaxRateRule](../../../tax_models/classes/tax_models.TaxRateRule/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rate_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reference_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reference","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rate","type":"[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \Line truncated
### addShippingOptions
Add shipping options to a tax rate.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.addShippingOptions(taxRateId, {
shipping_options: [
shippingOptionId
]
})
.then(({ tax_rate }) => {
console.log(tax_rate.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The tax rate's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminPostTaxRatesTaxRateShippingOptionsReq](../../../medusa/classes/medusa.AdminPostTaxRatesTaxRateShippingOptionsReq/page.mdx)","description":"The shipping options to add to the tax rate.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"shipping_options","type":"`string`[]","description":"The IDs of the shipping options to associate with this tax rate","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminPostTaxRatesTaxRateShippingOptionsParams](../../../medusa/classes/medusa.AdminPostTaxRatesTaxRateShippingOptionsParams/page.mdx)","description":"Configurations to apply on the retrieved tax rate.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`[]","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`[]","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addShippingOptions"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminTaxRatesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the tax rate's details.","expandable":false,"children":[{"name":"AdminTaxRatesRes","type":"[AdminTaxRatesRes](../../../medusa/types/medusa.AdminTaxRatesRes/page.mdx)","optional":false,"defaultValue":"","description":"The tax rate's details.","expandable":false,"children":[{"name":"tax_rate","type":"[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx)","description":"Tax rate details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rate","type":"`null` \\| `number`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"code","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_combinable","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"tax_region_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_region","type":"[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"provider","type":"[TaxProvider](../../../tax_models/classes/tax_models.TaxProvider/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"province_code","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"parent_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"parent","type":"[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rates","type":"Collection&#60;[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"children","type":"Collection&#60;[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"rules","type":"Collection&#60;[TaxRateRule](../../../tax_models/classes/tax_models.TaxRateRule/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rate_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reference_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reference","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rate","type":"[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \Line truncated
### removeProducts
Remove products from a tax rate. This only removes the association between the products and the tax rate. It does not delete the products.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.removeProducts(taxRateId, {
products: [
productId
]
})
.then(({ tax_rate }) => {
console.log(tax_rate.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The tax rate's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminDeleteTaxRatesTaxRateProductsReq](../../../medusa/classes/medusa.AdminDeleteTaxRatesTaxRateProductsReq/page.mdx)","description":"The products to remove from the tax rate.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"products","type":"`string`[]","description":"The IDs of the products to remove their association with this tax rate.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminDeleteTaxRatesTaxRateProductsParams](../../../medusa/classes/medusa.AdminDeleteTaxRatesTaxRateProductsParams/page.mdx)","description":"Configurations to apply on the retrieved tax rate.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`[]","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`[]","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeProducts"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminTaxRatesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the tax rate's details.","expandable":false,"children":[{"name":"AdminTaxRatesRes","type":"[AdminTaxRatesRes](../../../medusa/types/medusa.AdminTaxRatesRes/page.mdx)","optional":false,"defaultValue":"","description":"The tax rate's details.","expandable":false,"children":[{"name":"tax_rate","type":"[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx)","description":"Tax rate details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rate","type":"`null` \\| `number`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"code","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_combinable","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"tax_region_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_region","type":"[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"provider","type":"[TaxProvider](../../../tax_models/classes/tax_models.TaxProvider/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"province_code","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"parent_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"parent","type":"[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rates","type":"Collection&#60;[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"children","type":"Collection&#60;[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"rules","type":"Collection&#60;[TaxRateRule](../../../tax_models/classes/tax_models.TaxRateRule/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rate_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reference_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reference","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rate","type":"[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \Line truncated
### removeProductTypes
Remove product types from a tax rate. This only removes the association between the product types and the tax rate. It does not delete the product types.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.removeProductTypes(taxRateId, {
product_types: [
productTypeId
]
})
.then(({ tax_rate }) => {
console.log(tax_rate.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The tax rate's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminDeleteTaxRatesTaxRateProductTypesReq](../../../medusa/classes/medusa.AdminDeleteTaxRatesTaxRateProductTypesReq/page.mdx)","description":"The product types to remove from the tax rate.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"product_types","type":"`string`[]","description":"The IDs of the product types to remove their association with this tax rate.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminDeleteTaxRatesTaxRateProductTypesParams](../../../medusa/classes/medusa.AdminDeleteTaxRatesTaxRateProductTypesParams/page.mdx)","description":"Configurations to apply on the retrieved tax rate.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`[]","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`[]","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeProductTypes"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminTaxRatesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the tax rate's details.","expandable":false,"children":[{"name":"AdminTaxRatesRes","type":"[AdminTaxRatesRes](../../../medusa/types/medusa.AdminTaxRatesRes/page.mdx)","optional":false,"defaultValue":"","description":"The tax rate's details.","expandable":false,"children":[{"name":"tax_rate","type":"[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx)","description":"Tax rate details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rate","type":"`null` \\| `number`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"code","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_combinable","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"tax_region_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_region","type":"[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"provider","type":"[TaxProvider](../../../tax_models/classes/tax_models.TaxProvider/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"province_code","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"parent_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"parent","type":"[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rates","type":"Collection&#60;[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"children","type":"Collection&#60;[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"rules","type":"Collection&#60;[TaxRateRule](../../../tax_models/classes/tax_models.TaxRateRule/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rate_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reference_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reference","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rate","type":"[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \Line truncated
### removeShippingOptions
Remove shipping options from a tax rate. This only removes the association between the shipping options and the tax rate. It does not delete the shipping options.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.removeShippingOptions(taxRateId, {
shipping_options: [
shippingOptionId
]
})
.then(({ tax_rate }) => {
console.log(tax_rate.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The tax rate's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[AdminDeleteTaxRatesTaxRateShippingOptionsReq](../../../medusa/classes/medusa.AdminDeleteTaxRatesTaxRateShippingOptionsReq/page.mdx)","description":"The shipping options to remove from the tax rate.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"shipping_options","type":"`string`[]","description":"The IDs of the shipping options to remove their association with this tax rate.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminDeleteTaxRatesTaxRateShippingOptionsParams](../../../medusa/classes/medusa.AdminDeleteTaxRatesTaxRateShippingOptionsParams/page.mdx)","description":"Configurations to apply on the retrieved tax rate.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`[]","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`[]","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeShippingOptions"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminTaxRatesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the tax rate's details.","expandable":false,"children":[{"name":"AdminTaxRatesRes","type":"[AdminTaxRatesRes](../../../medusa/types/medusa.AdminTaxRatesRes/page.mdx)","optional":false,"defaultValue":"","description":"The tax rate's details.","expandable":false,"children":[{"name":"tax_rate","type":"[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx)","description":"Tax rate details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"rate","type":"`null` \\| `number`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"code","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_default","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_combinable","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"tax_region_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_region","type":"[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"provider","type":"[TaxProvider](../../../tax_models/classes/tax_models.TaxProvider/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"province_code","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"parent_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"parent","type":"[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rates","type":"Collection&#60;[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"children","type":"Collection&#60;[TaxRegion](../../../tax_models/classes/tax_models.TaxRegion/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"rules","type":"Collection&#60;[TaxRateRule](../../../tax_models/classes/tax_models.TaxRateRule/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rate_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reference_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reference","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rate","type":"[TaxRate](../../../tax_models/classes/tax_models.TaxRate/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \Line truncated
### delete
Delete a tax rate. Resources associated with the tax rate, such as products or product types, are not deleted.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.delete(taxRateId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The tax rate's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"[DeleteResponse](../../../medusa/interfaces/medusa.DeleteResponse/page.mdx)","optional":false,"defaultValue":"","description":"The response returned for a \n\n`DELETE`\n\n request.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the deleted item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the deleted item.","optional":false,"defaultValue":"product-collection","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether the item was deleted successfully.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
@@ -0,0 +1,128 @@
---
slug: /references/js-client/AdminUploadsResource
---
import { TypeList } from "docs-ui"
# AdminUploadsResource
This class is used to send requests to [Admin Upload API Routes](https://docs.medusajs.com/api/admin#uploads). All its method
are available in the JS Client under the `medusa.admin.uploads` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
The methods in this class are used to upload any type of resources. For example, they can be used to upload CSV files that are used to import products into the store.
Related Guide: [How to upload CSV file when importing a product](https://docs.medusajs.com/modules/products/admin/import-products#1-upload-csv-file).
## Methods
### create
Upload a file or multiple files to a public bucket or storage. The file upload is handled by the file service installed on the Medusa backend.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.uploads.create(file)
.then(({ uploads }) => {
console.log(uploads.length);
})
```
#### Parameters
<TypeList types={[{"name":"file","type":"`AdminCreateUploadPayload`","description":"The file(s) to upload.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminUploadsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the uploaded file details.","expandable":false,"children":[{"name":"AdminUploadsRes","type":"[AdminUploadsRes](../../../medusa/types/medusa.AdminUploadsRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of uploaded files.","expandable":false,"children":[{"name":"uploads","type":"[FileServiceUploadResult](../../../medusa/interfaces/medusa.FileServiceUploadResult/page.mdx)[]","description":"Uploaded files details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"url","type":"`string`","description":"The file's URL.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"key","type":"`string`","description":"The file's key. This key is used in other operations,\nsuch as deleting a file.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### createProtected
Upload a file to an ACL or a non-public bucket. The file upload is handled by the file service installed on the Medusa backend.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.uploads.createProtected(file)
.then(({ uploads }) => {
console.log(uploads.length);
})
```
#### Parameters
<TypeList types={[{"name":"file","type":"`AdminCreateUploadPayload`","description":"The file to upload.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createProtected"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminUploadsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the uploaded file details.","expandable":false,"children":[{"name":"AdminUploadsRes","type":"[AdminUploadsRes](../../../medusa/types/medusa.AdminUploadsRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of uploaded files.","expandable":false,"children":[{"name":"uploads","type":"[FileServiceUploadResult](../../../medusa/interfaces/medusa.FileServiceUploadResult/page.mdx)[]","description":"Uploaded files details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"url","type":"`string`","description":"The file's URL.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"key","type":"`string`","description":"The file's key. This key is used in other operations,\nsuch as deleting a file.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createProtected"/>
### delete
Delete an uploaded file from storage. The file is deleted using the installed file service on the Medusa backend.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.uploads.delete({
file_key
})
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminDeleteUploadsReq](../../../medusa/classes/medusa.AdminDeleteUploadsReq/page.mdx)","description":"The uploaded file to delete.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"file_key","type":"`string`","description":"key of the file to delete. This is obtained when you first uploaded the file, or by the file service if you used it directly.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"[DeleteResponse](../../../medusa/interfaces/medusa.DeleteResponse/page.mdx)","optional":false,"defaultValue":"","description":"The response returned for a \n\n`DELETE`\n\n request.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the deleted item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the deleted item.","optional":false,"defaultValue":"product-collection","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether the item was deleted successfully.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### getPresignedDownloadUrl
Create and retrieve a presigned or public download URL for a file. The URL creation is handled by the file service installed on the Medusa backend.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.uploads.getPresignedDownloadUrl({
file_key
})
.then(({ download_url }) => {
console.log(download_url);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminPostUploadsDownloadUrlReq](../../../medusa/classes/medusa.AdminPostUploadsDownloadUrlReq/page.mdx)","description":"The uploaded file to get a presigned download URL for.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"file_key","type":"`string`","description":"key of the file to obtain the download link for. This is obtained when you first uploaded the file, or by the file service if you used it directly.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getPresignedDownloadUrl"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminUploadsDownloadUrlRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the download URL details.","expandable":false,"children":[{"name":"AdminUploadsDownloadUrlRes","type":"[AdminUploadsDownloadUrlRes](../../../medusa/types/medusa.AdminUploadsDownloadUrlRes/page.mdx)","optional":false,"defaultValue":"","description":"The download URL details.","expandable":false,"children":[{"name":"download_url","type":"`string`","description":"The Download URL of the file","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getPresignedDownloadUrl"/>
### \_createPayload
#### Parameters
<TypeList types={[{"name":"file","type":"`AdminCreateUploadPayload`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="_createPayload"/>
#### Returns
<TypeList types={[{"name":"FormData","type":"`FormData`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="_createPayload"/>
@@ -0,0 +1,219 @@
---
slug: /references/js-client/AdminUsersResource
---
import { TypeList } from "docs-ui"
# AdminUsersResource
This class is used to send requests to [Admin User API Routes](https://docs.medusajs.com/api/admin#users). All its method
are available in the JS Client under the `medusa.admin.users` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A store can have more than one user, each having the same privileges. Admins can manage users, their passwords, and more.
Related Guide: [How to manage users](https://docs.medusajs.com/modules/users/admin/manage-users).
## Methods
### sendResetPasswordToken
Generate a password token for an admin user with a given email. This also triggers the `user.password_reset` event. So, if you have a Notification Service installed
that can handle this event, a notification, such as an email, will be sent to the user. The token is triggered as part of the `user.password_reset` event's payload.
That token must be used later to reset the password using the [resetPassword](page.mdx#resetpassword) method.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.users.sendResetPasswordToken({
email: "user@example.com"
})
.then(() => {
// successful
})
.catch(() => {
// error occurred
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminResetPasswordTokenRequest](../../../medusa/classes/medusa.AdminResetPasswordTokenRequest/page.mdx)","description":"The user's reset details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"email","type":"`string`","description":"The User's email.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="sendResetPasswordToken"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;void&#62;","optional":false,"defaultValue":"","description":"Resolves when the token is generated successfully.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="sendResetPasswordToken"/>
### resetPassword
Reset the password of an admin user using their reset password token. You must generate a reset password token first for the user using the [sendResetPasswordToken](page.mdx#sendresetpasswordtoken) method,
then use that token to reset the password in this method.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.users.resetPassword({
token: "supersecrettoken",
password: "supersecret"
})
.then(({ user }) => {
console.log(user.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[AdminResetPasswordRequest](../../../medusa/classes/medusa.AdminResetPasswordRequest/page.mdx)","description":"The reset details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"token","type":"`string`","description":"The password-reset token generated when the password reset was requested.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"password","type":"`string`","description":"The User's new password.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"The User's email.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="resetPassword"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminUserRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the user's details.","expandable":false,"children":[{"name":"AdminUserRes","type":"[AdminUserRes](../../../medusa/types/medusa.AdminUserRes/page.mdx)","optional":false,"defaultValue":"","description":"The user's details.","expandable":false,"children":[{"name":"user","type":"Omit&#60;User, \"password_hash\"&#62;","description":"User details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"avatar_url","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`OptionalFields`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":true,"defaultValue":"null","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="resetPassword"/>
### retrieve
Retrieve an admin user's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.users.retrieve(userId)
.then(({ user }) => {
console.log(user.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The user's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminUserRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the user's details.","expandable":false,"children":[{"name":"AdminUserRes","type":"[AdminUserRes](../../../medusa/types/medusa.AdminUserRes/page.mdx)","optional":false,"defaultValue":"","description":"The user's details.","expandable":false,"children":[{"name":"user","type":"Omit&#60;User, \"password_hash\"&#62;","description":"User details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"avatar_url","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`OptionalFields`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":true,"defaultValue":"null","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### create
Create an admin user. The user has the same privileges as all admin users, and will be able to authenticate and perform admin functionalities right after creation.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.users.create({
email: "user@example.com",
password: "supersecret"
})
.then(({ user }) => {
console.log(user.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminCreateUserPayload`","description":"The user to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminUserRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the user's details.","expandable":false,"children":[{"name":"AdminUserRes","type":"[AdminUserRes](../../../medusa/types/medusa.AdminUserRes/page.mdx)","optional":false,"defaultValue":"","description":"The user's details.","expandable":false,"children":[{"name":"user","type":"Omit&#60;User, \"password_hash\"&#62;","description":"User details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"avatar_url","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`OptionalFields`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":true,"defaultValue":"null","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update an admin user's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.users.update(userId, {
first_name: "Marcellus"
})
.then(({ user }) => {
console.log(user.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The user's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminUpdateUserPayload`","description":"The attributes to update in the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminUserRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the user's details.","expandable":false,"children":[{"name":"AdminUserRes","type":"[AdminUserRes](../../../medusa/types/medusa.AdminUserRes/page.mdx)","optional":false,"defaultValue":"","description":"The user's details.","expandable":false,"children":[{"name":"user","type":"Omit&#60;User, \"password_hash\"&#62;","description":"User details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"avatar_url","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`OptionalFields`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":true,"defaultValue":"null","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete a user. Once deleted, the user will not be able to authenticate or perform admin functionalities.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.users.delete(userId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The user's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"[DeleteResponse](../../../medusa/interfaces/medusa.DeleteResponse/page.mdx)","optional":false,"defaultValue":"","description":"The response returned for a \n\n`DELETE`\n\n request.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the deleted item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"object","type":"`string`","description":"The type of the deleted item.","optional":false,"defaultValue":"product-collection","expandable":false,"children":[]},{"name":"deleted","type":"`boolean`","description":"Whether the item was deleted successfully.","optional":false,"defaultValue":"true","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### list
Retrieve all admin users.
#### Example
To list users:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.users.list()
.then(({ users }) => {
console.log(users.length);
})
```
By default, only the first `20` users are returned. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.users.list({
limit,
offset
})
.then(({ users, limit, offset, count }) => {
console.log(users.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetUsersParams](../../../medusa/classes/medusa.AdminGetUsersParams/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string` \\| `string`[]","description":"IDs to filter users by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"q","type":"`string`","description":"Search terms to search users' first name, last name, and email.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the users' `update_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the customer users' `created_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"deleted_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the users' `deleted_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"email","type":"`string`","description":"Filter to apply on the users' `email` field.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`string`","description":"Filter to apply on the users' `first_name` field.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`string`","description":"Filter to apply on the users' `last_name` field.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"role","type":"[UserRole](../../../medusa/enums/medusa.UserRole/page.mdx)","description":"Filter to apply on the users' `role` field.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"MEMBER","type":"`\"member\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ADMIN","type":"`\"admin\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"DEVELOPER","type":"`\"developer\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned users.Line truncated
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminUsersListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of users.","expandable":false,"children":[{"name":"AdminUsersListRes","type":"[AdminUsersListRes](../../../medusa/types/medusa.AdminUsersListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of users.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The limit applied on the retrieved items.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before retrieving the list of items.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total count of items.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"users","type":"Omit&#60;User, \"password_hash\"&#62;[]","description":"An array of users details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"avatar_url","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`OptionalFields`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":true,"defaultValue":"null","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
@@ -0,0 +1,139 @@
---
slug: /references/js-client/AdminVariantsResource
---
import { TypeList } from "docs-ui"
# AdminVariantsResource
This class is used to send requests to [Admin Product Variant API Routes](https://docs.medusajs.com/api/admin#product-variants). All its method
are available in the JS Client under the `medusa.admin.variants` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Product variants are the actual salable item in your store. Each variant is a combination of the different option values available on the product.
Product variants can be managed through [AdminProductsResource](../js_client.AdminProductsResource/page.mdx).
Related Guide: [How to manage product variants](https://docs.medusajs.com/modules/products/admin/manage-products#manage-product-variants).
## Methods
### list
Retrieve a list of product variants. The product variant can be filtered by fields such as `id` or `title` passed in the `query` parameter. The product variant can also be paginated.
#### Example
To list product variants:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.variants.list()
.then(({ variants, limit, offset, count }) => {
console.log(variants.length);
})
```
To specify relations that should be retrieved within the product variants:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.variants.list({
expand: "options"
})
.then(({ variants, limit, offset, count }) => {
console.log(variants.length);
})
```
By default, only the first `100` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.variants.list({
expand: "options",
limit,
offset
})
.then(({ variants, limit, offset, count }) => {
console.log(variants.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetVariantsParams](../../../medusa/classes/medusa.AdminGetVariantsParams/page.mdx)","description":"Filters and pagination configurations to apply on the retrieved product variants.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Search term to search product variants' IDs.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":true,"defaultValue":"20","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"IDs to filter product variants by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string` \\| `string`[]","description":"Titles to filter product variants by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"inventory_quantity","type":"`number` \\| [NumericalComparisonOperator](../../../medusa/classes/medusa.NumericalComparisonOperator/page.mdx)","description":"Number filters to apply on product variants' `inventory_quantity` field.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"manage_inventory","type":"`boolean`","description":"Filter product variants by whether their inventory is managed or not.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"allow_backorder","type":"`boolean`","description":"Filter product variants by whether they are allowed to be backordered or not.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"cart_id","type":"`string`","description":"Retrieve prices for a cart ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`string`","description":"Retrieve prices for a region ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"Retrieve prices for a currency code.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"Retrieve prices for a customer ID.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminVariantsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of product variants with pagination fields.","expandable":false,"children":[{"name":"AdminVariantsListRes","type":"[AdminVariantsListRes](../../../medusa/types/medusa.AdminVariantsListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of variants with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variants","type":"[PricedVariant](../../../medusa/types/medusa.PricedVariant/page.mdx)[]","description":"An array of product variant details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### retrieve
Retrieve a product variant's details.
#### Example
A simple example that retrieves a product variant by its ID:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.variants.retrieve(variantId)
.then(({ variant }) => {
console.log(variant.id);
})
```
To specify relations that should be retrieved:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.variants.retrieve(variantId, {
expand: "options"
})
.then(({ variant }) => {
console.log(variant.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The product variant's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[AdminGetVariantParams](../../../medusa/classes/medusa.AdminGetVariantParams/page.mdx)","description":"Configurations to apply on the retrieved product variant.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminVariantsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product variant's details.","expandable":false,"children":[{"name":"AdminVariantsRes","type":"[AdminVariantsRes](../../../medusa/types/medusa.AdminVariantsRes/page.mdx)","optional":false,"defaultValue":"","description":"The product variant's details.","expandable":false,"children":[{"name":"variant","type":"[PricedVariant](../../../medusa/types/medusa.PricedVariant/page.mdx)","description":"Product variant's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### getInventory
Retrieve the available inventory of a product variant.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.variants.getInventory(variantId)
.then(({ variant }) => {
console.log(variant.inventory, variant.sales_channel_availability)
})
```
#### Parameters
<TypeList types={[{"name":"variantId","type":"`string`","description":"The product variant's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getInventory"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminGetVariantsVariantInventoryRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the inventory details of the product variant.","expandable":false,"children":[{"name":"AdminGetVariantsVariantInventoryRes","type":"[AdminGetVariantsVariantInventoryRes](../../../medusa/types/medusa.AdminGetVariantsVariantInventoryRes/page.mdx)","optional":false,"defaultValue":"","description":"The variant's inventory details.","expandable":false,"children":[{"name":"variant","type":"[VariantInventory](../../../medusa/types/medusa.VariantInventory/page.mdx)","description":"The product variant's inventory details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"the ID of the variant","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"inventory","type":"[ResponseInventoryItem](../../../medusa/types/medusa.ResponseInventoryItem/page.mdx)[]","description":"The inventory details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"location_levels","type":"[LevelWithAvailability](../../../medusa/types/medusa.LevelWithAvailability/page.mdx)[]","description":"The inventory's location levels.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"sales_channel_availability","type":"`object`[]","description":"Details about the variant's inventory availability in sales channels.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"channel_name","type":"`string`","description":"Sales channel's name","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"channel_id","type":"`string`","description":"Sales channel's ID","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"available_quantity","type":"`number`","description":"Available quantity in the sales channel","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getInventory"/>
@@ -0,0 +1,139 @@
---
slug: /references/js-client/AuthResource
---
import { TypeList } from "docs-ui"
# AuthResource
This class is used to send requests to [Store Auth API Routes](https://docs.medusajs.com/api/store#auth). All its method
are available in the JS Client under the `medusa.auth` property.
The methods in this class allows you to manage a customer's session, such as login or log out.
You can send authenticated requests for a customer either using the Cookie header or using the JWT Token.
When you log the customer in using the [authenticate](page.mdx#authenticate) method, the JS client will automatically attach the
cookie header in all subsequent requests.
Related Guide: [How to implement customer profiles in your storefront](https://docs.medusajs.com/modules/customers/storefront/implement-customer-profiles).
## Methods
### authenticate
Authenticate a customer using their email and password. If the customer is authenticated successfully, the cookie is automatically attached to subsequent requests sent with the JS Client.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.auth.authenticate({
email: "user@example.com",
password: "user@example.com"
})
.then(({ customer }) => {
console.log(customer.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[StorePostAuthReq](../../../medusa/classes/medusa.StorePostAuthReq/page.mdx)","description":"The credentials of the customer to authenticate.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"email","type":"`string`","description":"The Customer's email.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"password","type":"`string`","description":"The Customer's password.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="authenticate"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreAuthRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer's details.","expandable":false,"children":[{"name":"StoreAuthRes","type":"[StoreAuthRes](../../../medusa/types/medusa.StoreAuthRes/page.mdx)","optional":false,"defaultValue":"","description":"The customer's details.","expandable":false,"children":[{"name":"customer","type":"[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx)","description":"Customer's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"groups","type":"Collection&#60;[CustomerGroup](../../../customer_models/classes/customer_models.CustomerGroup/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customers","type":"Collection&#60;[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]}]},{"name":"addresses","type":"Collection&#60;[Address](../../../customer_models/classes/customer_models.Address/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[EntityDateColumns](../../../types/DAL/types/types.DAL.EntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customer","type":"[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandableLine truncated
### deleteSession
Log out the customer and remove their authentication session. This method requires [authentication](../../../modules/customer/page.mdx).
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.auth.deleteSession()
.then(() => {
// customer logged out successfully
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteSession"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;void&#62;","optional":false,"defaultValue":"","description":"Resolves when customer is logged out successfully.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteSession"/>
### getSession
Retrieve the details of the logged-in customer. Can also be used to check if there is an authenticated customer.
This method requires [authentication](../../../modules/customer/page.mdx).
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged
medusa.auth.getSession()
.then(({ customer }) => {
console.log(customer.id);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getSession"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreAuthRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer's details.","expandable":false,"children":[{"name":"StoreAuthRes","type":"[StoreAuthRes](../../../medusa/types/medusa.StoreAuthRes/page.mdx)","optional":false,"defaultValue":"","description":"The customer's details.","expandable":false,"children":[{"name":"customer","type":"[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx)","description":"Customer's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"groups","type":"Collection&#60;[CustomerGroup](../../../customer_models/classes/customer_models.CustomerGroup/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customers","type":"Collection&#60;[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]}]},{"name":"addresses","type":"Collection&#60;[Address](../../../customer_models/classes/customer_models.Address/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[EntityDateColumns](../../../types/DAL/types/types.DAL.EntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customer","type":"[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandableLine truncated
### exists
Check if the email is already used by another registered customer. Can be used to validate a new customer's email.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.auth.exists("user@example.com")
```
#### Parameters
<TypeList types={[{"name":"email","type":"`string`","description":"The email to check.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="exists"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreGetAuthEmailRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the result of the check.","expandable":false,"children":[{"name":"StoreGetAuthEmailRes","type":"[StoreGetAuthEmailRes](../../../medusa/types/medusa.StoreGetAuthEmailRes/page.mdx)","optional":false,"defaultValue":"","description":"Details on whether the email exists.","expandable":false,"children":[{"name":"exists","type":"`boolean`","description":"Whether email exists or not.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="exists"/>
### getToken
Authenticate the customer and retrieve a JWT token to use for subsequent authenticated requests.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.auth.getToken({
email: 'user@example.com',
password: 'supersecret'
})
.then(({ access_token }) => {
console.log(access_token);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[StorePostAuthReq](../../../medusa/classes/medusa.StorePostAuthReq/page.mdx)","description":"The credentials of the customer to authenticate.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"email","type":"`string`","description":"The Customer's email.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"password","type":"`string`","description":"The Customer's password.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getToken"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreBearerAuthRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the access token of the customer, if they're authenticated successfully.","expandable":false,"children":[{"name":"StoreBearerAuthRes","type":"[StoreBearerAuthRes](../../../medusa/types/medusa.StoreBearerAuthRes/page.mdx)","optional":false,"defaultValue":"","description":"The access token details.","expandable":false,"children":[{"name":"access_token","type":"`string`","description":"Access token that can be used to send authenticated requests.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getToken"/>
@@ -0,0 +1,296 @@
---
slug: /references/js-client/CartsResource
---
import { TypeList } from "docs-ui"
# CartsResource
This class is used to send requests to [Store Cart API Routes](https://docs.medusajs.com/api/store#carts). All its method
are available in the JS Client under the `medusa.carts` property.
A cart is a virtual shopping bag that customers can use to add items they want to purchase.
A cart is then used to checkout and place an order.
Related Guide: [How to implement cart functionality in your storefront](https://docs.medusajs.com/modules/carts-and-checkout/storefront/implement-cart).
## Properties
<TypeList types={[{"name":"lineItems","type":"[LineItemsResource](../js_client.LineItemsResource/page.mdx)","description":"An instance of [LineItemsResource](../js_client.LineItemsResource/page.mdx) used to send requests to line-item-related routes part of the [Store Cart API Routes](https://docs.medusajs.com/api/store#carts).","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="CartsResource"/>
___
## Methods
### addShippingMethod
Add a shipping method to the cart. The validation of the `data` field is handled by the fulfillment provider of the chosen shipping option.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.addShippingMethod(cartId, {
option_id
})
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The ID of the cart to add the shipping method to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[StorePostCartsCartShippingMethodReq](../../../medusa/classes/medusa.StorePostCartsCartShippingMethodReq/page.mdx)","description":"The shipping method to add.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"option_id","type":"`string`","description":"ID of the shipping option to create the method from.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`Record<string, any>`","description":"Used to hold any data that the shipping method may need to process the fulfillment of the order. This depends on the fulfillment provider you're using.","optional":true,"defaultValue":"{}","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addShippingMethod"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"[StoreCartsRes](../../../medusa/types/medusa.StoreCartsRes/page.mdx)","optional":false,"defaultValue":"","description":"The cart's details.","expandable":false,"children":[{"name":"cart","type":"Omit&#60;Cart, \"refundable_amount\" \\| \"refunded_total\"&#62;","description":"Cart details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customer_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"sales_channel_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"items","type":"Collection&#60;[LineItem](../../../cart_models/classes/cart_models.LineItem/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart","type":"[Cart](../../../cart_models/classes/cart_models.Cart/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"thumbnail","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"quantity","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_title","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_description","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_subtitle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_type","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_collection","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_handle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_sku","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_barcode","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_title","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_option_values"Line truncated
### complete
Complete a cart and place an order or create a swap, based on the cart's type. This includes attempting to authorize the cart's payment.
If authorizing the payment requires more action, the cart will not be completed and the order will not be placed or the swap will not be created.
An idempotency key will be generated if none is provided in the header `Idempotency-Key` and added to
the response. If an error occurs during cart completion or the request is interrupted for any reason, the cart completion can be retried by passing the idempotency
key in the `Idempotency-Key` header.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.complete(cartId)
.then(({ data, type }) => {
console.log(data.id, type);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The ID of the cart to complete.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="complete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCompleteCartRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the completion details.","expandable":false,"children":[{"name":"StoreCompleteCartRes","type":"[StoreCompleteCartRes](../../../medusa/types/medusa.StoreCompleteCartRes/page.mdx)","optional":false,"defaultValue":"","description":"If the cart is completed successfully, this will have the created order or the swap's details, based on the cart's type. Otherwise, it'll be the cart's details.","expandable":false,"children":[{"name":"StoreCompleteCartRes","type":"`object` \\| `object` \\| `object`","description":"If the cart is completed successfully, this will have the created order or the swap's details, based on the cart's type. Otherwise, it'll be the cart's details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="complete"/>
### create
Create a Cart. Although optional, specifying the cart's region and sales channel can affect the cart's pricing and
the products that can be added to the cart respectively. So, make sure to set those early on and change them if necessary, such as when the customer changes their region.
If a customer is logged in, make sure to pass its ID or email within the cart's details so that the cart is attached to the customer.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.create()
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"payload","type":"[StorePostCartReq](../../../medusa/classes/medusa.StorePostCartReq/page.mdx)","description":"The cart to create.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"region_id","type":"`string`","description":"The ID of the Region to create the Cart in. Setting the cart's region can affect the pricing of the items in the cart as well as the used currency. If this parameter is not provided, the first region in the store is used by default.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"The two character ISO country code to create the Cart in. Setting this parameter will set the country code of the shipping address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"items","type":"[Item](../../../medusa/classes/medusa.Item-5/page.mdx)[]","description":"An array of product variants to generate line items from.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"variant_id","type":"`string`","description":"The ID of the Product Variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"`number`","description":"The quantity to add into the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"context","type":"`object`","description":"An object to provide context to the Cart. The `context` field is automatically populated with `ip` and `user\\_agent`","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"sales_channel_id","type":"`string`","description":"The ID of the Sales channel to create the Cart in. The cart's sales channel affects which products can be added to the cart. If a product does not exist in the cart's sales channel, it cannot be added to the cart. If you add a publishable API key in the header of this request and specify a sales channel ID, the specified sales channel must be within the scope of the publishable API key's resources. If you add a publishable API key in the header of this request, you don't specify a sales channel ID, and the publishable API key is associated with one sales channel, that sales channel will be attached to the cart. If no sales channel is passed and no publishable API key header is passed or the publishable API key isn't associated with any sales channel, the cart will not be associated with any sales channel.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the created cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"[StoreCartsRes](../../../medusa/types/medusa.StoreCartsRes/page.mdx)","optional":false,"defaultValue":"","description":"The cart's details.","expandable":false,"children":[{"name":"cart","type":"Omit&#60;Cart, \"refundable_amount\" \\| \"refunded_total\"&#62;","description":"Cart details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customer_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"sales_channel_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"items","type":"Collection&#60;[LineItem](../../../cart_models/classes/cart_models.LineItem/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart","type":"[Cart](../../../cart_models/classes/cart_models.Cart/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"thumbnail","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"quantity","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_title","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_description","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_subtitle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_type","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_collection","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_handle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_sku","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_barcode","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_title","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_optionLine truncated
### createPaymentSessions
Create Payment Sessions for each of the available Payment Providers in the Cart's Region. If there's only one payment session created,
it will be selected by default. The creation of the payment session uses the payment provider and may require sending requests to third-party services.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.createPaymentSessions(cartId)
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The ID of the cart to create the payment sessions for.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createPaymentSessions"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"[StoreCartsRes](../../../medusa/types/medusa.StoreCartsRes/page.mdx)","optional":false,"defaultValue":"","description":"The cart's details.","expandable":false,"children":[{"name":"cart","type":"Omit&#60;Cart, \"refundable_amount\" \\| \"refunded_total\"&#62;","description":"Cart details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customer_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"sales_channel_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"items","type":"Collection&#60;[LineItem](../../../cart_models/classes/cart_models.LineItem/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart","type":"[Cart](../../../cart_models/classes/cart_models.Cart/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"thumbnail","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"quantity","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_title","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_description","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_subtitle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_type","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_collection","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_handle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_sku","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_barcode","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_title","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_option_values"Line truncated
### deleteDiscount
Remove a Discount from a Cart. This only removes the application of the discount, and not completely deletes it. The totals will be re-calculated and the payment sessions
will be refreshed after the removal.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.deleteDiscount(cartId, code)
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"the ID of the cart to remove the discount from.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string`","description":"The code of the discount to remove from the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteDiscount"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"[StoreCartsRes](../../../medusa/types/medusa.StoreCartsRes/page.mdx)","optional":false,"defaultValue":"","description":"The cart's details.","expandable":false,"children":[{"name":"cart","type":"Omit&#60;Cart, \"refundable_amount\" \\| \"refunded_total\"&#62;","description":"Cart details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customer_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"sales_channel_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"items","type":"Collection&#60;[LineItem](../../../cart_models/classes/cart_models.LineItem/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart","type":"[Cart](../../../cart_models/classes/cart_models.Cart/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"thumbnail","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"quantity","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_title","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_description","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_subtitle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_type","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_collection","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_handle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_sku","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_barcode","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_title","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_option_values"Line truncated
### deletePaymentSession
Delete a Payment Session in a Cart. May be useful if a payment has failed. The totals will be recalculated.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.deletePaymentSession(cartId, "manual")
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The ID of the cart to delete the payment session from.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The ID of the payment provider that the session is associated with.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deletePaymentSession"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"[StoreCartsRes](../../../medusa/types/medusa.StoreCartsRes/page.mdx)","optional":false,"defaultValue":"","description":"The cart's details.","expandable":false,"children":[{"name":"cart","type":"Omit&#60;Cart, \"refundable_amount\" \\| \"refunded_total\"&#62;","description":"Cart details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customer_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"sales_channel_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"items","type":"Collection&#60;[LineItem](../../../cart_models/classes/cart_models.LineItem/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart","type":"[Cart](../../../cart_models/classes/cart_models.Cart/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"thumbnail","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"quantity","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_title","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_description","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_subtitle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_type","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_collection","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_handle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_sku","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_barcode","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_title","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_option_values"Line truncated
### refreshPaymentSession
Refresh a Payment Session to ensure that it is in sync with the Cart. This is usually not necessary, but is provided for edge cases.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.refreshPaymentSession(cartId, "manual")
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The ID of the cart to refresh its payment session.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The ID of the payment provider that's associated with the payment session.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="refreshPaymentSession"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"[StoreCartsRes](../../../medusa/types/medusa.StoreCartsRes/page.mdx)","optional":false,"defaultValue":"","description":"The cart's details.","expandable":false,"children":[{"name":"cart","type":"Omit&#60;Cart, \"refundable_amount\" \\| \"refunded_total\"&#62;","description":"Cart details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customer_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"sales_channel_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"items","type":"Collection&#60;[LineItem](../../../cart_models/classes/cart_models.LineItem/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart","type":"[Cart](../../../cart_models/classes/cart_models.Cart/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"thumbnail","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"quantity","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_title","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_description","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_subtitle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_type","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_collection","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_handle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_sku","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_barcode","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_title","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_option_values"Line truncated
### retrieve
Retrieve a Cart's details. This includes recalculating its totals.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.retrieve(cartId)
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"[StoreCartsRes](../../../medusa/types/medusa.StoreCartsRes/page.mdx)","optional":false,"defaultValue":"","description":"The cart's details.","expandable":false,"children":[{"name":"cart","type":"Omit&#60;Cart, \"refundable_amount\" \\| \"refunded_total\"&#62;","description":"Cart details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customer_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"sales_channel_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"items","type":"Collection&#60;[LineItem](../../../cart_models/classes/cart_models.LineItem/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart","type":"[Cart](../../../cart_models/classes/cart_models.Cart/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"thumbnail","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"quantity","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_title","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_description","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_subtitle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_type","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_collection","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_handle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_sku","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_barcode","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_title","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_option_values"Line truncated
### setPaymentSession
Select the Payment Session that will be used to complete the cart. This is typically used when the customer chooses their preferred payment method during checkout.
The totals of the cart will be recalculated.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.setPaymentSession(cartId, {
provider_id: "manual"
})
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[StorePostCartsCartPaymentSessionReq](../../../medusa/classes/medusa.StorePostCartsCartPaymentSessionReq/page.mdx)","description":"The associated payment provider.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"provider_id","type":"`string`","description":"The ID of the Payment Provider.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="setPaymentSession"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"[StoreCartsRes](../../../medusa/types/medusa.StoreCartsRes/page.mdx)","optional":false,"defaultValue":"","description":"The cart's details.","expandable":false,"children":[{"name":"cart","type":"Omit&#60;Cart, \"refundable_amount\" \\| \"refunded_total\"&#62;","description":"Cart details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customer_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"sales_channel_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"items","type":"Collection&#60;[LineItem](../../../cart_models/classes/cart_models.LineItem/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart","type":"[Cart](../../../cart_models/classes/cart_models.Cart/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"thumbnail","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"quantity","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_title","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_description","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_subtitle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_type","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_collection","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_handle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_sku","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_barcode","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_title","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_option_values"Line truncated
### update
Update a Cart's details. If the cart has payment sessions and the region was not changed, the payment sessions are updated. The cart's totals are also recalculated.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.update(cartId, {
email: "user@example.com"
})
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[StorePostCartsCartReq](../../../medusa/classes/medusa.StorePostCartsCartReq/page.mdx)","description":"The attributes to update in the cart.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"region_id","type":"`string`","description":"The ID of the Region to create the Cart in. Setting the cart's region can affect the pricing of the items in the cart as well as the used currency.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"The 2 character ISO country code to create the Cart in. Setting this parameter will set the country code of the shipping address.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"An email to be used on the Cart.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address","type":"`string` \\| [AddressPayload](../../../medusa/classes/medusa.AddressPayload/page.mdx)","description":"The Address to be used for billing purposes.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address","type":"`string` \\| [AddressPayload](../../../medusa/classes/medusa.AddressPayload/page.mdx)","description":"The Address to be used for shipping purposes.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gift_cards","type":"[GiftCard](../../../medusa/classes/medusa.GiftCard/page.mdx)[]","description":"An array of Gift Card codes to add to the Cart.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of a gift card.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"discounts","type":"[Discount](../../../medusa/classes/medusa.Discount-2/page.mdx)[]","description":"An array of Discount codes to add to the Cart.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of the discount.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customer_id","type":"`string`","description":"The ID of the Customer to associate the Cart with.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"context","type":"`object`","description":"An object to provide context to the Cart. The `context` field is automatically populated with `ip` and `user\\_agent`","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"sales_channel_id","type":"`string`","description":"The ID of the Sales channel to create the Cart in. The cart's sales channel affects which products can be added to the cart. If a product does not exist in the cart's sales channel, it cannot be added to the cart. If you add a publishable API key in the header of this request and specify a sales channel ID, the specified sales channel must be within the scope of the publishable API key's resources.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"[StoreCartsRes](../../../medusa/types/medusa.StoreCartsRes/page.mdx)","optional":false,"defaultValue":"","description":"The cart's details.","expandable":false,"children":[{"name":"cart","type":"Omit&#60;Cart, \"refundable_amount\" \\| \"refunded_total\"&#62;","description":"Cart details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customer_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"sales_channel_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"items","type":"Collection&#60;[LineItem](../../../cart_models/classes/cart_models.LineItem/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart","type":"[Cart](../../../cart_models/classes/cart_models.Cart/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"thumbnail","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"quantity","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_title","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_description","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_subtitle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_type","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_collection","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_handle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_sku","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_barcode","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_title","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_option_values"Line truncated
### updatePaymentSession
Update a Payment Session with additional data. This can be useful depending on the payment provider used.
All payment sessions are updated and cart totals are recalculated afterwards.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.updatePaymentSession(cartId, "manual", {
data: {
}
})
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The ID of the payment provider that the payment session is associated with.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[StorePostCartsCartPaymentSessionUpdateReq](../../../medusa/classes/medusa.StorePostCartsCartPaymentSessionUpdateReq/page.mdx)","description":"The attributes to update in the payment session.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"data","type":"`Record<string, unknown>`","description":"The data to update the payment session with.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updatePaymentSession"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"[StoreCartsRes](../../../medusa/types/medusa.StoreCartsRes/page.mdx)","optional":false,"defaultValue":"","description":"The cart's details.","expandable":false,"children":[{"name":"cart","type":"Omit&#60;Cart, \"refundable_amount\" \\| \"refunded_total\"&#62;","description":"Cart details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customer_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"sales_channel_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"items","type":"Collection&#60;[LineItem](../../../cart_models/classes/cart_models.LineItem/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cart","type":"[Cart](../../../cart_models/classes/cart_models.Cart/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"thumbnail","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"quantity","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variant_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_title","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_description","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_subtitle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_type","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_collection","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"product_handle","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_sku","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_barcode","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_title","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"variant_option_values"Line truncated
@@ -0,0 +1,78 @@
---
slug: /references/js-client/CollectionsResource
---
import { TypeList } from "docs-ui"
# CollectionsResource
This class is used to send requests to [Store Product Collection API Routes](https://docs.medusajs.com/api/store#product-collections). All its method
are available in the JS Client under the `medusa.collections` property.
A product collection is used to organize products for different purposes such as marketing or discount purposes. For example, you can create a Summer Collection.
Using the methods in this class, you can list or retrieve a collection's details and products.
## Methods
### retrieve
Retrieve a product collection's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.collections.retrieve(collectionId)
.then(({ collection }) => {
console.log(collection.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the collection's details.","expandable":false,"children":[{"name":"StoreCollectionsRes","type":"[StoreCollectionsRes](../../../medusa/types/medusa.StoreCollectionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The details of the product collection.","expandable":false,"children":[{"name":"collection","type":"[ProductCollection](../../../product_models/classes/product_models.ProductCollection/page.mdx)","description":"Product collection details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"Collection&#60;[Product](../../../product_models/classes/product_models.Product/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection","type":"`null` \\| [ProductCollection](../../../product_models/classes/product_models.ProductCollection/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`null` \\| [ProductType](../../../product_models/classes/product_models.ProductType/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tags","type":"Collection&#60;[ProductTag](../../../product_models/classes/product_models.ProductTag/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"images","type":"Collection&#60;[Image](../../../product_models/classes/product_models.Image/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"categories","type":"Collection&#60;[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discountable","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"weight","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"length","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"height","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"width","type":"`null` \\| `number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"origin_country","type":"`null` \\|Line truncated
### list
Retrieve a list of product collections. The product collections can be filtered by fields such as `handle` or `created_at` passed in the `query` parameter.
The product collections can also be paginated.
#### Example
To list product collections:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.collections.list()
.then(({ collections, limit, offset, count }) => {
console.log(collections.length);
})
```
By default, only the first `10` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.collections.list({
limit,
offset
})
.then(({ collections, limit, offset, count }) => {
console.log(collections.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[StoreGetCollectionsParams](../../../medusa/classes/medusa.StoreGetCollectionsParams/page.mdx)","description":"Filters and pagination configurations to apply on the retrieved product collections.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"handle","type":"`string`[]","description":"Handles to filter product collections by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":true,"defaultValue":"10","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the product collections' `created_at` date","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"updated_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the product collections' `updated_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCollectionsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of product collections with pagination fields.","expandable":false,"children":[{"name":"StoreCollectionsListRes","type":"[StoreCollectionsListRes](../../../medusa/types/medusa.StoreCollectionsListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of product collections with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collections","type":"[ProductCollection](../../../product_models/classes/product_models.ProductCollection/page.mdx)[]","description":"An array of product collections details","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"Collection&#60;[Product](../../../product_models/classes/product_models.Product/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection","type":"`null` \\| [ProductCollection](../../../product_models/classes/product_models.ProductCollection/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`null` \\| [ProductType](../../../product_models/classes/product_models.ProductType/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tags","type":"Collection&#60;[ProductTag](../../../product_models/classes/product_models.ProductTag/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"images","type":"Collection&#60;[Image](../../../product_models/classes/product_models.Image/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"categories","type":"Collection&#60;[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discountable","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"thumbnail","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"Line truncated
@@ -0,0 +1,183 @@
---
slug: /references/js-client/CustomersResource
---
import { TypeList } from "docs-ui"
# 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
<TypeList types={[{"name":"paymentMethods","type":"[PaymentMethodsResource](../js_client.PaymentMethodsResource/page.mdx)","description":"An instance of [PaymentMethodsResource](../js_client.PaymentMethodsResource/page.mdx) used to send requests to payment-related routes part of the [Store Customer API Routes](https://docs.medusajs.com/api/store#customers\\_postcustomers).","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"addresses","type":"[AddressesResource](../js_client.AddressesResource/page.mdx)","description":"An instance of [AddressesResource](../js_client.AddressesResource/page.mdx) used to send requests to address-related routes part of the [Store Customer API Routes](https://docs.medusajs.com/api/store#customers\\_postcustomers).","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="CustomersResource"/>
___
## 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
<TypeList types={[{"name":"payload","type":"[StorePostCustomersReq](../../../medusa/classes/medusa.StorePostCustomersReq/page.mdx)","description":"The details of the customer to be created.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"first_name","type":"`string`","description":"The customer's first name.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`string`","description":"The customer's last name.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"The customer's email.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"password","type":"`string`","description":"The customer's password.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"phone","type":"`string`","description":"The customer's phone number.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCustomersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the created customer's details.","expandable":false,"children":[{"name":"StoreCustomersRes","type":"[StoreCustomersRes](../../../medusa/types/medusa.StoreCustomersRes/page.mdx)","optional":false,"defaultValue":"","description":"The customer's details.","expandable":false,"children":[{"name":"customer","type":"Omit&#60;Customer, \"password_hash\"&#62;","description":"Customer details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"groups","type":"Collection&#60;[CustomerGroup](../../../customer_models/classes/customer_models.CustomerGroup/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customers","type":"Collection&#60;[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]}]},{"name":"addresses","type":"Collection&#60;[Address](../../../customer_models/classes/customer_models.Address/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[EntityDateColumns](../../../types/DAL/types/types.DAL.EntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customer","type":"[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"chLine truncated
### retrieve
Retrieve the logged-in customer's details. This method requires [authentication](../../../modules/customer/page.mdx).
#### 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
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCustomersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the logged-in customer's details.","expandable":false,"children":[{"name":"StoreCustomersRes","type":"[StoreCustomersRes](../../../medusa/types/medusa.StoreCustomersRes/page.mdx)","optional":false,"defaultValue":"","description":"The customer's details.","expandable":false,"children":[{"name":"customer","type":"Omit&#60;Customer, \"password_hash\"&#62;","description":"Customer details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"groups","type":"Collection&#60;[CustomerGroup](../../../customer_models/classes/customer_models.CustomerGroup/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customers","type":"Collection&#60;[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]}]},{"name":"addresses","type":"Collection&#60;[Address](../../../customer_models/classes/customer_models.Address/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[EntityDateColumns](../../../types/DAL/types/types.DAL.EntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customer","type":"[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"Line truncated
### update
Update the logged-in customer's details. This method requires [authentication](../../../modules/customer/page.mdx).
#### 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
<TypeList types={[{"name":"payload","type":"[StorePostCustomersCustomerReq](../../../medusa/classes/medusa.StorePostCustomersCustomerReq/page.mdx)","description":"The attributes to update in the logged-in customer.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"billing_address","type":"`string` \\| [AddressPayload](../../../medusa/classes/medusa.AddressPayload/page.mdx)","description":"The address to be used for billing purposes.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"first_name","type":"`string`","description":"The customer's first name.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"last_name","type":"`string`","description":"The customer's last name.","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":"email","type":"`string`","description":"The customer's email.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"Additional custom data about the customer.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCustomersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the logged-in customer's details.","expandable":false,"children":[{"name":"StoreCustomersRes","type":"[StoreCustomersRes](../../../medusa/types/medusa.StoreCustomersRes/page.mdx)","optional":false,"defaultValue":"","description":"The customer's details.","expandable":false,"children":[{"name":"customer","type":"Omit&#60;Customer, \"password_hash\"&#62;","description":"Customer details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"groups","type":"Collection&#60;[CustomerGroup](../../../customer_models/classes/customer_models.CustomerGroup/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customers","type":"Collection&#60;[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]}]},{"name":"addresses","type":"Collection&#60;[Address](../../../customer_models/classes/customer_models.Address/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[EntityDateColumns](../../../types/DAL/types/types.DAL.EntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customer","type":"[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"Line truncated
### 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 [authentication](../../../modules/customer/page.mdx).
#### 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
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"params","type":"[StoreGetCustomersCustomerOrdersParams](../../../medusa/classes/medusa.StoreGetCustomersCustomerOrdersParams/page.mdx)","description":"Filters and pagination configurations to apply on the retrieved orders.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":false,"defaultValue":"10","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":false,"defaultValue":"0","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"ID to filter orders by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"q","type":"`string`","description":"Search term to search orders' display ID, email, shipping address's first name, customer's first name, customer's last name, and customer's phone number.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"`OrderStatus`[]","description":"Statuses to filter orders by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillment_status","type":"`FulfillmentStatus`[]","description":"Fulfillment statuses to filter orders by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"payment_status","type":"`PaymentStatus`[]","description":"Payment statuses to filter orders by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"display_id","type":"`string`","description":"Display ID to filter orders by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"cart_id","type":"`string`","description":"Cart ID to filter orders by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"Email to filter orders by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`string`","description":"Region ID to filter orders by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"Currency code to filter orders by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"tax_rate","type":"`string`","description":"Tax rate to filter orders by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the orders' `created_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"updated_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the orders' `updated_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must Line truncated
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCustomersListOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of orders with pagination fields.","expandable":false,"children":[{"name":"StoreCustomersListOrdersRes","type":"[StoreCustomersListOrdersRes](../../../medusa/types/medusa.StoreCustomersListOrdersRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of the customer's orders with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"orders","type":"[Order](../../../types/types/types.Order/page.mdx)[]","description":"An array of orders details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listOrders"/>
### resetPassword
Reset a customer's password using a password token created by a previous request using the [generatePasswordToken](page.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
<TypeList types={[{"name":"payload","type":"[StorePostCustomersResetPasswordReq](../../../medusa/classes/medusa.StorePostCustomersResetPasswordReq/page.mdx)","description":"The necessary details to reset the password.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"email","type":"`string`","description":"The customer's email.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"token","type":"`string`","description":"The reset password token","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"password","type":"`string`","description":"The customer's password.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="resetPassword"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCustomersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer's details.","expandable":false,"children":[{"name":"StoreCustomersRes","type":"[StoreCustomersRes](../../../medusa/types/medusa.StoreCustomersRes/page.mdx)","optional":false,"defaultValue":"","description":"The customer's details.","expandable":false,"children":[{"name":"customer","type":"Omit&#60;Customer, \"password_hash\"&#62;","description":"Customer details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"phone","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"has_account","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"groups","type":"Collection&#60;[CustomerGroup](../../../customer_models/classes/customer_models.CustomerGroup/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[SoftDeletableEntityDateColumns](../../../types/DAL/types/types.DAL.SoftDeletableEntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customers","type":"Collection&#60;[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_by","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]}]},{"name":"addresses","type":"Collection&#60;[Address](../../../customer_models/classes/customer_models.Address/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"[OptionalProps]","type":"[EntityDateColumns](../../../types/DAL/types/types.DAL.EntityDateColumns/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"is_default_shipping","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"is_default_billing","type":"`boolean`","description":"","optional":false,"defaultValue":"false","expandable":false,"children":[]},{"name":"customer_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customer","type":"[Customer](../../../customer_models/classes/customer_models.Customer/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"company","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"first_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"last_name","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":Line truncated
### generatePasswordToken
Create a reset password token to be used when sending a request with the [resetPassword](page.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
<TypeList types={[{"name":"payload","type":"[StorePostCustomersCustomerPasswordTokenReq](../../../medusa/classes/medusa.StorePostCustomersCustomerPasswordTokenReq/page.mdx)","description":"The necessary details to create the reset password token.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"email","type":"`string`","description":"The customer's email.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="generatePasswordToken"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"`ResponsePromise`","optional":false,"defaultValue":"","description":"Resolves when reset password token is created successfully.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="generatePasswordToken"/>
@@ -0,0 +1,40 @@
---
slug: /references/js-client/GiftCardsResource
---
import { TypeList } from "docs-ui"
# GiftCardsResource
This class is used to send requests to [Store Gift Card API Routes](https://docs.medusajs.com/api/store#gift-cards). All its method
are available in the JS Client under the `medusa.giftCards` property.
Customers can use gift cards during checkout to deduct the gift card's balance from the checkout total.
The methods in this class allow retrieving a gift card's details by its code. A gift card can be applied to a cart using [CartsResource](../js_client.CartsResource/page.mdx).
Related Guide: [How to use gift cards in a storefront](https://docs.medusajs.com/modules/gift-cards/storefront/use-gift-cards).
## Methods
### retrieve
Retrieve a Gift Card's details by its associated unique code.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.giftCards.retrieve(code)
.then(({ gift_card }) => {
console.log(gift_card.id);
})
```
#### Parameters
<TypeList types={[{"name":"code","type":"`string`","description":"The code of the gift card.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreGiftCardsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the gift card.","expandable":false,"children":[{"name":"StoreGiftCardsRes","type":"[StoreGiftCardsRes](../../../medusa/types/medusa.StoreGiftCardsRes/page.mdx)","optional":false,"defaultValue":"","description":"The gift card's details.","expandable":false,"children":[{"name":"gift_card","type":"[GiftCard](../../../medusa/classes/medusa.GiftCard/page.mdx)","description":"Gift card details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"code","type":"`string`","description":"The code of a gift card.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
@@ -0,0 +1,86 @@
---
slug: /references/js-client/LineItemsResource
---
import { TypeList } from "docs-ui"
# LineItemsResource
This class is used to send requests to Line Item API Routes part of the [Store Cart API Routes](https://docs.medusajs.com/api/store#carts). All its method
are available in the JS Client under the `medusa.carts.lineItems` property.
## Methods
### create
Generate a Line Item with a given Product Variant and adds it to the Cart
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.lineItems.create(cart_id, {
variant_id,
quantity: 1
})
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[StorePostCartsCartLineItemsReq](../../../medusa/classes/medusa.StorePostCartsCartLineItemsReq/page.mdx)","description":"The line item to be created.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"variant_id","type":"`string`","description":"The id of the Product Variant to generate the Line Item from.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"`number`","description":"The quantity of the Product Variant to add to the Line Item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional key-value map with additional details about the Line Item.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the associated cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"[StoreCartsRes](../../../medusa/types/medusa.StoreCartsRes/page.mdx)","optional":false,"defaultValue":"","description":"The cart's details.","expandable":false,"children":[{"name":"cart","type":"Omit&#60;Cart, \"refundable_amount\" \\| \"refunded_total\"&#62;","description":"Cart details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customer_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"sales_channel_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"items","type":"Collection&#60;[LineItem](../../../cart_models/classes/cart_models.LineItem/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_methods","type":"Collection&#60;[ShippingMethod](../../../cart_models/classes/cart_models.ShippingMethod/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`OptionalCartProps`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update a line item's data.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.lineItems.update(cartId, lineId, {
quantity: 1
})
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The ID of the line item's cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"line_id","type":"`string`","description":"The ID of the line item to update.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[StorePostCartsCartLineItemsItemReq](../../../medusa/classes/medusa.StorePostCartsCartLineItemsItemReq/page.mdx)","description":"The data to update in the line item.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"quantity","type":"`number`","description":"The quantity of the line item in the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`Record<string, unknown>`","description":"An optional key-value map with additional details about the Line Item. If omitted, the metadata will remain unchanged.\"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the associated cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"[StoreCartsRes](../../../medusa/types/medusa.StoreCartsRes/page.mdx)","optional":false,"defaultValue":"","description":"The cart's details.","expandable":false,"children":[{"name":"cart","type":"Omit&#60;Cart, \"refundable_amount\" \\| \"refunded_total\"&#62;","description":"Cart details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customer_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"sales_channel_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"items","type":"Collection&#60;[LineItem](../../../cart_models/classes/cart_models.LineItem/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_methods","type":"Collection&#60;[ShippingMethod](../../../cart_models/classes/cart_models.ShippingMethod/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`OptionalCartProps`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete a line item from a cart. The payment sessions will be updated and the totals will be recalculated.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.lineItems.delete(cartId, lineId)
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The ID of the line item's cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"line_id","type":"`string`","description":"The ID of the line item to delete.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the associated cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"[StoreCartsRes](../../../medusa/types/medusa.StoreCartsRes/page.mdx)","optional":false,"defaultValue":"","description":"The cart's details.","expandable":false,"children":[{"name":"cart","type":"Omit&#60;Cart, \"refundable_amount\" \\| \"refunded_total\"&#62;","description":"Cart details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"customer_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"sales_channel_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"email","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"billing_address","type":"`null` \\| [Address](../../../cart_models/classes/cart_models.Address/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"items","type":"Collection&#60;[LineItem](../../../cart_models/classes/cart_models.LineItem/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_methods","type":"Collection&#60;[ShippingMethod](../../../cart_models/classes/cart_models.ShippingMethod/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`OptionalCartProps`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
@@ -0,0 +1,86 @@
---
slug: /references/js-client/OrderEditsResource
---
import { TypeList } from "docs-ui"
# OrderEditsResource
This class is used to send requests to [Store Order Edits API Routes](https://docs.medusajs.com/api/store#order-edits). All its method
are available in the JS Client under the `medusa.orderEdits` property.
Order edits are changes made to items in an order such as adding, updating their quantity, or deleting them. Order edits are created by the admin.
A customer can review order edit requests created by an admin and confirm or decline them.
Related Guide: [How to handle order edits in a storefront](https://docs.medusajs.com/modules/orders/storefront/handle-order-edits).
## Methods
### retrieve
Retrieve an Order Edit's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.orderEdits.retrieve(orderEditId)
.then(({ order_edit }) => {
console.log(order_edit.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order edit.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreOrderEditsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order edit's details.","expandable":false,"children":[{"name":"StoreOrderEditsRes","type":"[StoreOrderEditsRes](../../../medusa/types/medusa.StoreOrderEditsRes/page.mdx)","optional":false,"defaultValue":"","description":"The order edit's details.","expandable":false,"children":[{"name":"order_edit","type":"Omit&#60;OrderEdit, \"internal_note\" \\| \"created_by\" \\| \"confirmed_by\" \\| \"canceled_by\"&#62;","description":"Order edit details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### decline
Decline an Order Edit. The changes are not reflected on the original order.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.orderEdits.decline(orderEditId)
.then(({ order_edit }) => {
console.log(order_edit.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order edit.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[StorePostOrderEditsOrderEditDecline](../../../medusa/classes/medusa.StorePostOrderEditsOrderEditDecline/page.mdx)","description":"The decline details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"declined_reason","type":"`string`","description":"The reason for declining the Order Edit.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="decline"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreOrderEditsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order edit's details.","expandable":false,"children":[{"name":"StoreOrderEditsRes","type":"[StoreOrderEditsRes](../../../medusa/types/medusa.StoreOrderEditsRes/page.mdx)","optional":false,"defaultValue":"","description":"The order edit's details.","expandable":false,"children":[{"name":"order_edit","type":"Omit&#60;OrderEdit, \"internal_note\" \\| \"created_by\" \\| \"confirmed_by\" \\| \"canceled_by\"&#62;","description":"Order edit details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="decline"/>
### complete
Complete and confirm an Order Edit and reflect its changes on the original order. Any additional payment required must be authorized first using the [PaymentCollectionsResource](../js_client.PaymentCollectionsResource/page.mdx) routes.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.orderEdits.complete(orderEditId)
.then(({ order_edit }) => {
console.log(order_edit.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order edit.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="complete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreOrderEditsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order edit's details.","expandable":false,"children":[{"name":"StoreOrderEditsRes","type":"[StoreOrderEditsRes](../../../medusa/types/medusa.StoreOrderEditsRes/page.mdx)","optional":false,"defaultValue":"","description":"The order edit's details.","expandable":false,"children":[{"name":"order_edit","type":"Omit&#60;OrderEdit, \"internal_note\" \\| \"created_by\" \\| \"confirmed_by\" \\| \"canceled_by\"&#62;","description":"Order edit details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="complete"/>
@@ -0,0 +1,149 @@
---
slug: /references/js-client/OrdersResource
---
import { TypeList } from "docs-ui"
# OrdersResource
This class is used to send requests to [Store Order API Routes](https://docs.medusajs.com/api/store#orders). All its method
are available in the JS Client under the `medusa.orders` property.
Orders are purchases made by customers, typically through a storefront.
Orders are placed and created using [CartsResource](../js_client.CartsResource/page.mdx). The methods in this class allow retrieving and claiming orders.
Related Guide: [How to retrieve order details in a storefront](https://docs.medusajs.com/modules/orders/storefront/retrieve-order-details).
## Methods
### retrieve
Retrieve an Order's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.orders.retrieve(orderId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the order.","expandable":false,"children":[{"name":"StoreOrdersRes","type":"[StoreOrdersRes](../../../medusa/types/medusa.StoreOrdersRes/page.mdx)","optional":false,"defaultValue":"","description":"The order's details.","expandable":false,"children":[{"name":"order","type":"[Order](../../../types/types/types.Order/page.mdx)","description":"Order details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### retrieveByCartId
Retrieve an order's details by the ID of the cart that was used to create the order.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.orders.retrieveByCartId(cartId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieveByCartId"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the order.","expandable":false,"children":[{"name":"StoreOrdersRes","type":"[StoreOrdersRes](../../../medusa/types/medusa.StoreOrdersRes/page.mdx)","optional":false,"defaultValue":"","description":"The order's details.","expandable":false,"children":[{"name":"order","type":"[Order](../../../types/types/types.Order/page.mdx)","description":"Order details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieveByCartId"/>
### lookupOrder
Look up an order using filters. If the filters don't narrow down the results to a single order, a `404` response is returned with no orders.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.orders.lookupOrder({
display_id: 1,
email: "user@example.com"
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[StoreGetOrdersParams](../../../medusa/classes/medusa.StoreGetOrdersParams/page.mdx)","description":"Filters used to retrieve the order.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"display_id","type":"`number`","description":"Display ID of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"email","type":"`string`","description":"Email of the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_address","type":"[ShippingAddressPayload](../../../medusa/classes/medusa.ShippingAddressPayload/page.mdx)","description":"Filter the retrieved order by its shipping address details.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"postal_code","type":"`string`","description":"Postal code.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="lookupOrder"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the order.","expandable":false,"children":[{"name":"StoreOrdersRes","type":"[StoreOrdersRes](../../../medusa/types/medusa.StoreOrdersRes/page.mdx)","optional":false,"defaultValue":"","description":"The order's details.","expandable":false,"children":[{"name":"order","type":"[Order](../../../types/types/types.Order/page.mdx)","description":"Order details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="lookupOrder"/>
### requestCustomerOrders
Allow the logged-in customer to claim ownership of one or more orders. This generates a token that can be used later on to verify the claim using the [confirmRequest](page.mdx#confirmrequest) method.
This also emits the event `order-update-token.created`. So, if you have a notification provider installed that handles this event and sends the customer a notification, such as an email,
the customer should receive instructions on how to finalize their claim ownership.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.orders.requestCustomerOrders({
order_ids,
})
.then(() => {
// successful
})
.catch(() => {
// an error occurred
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[StorePostCustomersCustomerOrderClaimReq](../../../medusa/classes/medusa.StorePostCustomersCustomerOrderClaimReq/page.mdx)","description":"The orders to claim.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"order_ids","type":"`string`[]","description":"The ID of the orders to claim","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="requestCustomerOrders"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"`ResponsePromise`","optional":false,"defaultValue":"","description":"Resolves when the request is created successfully.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="requestCustomerOrders"/>
### confirmRequest
Verify the claim order token provided to the customer when they request ownership of an order.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.orders.confirmRequest(
token,
)
.then(() => {
// successful
})
.catch(() => {
// an error occurred
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[StorePostCustomersCustomerAcceptClaimReq](../../../medusa/classes/medusa.StorePostCustomersCustomerAcceptClaimReq/page.mdx)","description":"The claim order to verify.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"token","type":"`string`","description":"The claim token generated by previous request to the Claim Order API Route.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="confirmRequest"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"`ResponsePromise`","optional":false,"defaultValue":"","description":"Resolves when the claim order is verified successfully.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="confirmRequest"/>
@@ -0,0 +1,207 @@
---
slug: /references/js-client/PaymentCollectionsResource
---
import { TypeList } from "docs-ui"
# PaymentCollectionsResource
This class is used to send requests to [Store Payment Collection API Routes](https://docs.medusajs.com/api/store#payment-collections). All its method
are available in the JS Client under the `medusa.paymentCollections` property.
A payment collection is useful for managing additional payments, such as for Order Edits, or installment payments.
## Methods
### retrieve
Retrieve a Payment Collection's details.
#### Example
A simple example that retrieves a payment collection by its ID:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.paymentCollections.retrieve(paymentCollectionId)
.then(({ payment_collection }) => {
console.log(payment_collection.id)
})
```
To specify relations that should be retrieved:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.paymentCollections.retrieve(paymentCollectionId, {
expand: "region"
})
.then(({ payment_collection }) => {
console.log(payment_collection.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[StoreGetPaymentCollectionsParams](../../../medusa/classes/medusa.StoreGetPaymentCollectionsParams/page.mdx)","description":"Configurations to apply on the retrieved payment collection.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StorePaymentCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the payment collection's details.","expandable":false,"children":[{"name":"StorePaymentCollectionsRes","type":"[StorePaymentCollectionsRes](../../../medusa/types/medusa.StorePaymentCollectionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The payment collection's details.","expandable":false,"children":[{"name":"payment_collection","type":"[PaymentCollection](../../../payment_models/classes/payment_models.PaymentCollection/page.mdx)","description":"Payment collection's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"region_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"completed_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"status","type":"[PaymentCollectionStatus](../../../utils/enums/utils.PaymentCollectionStatus/page.mdx)","description":"","optional":false,"defaultValue":"PaymentCollectionStatus.NOT_PAID","expandable":false,"children":[{"name":"NOT_PAID","type":"`\"not_paid\"`","description":"The payment collection isn't paid.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"AWAITING","type":"`\"awaiting\"`","description":"The payment collection is awaiting payment.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"AUTHORIZED","type":"`\"authorized\"`","description":"The payment collection is authorized.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PARTIALLY_AUTHORIZED","type":"`\"partially_authorized\"`","description":"Some of the payments in the payment collection are authorized.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"CANCELED","type":"`\"canceled\"`","description":"The payment collection is canceled.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"payment_providers","type":"Collection&#60;[PaymentProvider](../../../payment_models/classes/payment_models.PaymentProvider/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_enabled","type":"`boolean`","description":"","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`\"is_enabled\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"payment_sessions","type":"Collection&#60;[PaymentSession](../../../payment_models/classes/payment_models.PaymentSession/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`Record<string, unknown>`","description":"","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"context","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defauLine truncated
### authorizePaymentSession
Authorize a Payment Session of a Payment Collection.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.paymentCollections.authorize(paymentId, sessionId)
.then(({ payment_collection }) => {
console.log(payment_collection.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"session_id","type":"`string`","description":"The ID of the payment session.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="authorizePaymentSession"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StorePaymentCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the payment collection's details.","expandable":false,"children":[{"name":"StorePaymentCollectionsRes","type":"[StorePaymentCollectionsRes](../../../medusa/types/medusa.StorePaymentCollectionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The payment collection's details.","expandable":false,"children":[{"name":"payment_collection","type":"[PaymentCollection](../../../payment_models/classes/payment_models.PaymentCollection/page.mdx)","description":"Payment collection's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"region_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"completed_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"status","type":"[PaymentCollectionStatus](../../../utils/enums/utils.PaymentCollectionStatus/page.mdx)","description":"","optional":false,"defaultValue":"PaymentCollectionStatus.NOT_PAID","expandable":false,"children":[{"name":"NOT_PAID","type":"`\"not_paid\"`","description":"The payment collection isn't paid.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"AWAITING","type":"`\"awaiting\"`","description":"The payment collection is awaiting payment.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"AUTHORIZED","type":"`\"authorized\"`","description":"The payment collection is authorized.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PARTIALLY_AUTHORIZED","type":"`\"partially_authorized\"`","description":"Some of the payments in the payment collection are authorized.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"CANCELED","type":"`\"canceled\"`","description":"The payment collection is canceled.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"payment_providers","type":"Collection&#60;[PaymentProvider](../../../payment_models/classes/payment_models.PaymentProvider/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_enabled","type":"`boolean`","description":"","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`\"is_enabled\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"payment_sessions","type":"Collection&#60;[PaymentSession](../../../payment_models/classes/payment_models.PaymentSession/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`Record<string, unknown>`","description":"","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"context","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defauLine truncated
### authorizePaymentSessionsBatch
Authorize the Payment Sessions of a Payment Collection.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.paymentCollections.authorizePaymentSessionsBatch(paymentCollectionId, {
session_ids: ["ps_123456"]
})
.then(({ payment_collection }) => {
console.log(payment_collection.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[StorePostPaymentCollectionsBatchSessionsAuthorizeReq](../../../medusa/classes/medusa.StorePostPaymentCollectionsBatchSessionsAuthorizeReq/page.mdx)","description":"The list of payment session IDs to authorize.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"session_ids","type":"`string`[]","description":"List of Payment Session IDs to authorize.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="authorizePaymentSessionsBatch"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StorePaymentCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the payment collection's details.","expandable":false,"children":[{"name":"StorePaymentCollectionsRes","type":"[StorePaymentCollectionsRes](../../../medusa/types/medusa.StorePaymentCollectionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The payment collection's details.","expandable":false,"children":[{"name":"payment_collection","type":"[PaymentCollection](../../../payment_models/classes/payment_models.PaymentCollection/page.mdx)","description":"Payment collection's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"region_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"completed_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"status","type":"[PaymentCollectionStatus](../../../utils/enums/utils.PaymentCollectionStatus/page.mdx)","description":"","optional":false,"defaultValue":"PaymentCollectionStatus.NOT_PAID","expandable":false,"children":[{"name":"NOT_PAID","type":"`\"not_paid\"`","description":"The payment collection isn't paid.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"AWAITING","type":"`\"awaiting\"`","description":"The payment collection is awaiting payment.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"AUTHORIZED","type":"`\"authorized\"`","description":"The payment collection is authorized.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PARTIALLY_AUTHORIZED","type":"`\"partially_authorized\"`","description":"Some of the payments in the payment collection are authorized.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"CANCELED","type":"`\"canceled\"`","description":"The payment collection is canceled.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"payment_providers","type":"Collection&#60;[PaymentProvider](../../../payment_models/classes/payment_models.PaymentProvider/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_enabled","type":"`boolean`","description":"","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`\"is_enabled\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"payment_sessions","type":"Collection&#60;[PaymentSession](../../../payment_models/classes/payment_models.PaymentSession/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`Record<string, unknown>`","description":"","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"context","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defauLine truncated
### managePaymentSessionsBatch
Create, update, or delete a list of payment sessions of a Payment Collections. If a payment session is not provided in the `sessions` array, it's deleted.
#### Example
To add two new payment sessions:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
// Total amount = 10000
medusa.paymentCollections.managePaymentSessionsBatch(paymentId, {
sessions: [
{
provider_id: "stripe",
amount: 5000,
},
{
provider_id: "manual",
amount: 5000,
},
]
})
.then(({ payment_collection }) => {
console.log(payment_collection.id);
})
```
To update a payment session and another one by not including it in the payload:
```ts
medusa.paymentCollections.managePaymentSessionsBatch(paymentId, {
sessions: [
{
provider_id: "stripe",
amount: 10000,
session_id: "ps_123456"
},
]
})
.then(({ payment_collection }) => {
console.log(payment_collection.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[StorePostPaymentCollectionsBatchSessionsReq](../../../medusa/classes/medusa.StorePostPaymentCollectionsBatchSessionsReq/page.mdx)","description":"The attributes of each session to update.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"sessions","type":"[StorePostPaymentCollectionsSessionsReq](../../../medusa/classes/medusa.StorePostPaymentCollectionsSessionsReq/page.mdx)[]","description":"Payment sessions related to the Payment Collection. Existing sessions that are not added in this array will be deleted.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"provider_id","type":"`string`","description":"The ID of the Payment Provider.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number`","description":"The payment amount","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"session_id","type":"`string`","description":"The ID of the Payment Session to be updated. If no ID is provided, a new payment session is created.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="managePaymentSessionsBatch"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StorePaymentCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the payment collection's details.","expandable":false,"children":[{"name":"StorePaymentCollectionsRes","type":"[StorePaymentCollectionsRes](../../../medusa/types/medusa.StorePaymentCollectionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The payment collection's details.","expandable":false,"children":[{"name":"payment_collection","type":"[PaymentCollection](../../../payment_models/classes/payment_models.PaymentCollection/page.mdx)","description":"Payment collection's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"region_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"completed_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"status","type":"[PaymentCollectionStatus](../../../utils/enums/utils.PaymentCollectionStatus/page.mdx)","description":"","optional":false,"defaultValue":"PaymentCollectionStatus.NOT_PAID","expandable":false,"children":[{"name":"NOT_PAID","type":"`\"not_paid\"`","description":"The payment collection isn't paid.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"AWAITING","type":"`\"awaiting\"`","description":"The payment collection is awaiting payment.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"AUTHORIZED","type":"`\"authorized\"`","description":"The payment collection is authorized.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PARTIALLY_AUTHORIZED","type":"`\"partially_authorized\"`","description":"Some of the payments in the payment collection are authorized.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"CANCELED","type":"`\"canceled\"`","description":"The payment collection is canceled.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"payment_providers","type":"Collection&#60;[PaymentProvider](../../../payment_models/classes/payment_models.PaymentProvider/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_enabled","type":"`boolean`","description":"","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`\"is_enabled\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"payment_sessions","type":"Collection&#60;[PaymentSession](../../../payment_models/classes/payment_models.PaymentSession/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`Record<string, unknown>`","description":"","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"context","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defauLine truncated
### managePaymentSession
Create a Payment Session for a payment provider in a Payment Collection.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.paymentCollections.managePaymentSession(payment_id, { provider_id: "stripe" })
.then(({ payment_collection }) => {
console.log(payment_collection.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"[StorePaymentCollectionSessionsReq](../../../medusa/classes/medusa.StorePaymentCollectionSessionsReq/page.mdx)","description":"The payment session to create.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"provider_id","type":"`string`","description":"The ID of the Payment Provider.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="managePaymentSession"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StorePaymentCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the payment collection's details.","expandable":false,"children":[{"name":"StorePaymentCollectionsRes","type":"[StorePaymentCollectionsRes](../../../medusa/types/medusa.StorePaymentCollectionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The payment collection's details.","expandable":false,"children":[{"name":"payment_collection","type":"[PaymentCollection](../../../payment_models/classes/payment_models.PaymentCollection/page.mdx)","description":"Payment collection's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"region_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"completed_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"status","type":"[PaymentCollectionStatus](../../../utils/enums/utils.PaymentCollectionStatus/page.mdx)","description":"","optional":false,"defaultValue":"PaymentCollectionStatus.NOT_PAID","expandable":false,"children":[{"name":"NOT_PAID","type":"`\"not_paid\"`","description":"The payment collection isn't paid.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"AWAITING","type":"`\"awaiting\"`","description":"The payment collection is awaiting payment.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"AUTHORIZED","type":"`\"authorized\"`","description":"The payment collection is authorized.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PARTIALLY_AUTHORIZED","type":"`\"partially_authorized\"`","description":"Some of the payments in the payment collection are authorized.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"CANCELED","type":"`\"canceled\"`","description":"The payment collection is canceled.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"payment_providers","type":"Collection&#60;[PaymentProvider](../../../payment_models/classes/payment_models.PaymentProvider/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_enabled","type":"`boolean`","description":"","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`\"is_enabled\"`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"payment_sessions","type":"Collection&#60;[PaymentSession](../../../payment_models/classes/payment_models.PaymentSession/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`Record<string, unknown>`","description":"","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"context","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defauLine truncated
### refreshPaymentSession
Refresh a Payment Session's data to ensure that it is in sync with the Payment Collection.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.paymentCollections.refreshPaymentSession(paymentCollectionId, sessionId)
.then(({ payment_session }) => {
console.log(payment_session.status);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"session_id","type":"`string`","description":"The ID of the payment session.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="refreshPaymentSession"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StorePaymentCollectionsSessionRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the refreshed payment session's details.","expandable":false,"children":[{"name":"StorePaymentCollectionsSessionRes","type":"[StorePaymentCollectionsSessionRes](../../../medusa/types/medusa.StorePaymentCollectionsSessionRes/page.mdx)","optional":false,"defaultValue":"","description":"The details of the payment session.","expandable":false,"children":[{"name":"payment_session","type":"[PaymentSession](../../../payment_models/classes/payment_models.PaymentSession/page.mdx)","description":"Payment session's details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"value","type":"`string` \\| `number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"provider_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`Record<string, unknown>`","description":"","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"context","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[PaymentSessionStatus](../../../utils/enums/utils.PaymentSessionStatus/page.mdx)","description":"","optional":false,"defaultValue":"PaymentSessionStatus.PENDING","expandable":false,"children":[{"name":"AUTHORIZED","type":"`\"authorized\"`","description":"The payment is authorized.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"PENDING","type":"`\"pending\"`","description":"The payment is pending.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"REQUIRES_MORE","type":"`\"requires_more\"`","description":"The payment requires an action.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"ERROR","type":"`\"error\"`","description":"An error occurred while processing the payment.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"CANCELED","type":"`\"canceled\"`","description":"The payment is canceled.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"authorized_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"payment_collection","type":"[PaymentCollection](../../../payment_models/classes/payment_models.PaymentCollection/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"amount","type":"`number` \\| `BigNumber`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"raw_amount","type":"[BigNumberRawValue](../../../types/types/types.BigNumberRawValue/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"completed_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"status","type":"[PaymentCollectionStatus](../../../utils/enums/utils.PaymentCollectionStatus/page.mdx)","description":"","optional":false,"defaultValue":"PaymentCollectionStatus.NOT_PAID","expandable":false,"children":[]},{"name":"payment_providers","type":"Collection&#60;[PaymentProvider](../../../payment_models/classes/payment_models.PaymentProvider/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payment_sessions","type":"Collection&#60;[PLine truncated
@@ -0,0 +1,39 @@
---
slug: /references/js-client/PaymentMethodsResource
---
import { TypeList } from "docs-ui"
# PaymentMethodsResource
This class is used to send requests to Payment Method API Routes part of the [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.paymentMethods` property.
All methods in this class require [authentication](../../../modules/customer/page.mdx).
## Methods
### list
Retrieve the logged-in customer's saved payment methods. This method only works with payment providers created with the deprecated Payment Service interface.
The payment methods are saved using the Payment Service's third-party service, and not on the Medusa backend. So, they're retrieved from the third-party service.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged
medusa.customers.paymentMethods.list()
.then(({ payment_methods }) => {
console.log(payment_methods.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCustomersListPaymentMethodsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer's payment methods.","expandable":false,"children":[{"name":"StoreCustomersListPaymentMethodsRes","type":"[StoreCustomersListPaymentMethodsRes](../../../medusa/types/medusa.StoreCustomersListPaymentMethodsRes/page.mdx)","optional":false,"defaultValue":"","description":"The payment method's details.","expandable":false,"children":[{"name":"payment_methods","type":"`object`[]","description":"The details of the saved payment methods.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"provider_id","type":"`string`","description":"The ID of the Payment Provider where the payment method is saved.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`object`","description":"The data needed for the Payment Provider to use the saved payment method.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
@@ -0,0 +1,133 @@
---
slug: /references/js-client/ProductCategoriesResource
---
import { TypeList } from "docs-ui"
# ProductCategoriesResource
:::note
To use this resource, make sure to [enable its feature flag: product_categories](https://docs.medusajs.com/development/feature-flags/toggle)
:::
This class is used to send requests to [Store Product Category API Routes](https://docs.medusajs.com/api/store#product-categories\_getproductcategories). All its method
are available in the JS Client under the `medusa.productCategories` property.
Products can be categoriezed into categories. A product can be associated more than one category.
Using the methods in this class, you can list or retrieve a category's details and products.
Related Guide: [How to use product categories in a storefront](https://docs.medusajs.com/modules/products/storefront/use-categories).
## Methods
### retrieve
Retrieve a Product Category's details.
#### Example
A simple example that retrieves a product category by its ID:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.productCategories.retrieve(productCategoryId)
.then(({ product_category }) => {
console.log(product_category.id);
})
```
To specify relations that should be retrieved:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.productCategories.retrieve(productCategoryId, {
expand: "products"
})
.then(({ product_category }) => {
console.log(product_category.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product category.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[StoreGetProductCategoriesCategoryParams](../../../medusa/classes/medusa.StoreGetProductCategoriesCategoryParams/page.mdx)","description":"Configurations to apply on the retrieved product categories.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreGetProductCategoriesCategoryRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product category's details.","expandable":false,"children":[{"name":"StoreGetProductCategoriesCategoryRes","type":"[StoreGetProductCategoriesCategoryRes](../../../medusa/types/medusa.StoreGetProductCategoriesCategoryRes/page.mdx)","optional":false,"defaultValue":"","description":"The product category's details.","expandable":false,"children":[{"name":"product_category","type":"[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx)","description":"Product category details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"category_children","type":"Collection&#60;[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"category_children","type":"Collection&#60;[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"Collection&#60;[Product](../../../product_models/classes/product_models.Product/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"mpath","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_active","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_internal","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rank","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"parent_category_id","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"parent_category","type":"[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"products","type":"Collection&#60;[Product](../../../product_models/classes/product_models.Product/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection","type":"`null` \\| [ProductCollection](../../../product_models/classes/product_models.ProductCollection/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]Line truncated
### list
Retrieve a list of product categories. The product categories can be filtered by fields such as `handle` or `q` passed in the `query` parameter.
The product categories can also be paginated. This method can also be used to retrieve a product category by its handle.
#### Example
To list product categories:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.productCategories.list()
.then(({ product_categories, limit, offset, count }) => {
console.log(product_categories.length);
})
```
To retrieve a product category by its handle:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.productCategories.list({
handle: "women",
})
.then(({ product_categories, limit, offset, count }) => {
if (!product_categories.length) {
// category does not exist
}
const category = product_categories[0]
})
```
To specify relations that should be retrieved within the product categories:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.productCategories.list({
expand: "products"
})
.then(({ product_categories, limit, offset, count }) => {
console.log(product_categories.length);
})
```
By default, only the first `100` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.productCategories.list({
expand: "products",
limit,
offset
})
.then(({ product_categories, limit, offset, count }) => {
console.log(product_categories.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[StoreGetProductCategoriesParams](../../../medusa/classes/medusa.StoreGetProductCategoriesParams/page.mdx)","description":"Filters and pagination configurations to apply on the retrieved product categories.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"Search term to search product categories' names and handles.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"Handle to filter product categories by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"parent_category_id","type":"`null` \\| `string`","description":"Filter product categories by the ID of their associated parent category.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"include_descendants_tree","type":"`boolean`","description":"Whether to include child categories in the retrieved categories.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"Limit the number of product categories returned in the list. Default is `100`.","optional":true,"defaultValue":"20","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreGetProductCategoriesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of product categories with pagination fields.","expandable":false,"children":[{"name":"StoreGetProductCategoriesRes","type":"[StoreGetProductCategoriesRes](../../../medusa/types/medusa.StoreGetProductCategoriesRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of product categories with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_categories","type":"[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx)[]","description":"An array of product categories details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"category_children","type":"Collection&#60;[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"category_children","type":"Collection&#60;[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"Collection&#60;[Product](../../../product_models/classes/product_models.Product/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"mpath","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_active","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_internal","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"rank","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"parent_category_id","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"parent_category","type":"[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"products","type":"Collection&#60;[Product](../../../product_models/classes/product_models.Product/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optiLine truncated
@@ -0,0 +1,54 @@
---
slug: /references/js-client/ProductTagsResource
---
import { TypeList } from "docs-ui"
# ProductTagsResource
This class is used to send requests to [Store Product Tag API Routes](https://docs.medusajs.com/api/store#product-tags). All its method
are available in the JS Client under the `medusa.productTags` property.
Product tags are string values that can be used to filter products by.
Products can have more than one tag, and products can share tags.
## Methods
### list
Retrieve a list of product tags. The product tags can be filtered by fields such as `id` or `q` passed in the `query` parameter. The product tags can also be sorted or paginated.
#### Example
To list product tags:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.productTags.list()
.then(({ product_tags }) => {
console.log(product_tags.length);
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.productTags.list({
limit,
offset
})
.then(({ product_tags }) => {
console.log(product_tags.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[StoreGetProductTagsParams](../../../medusa/classes/medusa.StoreGetProductTagsParams/page.mdx)","description":"Filters and pagination configurations to apply on the retrieved product tags.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string` \\| `string`[] \\| [StringComparisonOperator](../../../medusa/classes/medusa.StringComparisonOperator/page.mdx)","description":"IDs to filter product tags by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"q","type":"`string`","description":"Search term to search product tags' values.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string` \\| `string`[] \\| [StringComparisonOperator](../../../medusa/classes/medusa.StringComparisonOperator/page.mdx)","description":"Values to filter product tags by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply to the product tags' `created_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"updated_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply to the product tags' `updated_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_condition_id","type":"`string`","description":"Filter product tags by the ID of their associated discount condition.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":true,"defaultValue":"20","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreProductTagsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of product tags with pagination fields.","expandable":false,"children":[{"name":"StoreProductTagsListRes","type":"[StoreProductTagsListRes](../../../medusa/types/medusa.StoreProductTagsListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of product tags with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_tags","type":"[ProductTag](../../../product_models/classes/product_models.ProductTag/page.mdx)[]","description":"An array of product tags details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"Collection&#60;[Product](../../../product_models/classes/product_models.Product/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"status","type":"[ProductStatus](../../../utils/ProductUtils/enums/utils.ProductUtils.ProductStatus/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"Collection&#60;[ProductOption](../../../product_models/classes/product_models.ProductOption/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variants","type":"Collection&#60;[ProductVariant](../../../product_models/classes/product_models.ProductVariant/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"collection","type":"`null` \\| [ProductCollection](../../../product_models/classes/product_models.ProductCollection/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type_id","type":"`null` \\| `string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`null` \\| [ProductType](../../../product_models/classes/product_models.ProductType/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"tags","type":"Collection&#60;[ProductTag](../../../product_models/classes/product_models.ProductTag/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"images","type":"Collection&#60;[Image](../../../product_models/classes/product_models.Image/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"categories","type":"Collection&#60;[ProductCategory](../../../product_models/classes/product_models.ProductCategory/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"discountable","type":"`boolean`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"subtitle","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description"Line truncated
@@ -0,0 +1,56 @@
---
slug: /references/js-client/ProductTypesResource
---
import { TypeList } from "docs-ui"
# ProductTypesResource
This class is used to send requests to [Store Product Type API Routes](https://docs.medusajs.com/api/store#product-types). All its method
are available in the JS Client under the `medusa.productTypes` property.
Product types are string values that can be used to filter products by.
Products can have more than one tag, and products can share types.
## Methods
### list
Retrieve a list of product types. The product types can be filtered by fields such as `value` or `q` passed in the `query` parameter. The product types can also be sorted or paginated.
#### Example
To list product types:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.productTypes.list()
.then(({ product_types }) => {
console.log(product_types.length);
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.productTypes.list({
limit,
offset
})
.then(({ product_types }) => {
console.log(product_types.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[StoreGetProductTypesParams](../../../medusa/classes/medusa.StoreGetProductTypesParams/page.mdx)","description":"Filters and pagination configurations to apply on retrieved product types.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string` \\| `string`[] \\| [StringComparisonOperator](../../../medusa/classes/medusa.StringComparisonOperator/page.mdx)","description":"IDs to filter product types by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"q","type":"`string`","description":"Search term to search product types' values.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string` \\| `string`[] \\| [StringComparisonOperator](../../../medusa/classes/medusa.StringComparisonOperator/page.mdx)","description":"Values to filter product types by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the product types' `created_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"updated_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the product types' `updated_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"discount_condition_id","type":"`string`","description":"Filter product types by the ID of their associated discount condition.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":true,"defaultValue":"20","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreProductTypesListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of product types with pagination fields.","expandable":false,"children":[{"name":"StoreProductTypesListRes","type":"[StoreProductTypesListRes](../../../medusa/types/medusa.StoreProductTypesListRes/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"product_types","type":"[ProductType](../../../product_models/classes/product_models.ProductType/page.mdx)[]","description":"An array of product types details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"value","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`Date`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
@@ -0,0 +1,104 @@
---
slug: /references/js-client/ProductVariantsResource
---
import { TypeList } from "docs-ui"
# ProductVariantsResource
This class is used to send requests to [Store Product Variant API Routes](https://docs.medusajs.com/api/store#product-variants). All its method
are available in the JS Client under the `medusa.product.variants` property.
Product variants are the actual salable item in your store. Each variant is a combination of the different option values available on the product.
## Methods
### retrieve
Retrieve a Product Variant's details. For accurate and correct pricing of the product variant based on the customer's context, it's highly recommended to pass fields such as
`region_id`, `currency_code`, and `cart_id` when available.
Passing `sales_channel_id` ensures retrieving only variants of products available in the current sales channel.
You can alternatively use a publishable API key in the request header instead of passing a `sales_channel_id`.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.product.variants.retrieve(productVariantId)
.then(({ variant }) => {
console.log(variant.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreVariantsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product variant's details.","expandable":false,"children":[{"name":"StoreVariantsRes","type":"[StoreVariantsRes](../../../medusa/types/medusa.StoreVariantsRes/page.mdx)","optional":false,"defaultValue":"","description":"The product variant's details.","expandable":false,"children":[{"name":"variant","type":"[PricedVariant](../../../medusa/types/medusa.PricedVariant/page.mdx)","description":"Product variant description.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieves a list of product variants. The product variants can be filtered by fields such as `id` or `title` passed in the `query` parameter. The product variants can also be paginated.
For accurate and correct pricing of the product variants based on the customer's context, it's highly recommended to pass fields such as
`region_id`, `currency_code`, and `cart_id` when available.
Passing `sales_channel_id` ensures retrieving only variants of products available in the specified sales channel.
You can alternatively use a publishable API key in the request header instead of passing a `sales_channel_id`.
#### Example
To list product variants:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.product.variants.list()
.then(({ variants }) => {
console.log(variants.length);
})
```
To specify relations that should be retrieved within the product variants:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.product.variants.list({
expand: "product"
})
.then(({ variants }) => {
console.log(variants.length);
})
```
By default, only the first `100` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.product.variants.list({
expand: "product",
limit,
offset
})
.then(({ variants }) => {
console.log(variants.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[StoreGetVariantsParams](../../../medusa/classes/medusa.StoreGetVariantsParams/page.mdx)","description":"Filters and pagination configurations applied on the retrieved product variants.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":true,"defaultValue":"100","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]},{"name":"ids","type":"`string`","description":"ID to filter the product variants by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"sales_channel_id","type":"`string`","description":"Filter product variants by the ID of their associated sales channel.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"IDs to filter product variants by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string` \\| `string`[]","description":"Titles to filter product variants by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"inventory_quantity","type":"`number` \\| [NumericalComparisonOperator](../../../medusa/classes/medusa.NumericalComparisonOperator/page.mdx)","description":"Number filters to apply on the product variants' `inventory_quantity` field.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"expand","type":"`string`","description":"Comma-separated relations that should be expanded in the returned data.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"fields","type":"`string`","description":"Comma-separated fields that should be included in the returned data.\nif a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields.\nwithout prefix it will replace the entire default fields.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"cart_id","type":"`string`","description":"Retrieve prices for a cart ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`string`","description":"Retrieve prices for a region ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"Retrieve prices for a currency code.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreVariantsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of product variants.","expandable":false,"children":[{"name":"StoreVariantsListRes","type":"[StoreVariantsListRes](../../../medusa/types/medusa.StoreVariantsListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of product variants.","expandable":false,"children":[{"name":"variants","type":"[PricedVariant](../../../medusa/types/medusa.PricedVariant/page.mdx)[]","description":"An array of product variant descriptions.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
@@ -0,0 +1,136 @@
---
slug: /references/js-client/ProductsResource
---
import { TypeList } from "docs-ui"
# ProductsResource
This class is used to send requests to [Store Product API Routes](https://docs.medusajs.com/api/store#products). All its method
are available in the JS Client under the `medusa.products` property.
Products are saleable items in a store. This also includes [saleable gift cards](https://docs.medusajs.com/modules/gift-cards/storefront/use-gift-cards) in a store.
Using the methods in this class, you can filter products by categories, collections, sales channels, and more.
Related Guide: [How to show products in a storefront](https://docs.medusajs.com/modules/products/storefront/show-products).
## Properties
<TypeList types={[{"name":"variants","type":"[ProductVariantsResource](../js_client.ProductVariantsResource/page.mdx)","description":"An instance of [ProductVariantsResource](../js_client.ProductVariantsResource/page.mdx) used to send requests to [Store Product Variant API Routes](https://docs.medusajs.com/api/store#product-variants\\_getvariants).","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="ProductsResource"/>
___
## Methods
### retrieve
Retrieve a Product's details. For accurate and correct pricing of the product based on the customer's context, it's highly recommended to pass fields such as
`region_id`, `currency_code`, and `cart_id` when available.
Passing `sales_channel_id` ensures retrieving only products available in the current sales channel.
You can alternatively use a publishable API key in the request header instead of passing a `sales_channel_id`.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.products.retrieve(productId)
.then(({ product }) => {
console.log(product.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The product's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreProductsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product's details.","expandable":false,"children":[{"name":"StoreProductsRes","type":"[StoreProductsRes](../../../medusa/types/medusa.StoreProductsRes/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"product","type":"[PricedProduct](../../../medusa/types/medusa.PricedProduct/page.mdx)","description":"Product details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"variants","type":"[PricedVariant](../../../medusa/types/medusa.PricedVariant/page.mdx)[]","description":"The product variants and their prices.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### search
Run a search query on products using the search service installed on the Medusa backend. The searching is handled through the search service, so the returned data's
format depends on the search service you're using.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.products.search({
q: "Shirt"
})
.then(({ hits }) => {
console.log(hits.length);
})
```
#### Parameters
<TypeList types={[{"name":"searchOptions","type":"[StorePostSearchReq](../../../medusa/classes/medusa.StorePostSearchReq/page.mdx)","description":"Fields to search products.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"q","type":"`string`","description":"The search query.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of products to skip when retrieving the products.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"Limit the number of products returned.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"filter","type":"`unknown`","description":"Pass filters based on the search service.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="search"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StorePostSearchRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of search results. The format of the items depends on the search engine installed on the Medusa backend.","expandable":false,"children":[{"name":"StorePostSearchRes","type":"[StorePostSearchRes](../../../medusa/types/medusa.StorePostSearchRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of search results.","expandable":false,"children":[{"name":"hits","type":"`unknown`[]","description":"Array of search results. The format of the items depends on the search engine installed on the Medusa backend.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="search"/>
### list
Retrieve a list of products. The products can be filtered by fields such as `id` or `q` passed in the `query` parameter. The products can also be sorted or paginated.
This method can also be used to retrieve a product by its handle.
For accurate and correct pricing of the products based on the customer's context, it's highly recommended to pass fields such as
`region_id`, `currency_code`, and `cart_id` when available.
Passing `sales_channel_id` ensures retrieving only products available in the specified sales channel.
You can alternatively use a publishable API key in the request header instead of passing a `sales_channel_id`.
#### Example
To list products:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.products.list()
.then(({ products, limit, offset, count }) => {
console.log(products.length);
})
```
To specify relations that should be retrieved within the products:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.products.list({
expand: "variants"
})
.then(({ products, limit, offset, count }) => {
console.log(products.length);
})
```
By default, only the first `100` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.products.list({
expand: "variants",
limit,
offset
})
.then(({ products, limit, offset, count }) => {
console.log(products.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[StoreGetProductsParams](../../../medusa/classes/medusa.StoreGetProductsParams/page.mdx)","description":"Filters and pagination configurations to apply on the retrieved products.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"offset","type":"`number`","description":"The number of items to skip when retrieving a list.","optional":true,"defaultValue":"0","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"Limit the number of items returned in the list.","optional":true,"defaultValue":"100","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"id","type":"`string` \\| `string`[]","description":"IDs to filter products by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"q","type":"`string`","description":"Search term to search products' title, description, variants' title and sku, and collections' title.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"collection_id","type":"`string`[]","description":"Filter products by their associated product collection's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"tags","type":"`string`[]","description":"Filter products by their associated tags' value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"title","type":"`string`","description":"Title to filter products by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"description","type":"`string`","description":"Description to filter products by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"handle","type":"`string`","description":"Handle to filter products by.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_giftcard","type":"`boolean`","description":"Filter products by whether they're gift cards.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"type_id","type":"`string`[]","description":"Filter products by their associated product type's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"sales_channel_id","type":"`string`[]","description":"Filter products by their associated sales channels' ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"category_id","type":"`string`[]","description":"Filter products by their associated product category's ID.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"include_category_children","type":"`boolean`","description":"Whether to include product category children in the response.","optional":true,"defaultValue":"","expandable":false,"featureFlag":"product_categories","children":[]},{"name":"created_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the products' `created_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"updated_at","type":"[DateComparisonOperator](../../../medusa/classes/medusa.DateComparisonOperator/page.mdx)","description":"Date filters to apply on the products' `created_at` date.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"lt","type":"`Date`","description":"The filtered date must be less than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gt","type":"`Date`","description":"The filtered date must be greater than this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"gte","type":"`Date`","description":"The filtered date must be greater than or equal to this value.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"lte","type":"`Date`","description":"The filtered date must be less than or equal to tLine truncated
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreProductsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of products with pagination fields.","expandable":false,"children":[{"name":"StoreProductsListRes","type":"[StoreProductsListRes](../../../medusa/types/medusa.StoreProductsListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of products with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The maximum number of items that can be returned in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before the returned items in the list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total number of items available.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"products","type":"[PricedProduct](../../../medusa/types/medusa.PricedProduct/page.mdx)[]","description":"An array of products details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"variants","type":"[PricedVariant](../../../medusa/types/medusa.PricedVariant/page.mdx)[]","description":"The product variants and their prices.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
@@ -0,0 +1,63 @@
---
slug: /references/js-client/RegionsResource
---
import { TypeList } from "docs-ui"
# RegionsResource
This class is used to send requests to [Store Region API Routes](https://docs.medusajs.com/api/store#regions\_getregions). All its method
are available in the JS Client under the `medusa.regions` property.
Regions are different countries or geographical regions that the commerce store serves customers in.
Customers can choose what region they're in, which can be used to change the prices shown based on the region and its currency.
Related Guide: [How to use regions in a storefront](https://docs.medusajs.com/modules/regions-and-currencies/storefront/use-regions).
## Methods
### list
Retrieve a list of regions. This method is useful to show the customer all available regions to choose from.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.regions.list()
.then(({ regions, count, limit, offset }) => {
console.log(regions.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreRegionsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of regions with pagination fields.","expandable":false,"children":[{"name":"StoreRegionsListRes","type":"[StoreRegionsListRes](../../../medusa/types/medusa.StoreRegionsListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of regions with pagination fields.","expandable":false,"children":[{"name":"limit","type":"`number`","description":"The limit applied on the retrieved items.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"The number of items skipped before retrieving the list of items.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"count","type":"`number`","description":"The total count of items.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"regions","type":"[Region](../../../region_models/classes/region_models.Region/page.mdx)[]","description":"An array of regions details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"automatic_taxes","type":"`boolean`","description":"","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"countries","type":"Collection&#60;[Country](../../../region_models/classes/region_models.Country/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"iso_2","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"iso_3","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"num_code","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"null","expandable":false,"children":[]},{"name":"region","type":"`null` \\| [Region](../../../region_models/classes/region_models.Region/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`RegionOptionalProps`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### retrieve
Retrieve a Region's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.regions.retrieve(regionId)
.then(({ region }) => {
console.log(region.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The region's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreRegionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the region's details.","expandable":false,"children":[{"name":"StoreRegionsRes","type":"[StoreRegionsRes](../../../medusa/types/medusa.StoreRegionsRes/page.mdx)","optional":false,"defaultValue":"","description":"The region's details.","expandable":false,"children":[{"name":"region","type":"[Region](../../../region_models/classes/region_models.Region/page.mdx)","description":"Region details.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"currency_code","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"automatic_taxes","type":"`boolean`","description":"","optional":false,"defaultValue":"true","expandable":false,"children":[]},{"name":"countries","type":"Collection&#60;[Country](../../../region_models/classes/region_models.Country/page.mdx), object&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"iso_2","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"iso_3","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"num_code","type":"`number`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"display_name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`null` \\| `string`","description":"","optional":true,"defaultValue":"null","expandable":false,"children":[]},{"name":"region","type":"`null` \\| [Region](../../../region_models/classes/region_models.Region/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"","optional":false,"defaultValue":"null","expandable":false,"children":[]},{"name":"[OptionalProps]","type":"`RegionOptionalProps`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
@@ -0,0 +1,60 @@
---
slug: /references/js-client/ReturnReasonsResource
---
import { TypeList } from "docs-ui"
# ReturnReasonsResource
This class is used to send requests to [Store Return Reason API Routes](https://docs.medusajs.com/api/store#return-reasons). All its method
are available in the JS Client under the `medusa.returnReasons` property.
Return reasons are key-value pairs that are used to specify why an order return is being created.
## Methods
### retrieve
Retrieve a Return Reason's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.returnReasons.retrieve(reasonId)
.then(({ return_reason }) => {
console.log(return_reason.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the return reason.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreReturnReasonsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the return reason's details.","expandable":false,"children":[{"name":"StoreReturnReasonsRes","type":"[StoreReturnReasonsRes](../../../medusa/types/medusa.StoreReturnReasonsRes/page.mdx)","optional":false,"defaultValue":"","description":"The return reason's details.","expandable":false,"children":[{"name":"return_reason","type":"`ReturnReason`","description":"Return reason details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of Return Reasons. This is useful when implementing a Create Return flow in the storefront.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.returnReasons.list()
.then(({ return_reasons }) => {
console.log(return_reasons.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreReturnReasonsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of return reasons.","expandable":false,"children":[{"name":"StoreReturnReasonsListRes","type":"[StoreReturnReasonsListRes](../../../medusa/types/medusa.StoreReturnReasonsListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of return reasons.","expandable":false,"children":[{"name":"return_reasons","type":"`ReturnReason`[]","description":"An array of return reasons details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
@@ -0,0 +1,47 @@
---
slug: /references/js-client/ReturnsResource
---
import { TypeList } from "docs-ui"
# ReturnsResource
This class is used to send requests to [Store Return API Routes](https://docs.medusajs.com/api/store#returns). All its method
are available in the JS Client under the `medusa.returns` property.
A return can be created by a customer to return items in an order.
Related Guide: [How to create a return in a storefront](https://docs.medusajs.com/modules/orders/storefront/create-return).
## Methods
### create
Create a return for an order. If a return shipping method is specified, the return is automatically fulfilled.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.returns.create({
order_id,
items: [
{
item_id,
quantity: 1
}
]
})
.then((data) => {
console.log(data.return.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[StorePostReturnsReq](../../../medusa/classes/medusa.StorePostReturnsReq/page.mdx)","description":"The data of the return to be created.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"order_id","type":"`string`","description":"The ID of the Order to create the return for.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"items","type":"[Item](../../../medusa/classes/medusa.Item-6/page.mdx)[]","description":"The items to include in the return.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"item_id","type":"`string`","description":"The ID of the line item to return.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"`number`","description":"The quantity to return.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reason_id","type":"`string`","description":"The ID of the return reason. Return reasons can be retrieved from the List Return Reasons API Route.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"note","type":"`string`","description":"A note to add to the item returned.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"return_shipping","type":"[ReturnShipping](../../../medusa/classes/medusa.ReturnShipping-3/page.mdx)","description":"The return shipping method used to return the items. If provided, a fulfillment is automatically created for the return.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"option_id","type":"`string`","description":"The ID of the Shipping Option to create the Shipping Method from.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreReturnsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the return's details.","expandable":false,"children":[{"name":"StoreReturnsRes","type":"[StoreReturnsRes](../../../medusa/types/medusa.StoreReturnsRes/page.mdx)","optional":false,"defaultValue":"","description":"The return's details.","expandable":false,"children":[{"name":"return","type":"`Return`","description":"Return details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
@@ -0,0 +1,62 @@
---
slug: /references/js-client/ShippingOptionsResource
---
import { TypeList } from "docs-ui"
# ShippingOptionsResource
This class is used to send requests to [Store Shipping Option API Routes](https://docs.medusajs.com/api/store#shipping-options). All its method
are available in the JS Client under the `medusa.shippingOptions` property.
A shipping option is used to define the available shipping methods during checkout or when creating a return.
Related Guide: [Shipping Option architecture](https://docs.medusajs.com/modules/carts-and-checkout/shipping#shipping-option).
## Methods
### listCartOptions
Retrieve a list of shipping options available for a cart.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.shippingOptions.listCartOptions(cartId)
.then(({ shipping_options }) => {
console.log(shipping_options.length);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listCartOptions"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreShippingOptionsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of shipping options.","expandable":false,"children":[{"name":"StoreShippingOptionsListRes","type":"[StoreShippingOptionsListRes](../../../medusa/types/medusa.StoreShippingOptionsListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of shipping options.","expandable":false,"children":[{"name":"shipping_options","type":"[PricedShippingOption](../../../medusa/types/medusa.PricedShippingOption/page.mdx)[]","description":"An array of shipping options details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listCartOptions"/>
### list
Retrieve a list of shipping options. The shipping options can be filtered using the `query` parameter.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.shippingOptions.list()
.then(({ shipping_options }) => {
console.log(shipping_options.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"[StoreGetShippingOptionsParams](../../../medusa/classes/medusa.StoreGetShippingOptionsParams/page.mdx)","description":"The filters to apply on the shipping options.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"product_ids","type":"`string`","description":"Product ID that is used to filter shipping options by whether they can be used to ship that product.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"region_id","type":"`string`","description":"Filter the shipping options by the ID of their associated region.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"is_return","type":"`string`","description":"Filter the shipping options by whether they're return shipping options.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreShippingOptionsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of shipping options.","expandable":false,"children":[{"name":"StoreShippingOptionsListRes","type":"[StoreShippingOptionsListRes](../../../medusa/types/medusa.StoreShippingOptionsListRes/page.mdx)","optional":false,"defaultValue":"","description":"The list of shipping options.","expandable":false,"children":[{"name":"shipping_options","type":"[PricedShippingOption](../../../medusa/types/medusa.PricedShippingOption/page.mdx)[]","description":"An array of shipping options details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
@@ -0,0 +1,82 @@
---
slug: /references/js-client/SwapsResource
---
import { TypeList } from "docs-ui"
# SwapsResource
This class is used to send requests to [Store Swap API Routes](https://docs.medusajs.com/api/store#swaps). All its method
are available in the JS Client under the `medusa.swaps` property.
A swap is created by a customer or an admin to exchange an item with a new one.
Creating a swap implicitely includes creating a return for the item being exchanged.
Related Guide: [How to create a swap in a storefront](https://docs.medusajs.com/modules/orders/storefront/create-swap)
## Methods
### create
Create a Swap for an Order. This will also create a return and associate it with the swap. If a return shipping option is specified, the return will automatically be fulfilled.
To complete the swap, you must use the [CartsResource.complete](../js_client.CartsResource/page.mdx#complete) method passing it the ID of the swap's cart.
An idempotency key will be generated if none is provided in the header `Idempotency-Key` and added to
the response. If an error occurs during swap creation or the request is interrupted for any reason, the swap creation can be retried by passing the idempotency
key in the `Idempotency-Key` header.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.swaps.create({
order_id,
return_items: [
{
item_id,
quantity: 1
}
],
additional_items: [
{
variant_id,
quantity: 1
}
]
})
.then(({ swap }) => {
console.log(swap.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"[StorePostSwapsReq](../../../medusa/classes/medusa.StorePostSwapsReq/page.mdx)","description":"The data of the swap to be created.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"order_id","type":"`string`","description":"The ID of the Order to create the Swap for.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"return_items","type":"[Item](../../../medusa/classes/medusa.Item-7/page.mdx)[]","description":"The items to include in the Return.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"item_id","type":"`string`","description":"The ID of the order's line item to return.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"`number`","description":"The quantity to return.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reason_id","type":"`string`","description":"The ID of the reason of this return. Return reasons can be retrieved from the List Return Reasons API Route.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"note","type":"`string`","description":"The note to add to the item being swapped.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"additional_items","type":"[AdditionalItem](../../../medusa/classes/medusa.AdditionalItem-2/page.mdx)[]","description":"The items to exchange the returned items with.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"variant_id","type":"`string`","description":"The ID of the Product Variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"`number`","description":"The quantity of the variant.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"return_shipping_option","type":"`string`","description":"The ID of the Shipping Option to create the Shipping Method from.","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreSwapsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the swap's details.","expandable":false,"children":[{"name":"StoreSwapsRes","type":"[StoreSwapsRes](../../../medusa/types/medusa.StoreSwapsRes/page.mdx)","optional":false,"defaultValue":"","description":"The swap's details.","expandable":false,"children":[{"name":"swap","type":"`Swap`","description":"Swap details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### retrieveByCartId
Retrieve a Swap's details by the ID of its cart.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.swaps.retrieveByCartId(cartId)
.then(({ swap }) => {
console.log(swap.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieveByCartId"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreSwapsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the swap's details.","expandable":false,"children":[{"name":"StoreSwapsRes","type":"[StoreSwapsRes](../../../medusa/types/medusa.StoreSwapsRes/page.mdx)","optional":false,"defaultValue":"","description":"The swap's details.","expandable":false,"children":[{"name":"swap","type":"`Swap`","description":"Swap details.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieveByCartId"/>