docs: generate + configure js sdk reference (#9714)

Manually generate the JS SDK reference + add it to the sidebar
This commit is contained in:
Shahed Nasser authored and GitHub committed 2024-10-22 17:31:32 +00:00
1 parent af3c6b0d93
commit a1190b7208
476 files changed
+76450 -189

No files matched your search

@@ -0,0 +1,510 @@
---
slug: /references/js-sdk/admin/cart
sidebar_label: cart
---
import { TypeList } from "docs-ui"
# cart - JS SDK Store Reference
This documentation provides a reference to the `sdk.store.cart` set of methods used to send requests to Medusa's Store API routes.
Related guides: [How to implement carts in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/cart).
## create
This method creates a cart. It sends a request to the [Create Cart](https://docs.medusajs.com/v2/api/store#carts\_postcarts)
API route.
Related guide: [How to create a cart in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/cart/create).
### Example
```ts
sdk.store.cart.create({
region_id: "reg_123"
})
.then(({ cart }) => {
console.log(cart)
})
```
### Parameters
<TypeList types={[{"name":"body","type":"`StoreCreateCart`","description":"The details of the cart to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the cart.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCartResponse&#62;","optional":false,"defaultValue":"","description":"The created cart.","expandable":false,"children":[{"name":"StoreCartResponse","type":"`StoreCartResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## update
This method updates a cart. It sends a request to the
[Update Cart](https://docs.medusajs.com/v2/api/store#carts\_postcartsid) API route.
Related guide: [How to update a cart in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/cart/update).
### Example
```ts
sdk.store.cart.update("cart_123", {
region_id: "reg_123"
})
.then(({ cart }) => {
console.log(cart)
})
```
### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"body","type":"`StoreUpdateCart`","description":"The data to update in the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the cart.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCartResponse&#62;","optional":false,"defaultValue":"","description":"The updated cart.","expandable":false,"children":[{"name":"StoreCartResponse","type":"`StoreCartResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## retrieve
This method retrieves a cart by its ID. It sends a request to the
[Get Cart](https://docs.medusajs.com/v2/api/store#carts\_getcartsid) API route.
Related guide: [How to retrieve a cart in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/cart/retrieve).
### Example
To retrieve a cart by its ID:
```ts
sdk.store.cart.retrieve("cart_123")
.then(({ cart }) => {
console.log(cart)
})
```
To specify the fields and relations to retrieve:
```ts
sdk.store.cart.retrieve("cart_123", {
fields: "id,*items"
})
.then(({ cart }) => {
console.log(cart)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the cart.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCartResponse&#62;","optional":false,"defaultValue":"","description":"The cart's details.","expandable":false,"children":[{"name":"StoreCartResponse","type":"`StoreCartResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## createLineItem
This methods adds a product variant to the cart as a line item. It sends a request to the
[Add Line Item](https://docs.medusajs.com/v2/api/store#carts\_postcartsidlineitems) API route.
Related guide: [How to manage a cart's line items in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/cart/manage-items).
### Example
```ts
sdk.store.cart.createLineItem("cart_123", {
variant_id: "variant_123",
quantity: 1
})
.then(({ cart }) => {
console.log(cart)
})
```
### Parameters
<TypeList types={[{"name":"cartId","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"body","type":"`StoreAddCartLineItem`","description":"The details of the item to add.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the cart.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCartResponse&#62;","optional":false,"defaultValue":"","description":"The cart's details.","expandable":false,"children":[{"name":"StoreCartResponse","type":"`StoreCartResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## updateLineItem
This method updates a line item in a cart. It sends a request to the
[Update Line Item](https://docs.medusajs.com/v2/api/store#carts\_postcartsidlineitemsline\_id) API route.
Related guide: [How to manage a cart's line items in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/cart/manage-items).
### Example
```ts
sdk.store.cart.updateLineItem(
"cart_123",
"li_123",
{
quantity: 1
}
)
.then(({ cart }) => {
console.log(cart)
})
```
### Parameters
<TypeList types={[{"name":"cartId","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"lineItemId","type":"`string`","description":"The line item's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"body","type":"`StoreUpdateCartLineItem`","description":"The data to update.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the cart.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCartResponse&#62;","optional":false,"defaultValue":"","description":"The cart's details.","expandable":false,"children":[{"name":"StoreCartResponse","type":"`StoreCartResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## deleteLineItem
This method deletes a line item from a cart. It sends a request to the
[Remove Line Item](https://docs.medusajs.com/v2/api/store#carts\_deletecartsidlineitemsline\_id) API route.
Related guide: [How to manage a cart's line items in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/cart/manage-items).
### Example
```ts
sdk.store.cart.deleteLineItem(
"cart_123",
"li_123"
)
.then(({ deleted, parent: cart }) => {
console.log(deleted, cart)
})
```
### Parameters
<TypeList types={[{"name":"cartId","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"lineItemId","type":"`string`","description":"The item's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreLineItemDeleteResponse&#62;","optional":false,"defaultValue":"","description":"The deletion's details.","expandable":false,"children":[{"name":"StoreLineItemDeleteResponse","type":"`StoreLineItemDeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## addShippingMethod
This method adds a shipping method to a cart. It sends a request to
the [Add Shipping Method](https://docs.medusajs.com/v2/api/store#carts\_postcartsidshippingmethods) API routes.
Related guide: [Implement shipping step during checkout](https://docs.medusajs.com/v2/resources/storefront-development/checkout/shipping).
### Example
```ts
sdk.store.cart.addShippingMethod("cart_123", {
option_id: "so_123",
data: {
// custom data for fulfillment provider.
}
})
.then(({ cart }) => {
console.log(cart)
})
```
### Parameters
<TypeList types={[{"name":"cartId","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"body","type":"`StoreAddCartShippingMethods`","description":"The shipping method's details.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the cart.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCartResponse&#62;","optional":false,"defaultValue":"","description":"The cart's details.","expandable":false,"children":[{"name":"StoreCartResponse","type":"`StoreCartResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## complete
This method completes a cart and places the order. It's the last step of the checkout flow.
The method sends a request to the [Complete Cart](https://docs.medusajs.com/v2/api/store#carts\_postcartsidcomplete)
API route.
Related guide: [Learn how to complete cart in checkout flow](https://docs.medusajs.com/v2/resources/storefront-development/checkout/complete-cart).
### Example
```ts
sdk.store.cart.complete("cart_123")
.then((data) => {
if(data.type === "cart") {
// an error occurred
console.log(data.error, data.cart)
} else {
// order placed successfully
console.log(data.order)
}
})
```
### Parameters
<TypeList types={[{"name":"cartId","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the created order.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCompleteCartResponse&#62;","optional":false,"defaultValue":"","description":"The order's details, if it was placed successfully. Otherwise, the cart is returned with an error.","expandable":false,"children":[{"name":"StoreCompleteCartResponse","type":"`StoreCompleteCartResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
## create
This method creates a cart. It sends a request to the [Create Cart](https://docs.medusajs.com/v2/api/store#carts\_postcarts)
API route.
Related guide: [How to create a cart in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/cart/create).
### Example
```ts
sdk.store.cart.create({
region_id: "reg_123"
})
.then(({ cart }) => {
console.log(cart)
})
```
### Parameters
<TypeList types={[{"name":"body","type":"`StoreCreateCart`","description":"The details of the cart to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the cart.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCartResponse&#62;","optional":false,"defaultValue":"","description":"The created cart.","expandable":false,"children":[{"name":"StoreCartResponse","type":"`StoreCartResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## update
This method updates a cart. It sends a request to the
[Update Cart](https://docs.medusajs.com/v2/api/store#carts\_postcartsid) API route.
Related guide: [How to update a cart in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/cart/update).
### Example
```ts
sdk.store.cart.update("cart_123", {
region_id: "reg_123"
})
.then(({ cart }) => {
console.log(cart)
})
```
### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"body","type":"`StoreUpdateCart`","description":"The data to update in the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the cart.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCartResponse&#62;","optional":false,"defaultValue":"","description":"The updated cart.","expandable":false,"children":[{"name":"StoreCartResponse","type":"`StoreCartResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## retrieve
This method retrieves a cart by its ID. It sends a request to the
[Get Cart](https://docs.medusajs.com/v2/api/store#carts\_getcartsid) API route.
Related guide: [How to retrieve a cart in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/cart/retrieve).
### Example
To retrieve a cart by its ID:
```ts
sdk.store.cart.retrieve("cart_123")
.then(({ cart }) => {
console.log(cart)
})
```
To specify the fields and relations to retrieve:
```ts
sdk.store.cart.retrieve("cart_123", {
fields: "id,*items"
})
.then(({ cart }) => {
console.log(cart)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the cart.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCartResponse&#62;","optional":false,"defaultValue":"","description":"The cart's details.","expandable":false,"children":[{"name":"StoreCartResponse","type":"`StoreCartResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## createLineItem
This methods adds a product variant to the cart as a line item. It sends a request to the
[Add Line Item](https://docs.medusajs.com/v2/api/store#carts\_postcartsidlineitems) API route.
Related guide: [How to manage a cart's line items in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/cart/manage-items).
### Example
```ts
sdk.store.cart.createLineItem("cart_123", {
variant_id: "variant_123",
quantity: 1
})
.then(({ cart }) => {
console.log(cart)
})
```
### Parameters
<TypeList types={[{"name":"cartId","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"body","type":"`StoreAddCartLineItem`","description":"The details of the item to add.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the cart.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCartResponse&#62;","optional":false,"defaultValue":"","description":"The cart's details.","expandable":false,"children":[{"name":"StoreCartResponse","type":"`StoreCartResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## updateLineItem
This method updates a line item in a cart. It sends a request to the
[Update Line Item](https://docs.medusajs.com/v2/api/store#carts\_postcartsidlineitemsline\_id) API route.
Related guide: [How to manage a cart's line items in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/cart/manage-items).
### Example
```ts
sdk.store.cart.updateLineItem(
"cart_123",
"li_123",
{
quantity: 1
}
)
.then(({ cart }) => {
console.log(cart)
})
```
### Parameters
<TypeList types={[{"name":"cartId","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"lineItemId","type":"`string`","description":"The line item's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"body","type":"`StoreUpdateCartLineItem`","description":"The data to update.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the cart.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCartResponse&#62;","optional":false,"defaultValue":"","description":"The cart's details.","expandable":false,"children":[{"name":"StoreCartResponse","type":"`StoreCartResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## deleteLineItem
This method deletes a line item from a cart. It sends a request to the
[Remove Line Item](https://docs.medusajs.com/v2/api/store#carts\_deletecartsidlineitemsline\_id) API route.
Related guide: [How to manage a cart's line items in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/cart/manage-items).
### Example
```ts
sdk.store.cart.deleteLineItem(
"cart_123",
"li_123"
)
.then(({ deleted, parent: cart }) => {
console.log(deleted, cart)
})
```
### Parameters
<TypeList types={[{"name":"cartId","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"lineItemId","type":"`string`","description":"The item's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreLineItemDeleteResponse&#62;","optional":false,"defaultValue":"","description":"The deletion's details.","expandable":false,"children":[{"name":"StoreLineItemDeleteResponse","type":"`StoreLineItemDeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## addShippingMethod
This method adds a shipping method to a cart. It sends a request to
the [Add Shipping Method](https://docs.medusajs.com/v2/api/store#carts\_postcartsidshippingmethods) API routes.
Related guide: [Implement shipping step during checkout](https://docs.medusajs.com/v2/resources/storefront-development/checkout/shipping).
### Example
```ts
sdk.store.cart.addShippingMethod("cart_123", {
option_id: "so_123",
data: {
// custom data for fulfillment provider.
}
})
.then(({ cart }) => {
console.log(cart)
})
```
### Parameters
<TypeList types={[{"name":"cartId","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"body","type":"`StoreAddCartShippingMethods`","description":"The shipping method's details.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the cart.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCartResponse&#62;","optional":false,"defaultValue":"","description":"The cart's details.","expandable":false,"children":[{"name":"StoreCartResponse","type":"`StoreCartResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## complete
This method completes a cart and places the order. It's the last step of the checkout flow.
The method sends a request to the [Complete Cart](https://docs.medusajs.com/v2/api/store#carts\_postcartsidcomplete)
API route.
Related guide: [Learn how to complete cart in checkout flow](https://docs.medusajs.com/v2/resources/storefront-development/checkout/complete-cart).
### Example
```ts
sdk.store.cart.complete("cart_123")
.then((data) => {
if(data.type === "cart") {
// an error occurred
console.log(data.error, data.cart)
} else {
// order placed successfully
console.log(data.order)
}
})
```
### Parameters
<TypeList types={[{"name":"cartId","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the created order.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCompleteCartResponse&#62;","optional":false,"defaultValue":"","description":"The order's details, if it was placed successfully. Otherwise, the cart is returned with an error.","expandable":false,"children":[{"name":"StoreCompleteCartResponse","type":"`StoreCompleteCartResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
@@ -0,0 +1,200 @@
---
slug: /references/js-sdk/admin/category
sidebar_label: category
---
import { TypeList } from "docs-ui"
# category - JS SDK Store Reference
This documentation provides a reference to the `sdk.store.category` set of methods used to send requests to Medusa's Store API routes.
## list
This method retrieves a paginated list of product categories. It sends a request to the
[List Categories](https://docs.medusajs.com/v2/api/store#product-categories\_getproductcategories) API route.
Related guide: [How to retrieve list of categories in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/products/categories/list).
### Example
To retrieve the list of categoreis:
```ts
sdk.store.category.list()
.then(({ product_categories, count, offset, limit }) => {
console.log(product_categories)
})
```
To configure the pagination, pass the `limit` and `offset` query parameters.
For example, to retrieve only 10 items and skip 10 items:
```ts
sdk.store.category.list({
limit: 10,
offset: 10
})
.then(({ product_categories, count, offset, limit }) => {
console.log(product_categories)
})
```
Using the `fields` query parameter, you can specify the fields and relations to retrieve
in each category:
```ts
sdk.store.category.list({
fields: "id,*parent_category"
})
.then(({ product_categories, count, offset, limit }) => {
console.log(product_categories)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"query","type":"[FindParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.FindParams/page.mdx) & `StoreProductCategoryListParams`","description":"Filters and pagination configurations.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreProductCategoryListResponse&#62;","optional":false,"defaultValue":"","description":"The paginated list of categoreis.","expandable":false,"children":[{"name":"StoreProductCategoryListResponse","type":"`StoreProductCategoryListResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## retrieve
This method retrieves a category by its ID. It sends a request to the
[Retrieve Product Category](https://docs.medusajs.com/v2/api/store#product-categories\_getproductcategoriesid).
Related guide: [How to retrieve a category in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/products/categories/retrieve).
### Example
To retrieve a category by its ID:
```ts
sdk.store.category.retrieve("pcat_123")
.then(({ product_category }) => {
console.log(product_category)
})
```
To specify the fields and relations to retrieve:
```ts
sdk.store.category.retrieve("pcat_123", {
fields: "id,*parent_category"
})
.then(({ product_category }) => {
console.log(product_category)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the category to retrieve.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"`StoreProductCategoryParams`","description":"Configure the fields to retrieve in the category.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreProductCategoryResponse&#62;","optional":false,"defaultValue":"","description":"The category.","expandable":false,"children":[{"name":"StoreProductCategoryResponse","type":"`StoreProductCategoryResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
## list
This method retrieves a paginated list of product categories. It sends a request to the
[List Categories](https://docs.medusajs.com/v2/api/store#product-categories\_getproductcategories) API route.
Related guide: [How to retrieve list of categories in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/products/categories/list).
### Example
To retrieve the list of categoreis:
```ts
sdk.store.category.list()
.then(({ product_categories, count, offset, limit }) => {
console.log(product_categories)
})
```
To configure the pagination, pass the `limit` and `offset` query parameters.
For example, to retrieve only 10 items and skip 10 items:
```ts
sdk.store.category.list({
limit: 10,
offset: 10
})
.then(({ product_categories, count, offset, limit }) => {
console.log(product_categories)
})
```
Using the `fields` query parameter, you can specify the fields and relations to retrieve
in each category:
```ts
sdk.store.category.list({
fields: "id,*parent_category"
})
.then(({ product_categories, count, offset, limit }) => {
console.log(product_categories)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"query","type":"[FindParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.FindParams/page.mdx) & `StoreProductCategoryListParams`","description":"Filters and pagination configurations.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreProductCategoryListResponse&#62;","optional":false,"defaultValue":"","description":"The paginated list of categoreis.","expandable":false,"children":[{"name":"StoreProductCategoryListResponse","type":"`StoreProductCategoryListResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## retrieve
This method retrieves a category by its ID. It sends a request to the
[Retrieve Product Category](https://docs.medusajs.com/v2/api/store#product-categories\_getproductcategoriesid).
Related guide: [How to retrieve a category in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/products/categories/retrieve).
### Example
To retrieve a category by its ID:
```ts
sdk.store.category.retrieve("pcat_123")
.then(({ product_category }) => {
console.log(product_category)
})
```
To specify the fields and relations to retrieve:
```ts
sdk.store.category.retrieve("pcat_123", {
fields: "id,*parent_category"
})
.then(({ product_category }) => {
console.log(product_category)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the category to retrieve.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"`StoreProductCategoryParams`","description":"Configure the fields to retrieve in the category.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreProductCategoryResponse&#62;","optional":false,"defaultValue":"","description":"The category.","expandable":false,"children":[{"name":"StoreProductCategoryResponse","type":"`StoreProductCategoryResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
@@ -0,0 +1,200 @@
---
slug: /references/js-sdk/admin/collection
sidebar_label: collection
---
import { TypeList } from "docs-ui"
# collection - JS SDK Store Reference
This documentation provides a reference to the `sdk.store.collection` set of methods used to send requests to Medusa's Store API routes.
## list
This method retrieves a paginated list of product collections. It sends a request to the
[List Collections](https://docs.medusajs.com/v2/api/store#collections\_getcollections) API route.
Related guide: [How to retrieve collections in a storefront](https://docs.medusajs.com/v2/resources/storefront-development/products/collections/list).
### Example
To retrieve the list of collections:
```ts
sdk.store.collection.list()
.then(({ collections, count, limit, offset }) => {
console.log(collections)
})
```
To configure the pagination, pass the `limit` and `offset` query parameters.
For example, to retrieve only 10 items and skip 10 items:
```ts
sdk.store.collection.list({
limit: 10,
offset: 10
})
.then(({ collections, count, limit, offset }) => {
console.log(collections)
})
```
Using the `fields` query parameter, you can specify the fields and relations to retrieve
in each collection:
```ts
sdk.store.collection.list({
fields: "id,handle"
})
.then(({ collections, count, limit, offset }) => {
console.log(collections)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"query","type":"[FindParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.FindParams/page.mdx) & `StoreCollectionFilters`","description":"Filters and pagination configurations.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCollectionListResponse&#62;","optional":false,"defaultValue":"","description":"The paginated list of collections.","expandable":false,"children":[{"name":"StoreCollectionListResponse","type":"`StoreCollectionListResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## retrieve
This method retrieves a collection by its ID. It sends a request to the [Get Collection](https://docs.medusajs.com/v2/api/store#collections\_getcollectionsid)
API route.
Related guide: [How to retrieve a collection in a storefront](https://docs.medusajs.com/v2/resources/storefront-development/products/collections/retrieve).
### Example
To retrieve a collection by its ID:
```ts
sdk.store.collection.retrieve("pcol_123")
.then(({ collection }) => {
console.log(collection)
})
```
To specify the fields and relations to retrieve:
```ts
sdk.store.collection.retrieve("pcol_123", {
fields: "id,handle"
})
.then(({ collection }) => {
console.log(collection)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the collection to retrieve.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the collection.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCollectionResponse&#62;","optional":false,"defaultValue":"","description":"The collection.","expandable":false,"children":[{"name":"StoreCollectionResponse","type":"`StoreCollectionResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
## list
This method retrieves a paginated list of product collections. It sends a request to the
[List Collections](https://docs.medusajs.com/v2/api/store#collections\_getcollections) API route.
Related guide: [How to retrieve collections in a storefront](https://docs.medusajs.com/v2/resources/storefront-development/products/collections/list).
### Example
To retrieve the list of collections:
```ts
sdk.store.collection.list()
.then(({ collections, count, limit, offset }) => {
console.log(collections)
})
```
To configure the pagination, pass the `limit` and `offset` query parameters.
For example, to retrieve only 10 items and skip 10 items:
```ts
sdk.store.collection.list({
limit: 10,
offset: 10
})
.then(({ collections, count, limit, offset }) => {
console.log(collections)
})
```
Using the `fields` query parameter, you can specify the fields and relations to retrieve
in each collection:
```ts
sdk.store.collection.list({
fields: "id,handle"
})
.then(({ collections, count, limit, offset }) => {
console.log(collections)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"query","type":"[FindParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.FindParams/page.mdx) & `StoreCollectionFilters`","description":"Filters and pagination configurations.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCollectionListResponse&#62;","optional":false,"defaultValue":"","description":"The paginated list of collections.","expandable":false,"children":[{"name":"StoreCollectionListResponse","type":"`StoreCollectionListResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## retrieve
This method retrieves a collection by its ID. It sends a request to the [Get Collection](https://docs.medusajs.com/v2/api/store#collections\_getcollectionsid)
API route.
Related guide: [How to retrieve a collection in a storefront](https://docs.medusajs.com/v2/resources/storefront-development/products/collections/retrieve).
### Example
To retrieve a collection by its ID:
```ts
sdk.store.collection.retrieve("pcol_123")
.then(({ collection }) => {
console.log(collection)
})
```
To specify the fields and relations to retrieve:
```ts
sdk.store.collection.retrieve("pcol_123", {
fields: "id,handle"
})
.then(({ collection }) => {
console.log(collection)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the collection to retrieve.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the collection.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCollectionResponse&#62;","optional":false,"defaultValue":"","description":"The collection.","expandable":false,"children":[{"name":"StoreCollectionResponse","type":"`StoreCollectionResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
@@ -0,0 +1,610 @@
---
slug: /references/js-sdk/admin/customer
sidebar_label: customer
---
import { TypeList } from "docs-ui"
# customer - JS SDK Store Reference
This documentation provides a reference to the `sdk.store.customer` set of methods used to send requests to Medusa's Store API routes.
## create
This method registers a customer. It sends a request to the [Register Customer](https://docs.medusajs.com/v2/api/store#customers\_postcustomers)
API route.
You must use the Auth.register method first to retrieve a registration token. Then, pass that
registration token in the `headers` parameter of this method as an authorization bearer header.
Related guide: [How to register customer in storefront](https://docs.medusajs.com/v2/resources/storefront-development/customers/register)
### Example
```ts
const token = await sdk.auth.register("customer", "emailpass", {
"email": "customer@gmail.com",
"password": "supersecret"
})
sdk.store.customer.create(
{
"email": "customer@gmail.com"
},
{},
{
authorization: `Bearer ${token}`
}
)
.then(({ customer }) => {
console.log(customer)
})
```
### Parameters
<TypeList types={[{"name":"body","type":"`StoreCreateCustomer`","description":"The customer's details.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the customer.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request. This is where you include the authorization JWT registration token.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCustomerResponse&#62;","optional":false,"defaultValue":"","description":"The customer's details.","expandable":false,"children":[{"name":"StoreCustomerResponse","type":"`StoreCustomerResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## update
This method updates the logged-in customer's details. The customer must be logged in
first with the Auth.login method.
It sends a request to the
[Update Customer](https://docs.medusajs.com/v2/api/store#customers\_postcustomersme) API route.
Related guide: [How to edit customer's profile in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/customers/profile).
### Example
```ts
sdk.store.customer.update({
first_name: "John"
})
.then(({ customer }) => {
console.log(customer)
})
```
### Parameters
<TypeList types={[{"name":"body","type":"`StoreUpdateCustomer`","description":"The customer's details to update.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the customer.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCustomerResponse&#62;","optional":false,"defaultValue":"","description":"The customer's details.","expandable":false,"children":[{"name":"StoreCustomerResponse","type":"`StoreCustomerResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## retrieve
This method retrieves the logged-in customer's details. The customer must be logged in
first with the Auth.login method.
It sends a request to the [Get Logged-In Customer](https://docs.medusajs.com/v2/api/store#customers\_getcustomersme)
API route.
### Example
```ts
sdk.store.customer.retrieve()
.then(({ customer }) => {
console.log(customer)
})
```
### Parameters
<TypeList types={[{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the customer.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCustomerResponse&#62;","optional":false,"defaultValue":"","description":"The customer's details.","expandable":false,"children":[{"name":"StoreCustomerResponse","type":"`StoreCustomerResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## createAddress
This method creates an address for the logged-in customer. The customer must be logged in
first with the Auth.login method.
It sends a request to the [Create Address](https://docs.medusajs.com/v2/api/store#customers\_postcustomersmeaddresses)
API route.
Related guides: [How to manage customer's addresses in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/customers/addresses)
### Example
```ts
sdk.store.customer.createAddress({
country_code: "us"
})
.then(({ customer }) => {
console.log(customer)
})
```
### Parameters
<TypeList types={[{"name":"body","type":"`StoreCreateCustomerAddress`","description":"The address's details.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the customer.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCustomerResponse&#62;","optional":false,"defaultValue":"","description":"The customer's details.","expandable":false,"children":[{"name":"StoreCustomerResponse","type":"`StoreCustomerResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## updateAddress
This method updates the address of the logged-in customer. The customer must be logged in
first with the Auth.login method.
It sends a request to the [Update Address](https://docs.medusajs.com/v2/api/store#customers\_postcustomersmeaddressesaddress\_id)
API route.
Related guides: [How to manage customer's addresses in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/customers/addresses)
### Example
```ts
sdk.store.customer.updateAddress(
"caddr_123",
{
country_code: "us"
}
)
.then(({ customer }) => {
console.log(customer)
})
```
### Parameters
<TypeList types={[{"name":"addressId","type":"`string`","description":"The ID of the address to update.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"body","type":"`StoreUpdateCustomerAddress`","description":"The details to update in the address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the customer.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCustomerResponse&#62;","optional":false,"defaultValue":"","description":"The customer's details.","expandable":false,"children":[{"name":"StoreCustomerResponse","type":"`StoreCustomerResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## listAddress
This method retrieves the logged-in customer's address. The customer must be logged in
first with the Auth.login method.
It sends a request to the [List Customer's Address](https://docs.medusajs.com/v2/api/store#customers\_getcustomersmeaddresses)
API route.
Related guides: [How to manage customer's addresses in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/customers/addresses)
### Example
To retrieve the list of addresses:
```ts
sdk.store.customer.listAddress()
.then(({ addresses, count, offset, limit }) => {
console.log(addresses)
})
```
To configure the pagination, pass the `limit` and `offset` query parameters.
For example, to retrieve only 10 items and skip 10 items:
```ts
sdk.store.customer.listAddress({
limit: 10,
offset: 10
})
.then(({ addresses, count, offset, limit }) => {
console.log(addresses)
})
```
Using the `fields` query parameter, you can specify the fields and relations to retrieve
in each address:
```ts
sdk.store.customer.listAddress({
fields: "id,country_code"
})
.then(({ addresses, count, offset, limit }) => {
console.log(addresses)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"query","type":"[FindParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.FindParams/page.mdx) & `StoreCustomerAddressFilters`","description":"Configure the fields to retrieve in the addresses.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCustomerAddressListResponse&#62;","optional":false,"defaultValue":"","description":"The paginated list of addresses.","expandable":false,"children":[{"name":"StoreCustomerAddressListResponse","type":"`StoreCustomerAddressListResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## retrieveAddress
This method retrieves an address of the logged-in customer. The customer must be logged in
first with the Auth.login method.
It sends a request to the [Get Address](https://docs.medusajs.com/v2/api/store#customers\_getcustomersmeaddressesaddress\_id)
API route.
Related guides: [How to manage customer's addresses in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/customers/addresses)
### Example
To retrieve an address by its ID:
```ts
sdk.store.customer.retrieveAddress(
"caddr_123"
)
.then(({ address }) => {
console.log(address)
})
```
To specify the fields and relations to retrieve:
```ts
sdk.store.customer.retrieveAddress(
"caddr_123",
{
fields: "id,country_code"
}
)
.then(({ address }) => {
console.log(address)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"addressId","type":"`string`","description":"The address's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the address.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCustomerAddressResponse&#62;","optional":false,"defaultValue":"","description":"The address's details.","expandable":false,"children":[{"name":"StoreCustomerAddressResponse","type":"`StoreCustomerAddressResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## deleteAddress
This method deletes an address of the logged-in customer. The customer must be logged in
first with the Auth.login method.
It sends a request to the [Remove Address](https://docs.medusajs.com/v2/api/store#customers\_deletecustomersmeaddressesaddress\_id)
API route.
Related guides: [How to manage customer's addresses in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/customers/addresses)
### Example
```ts
sdk.store.customer.deleteAddress("caddr_123")
.then(({ deleted, parent: customer }) => {
console.log(customer)
})
```
### Parameters
<TypeList types={[{"name":"addressId","type":"`string`","description":"The address's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCustomerAddressDeleteResponse&#62;","optional":false,"defaultValue":"","description":"The deletion's details.","expandable":false,"children":[{"name":"StoreCustomerAddressDeleteResponse","type":"`StoreCustomerAddressDeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
## create
This method registers a customer. It sends a request to the [Register Customer](https://docs.medusajs.com/v2/api/store#customers\_postcustomers)
API route.
You must use the Auth.register method first to retrieve a registration token. Then, pass that
registration token in the `headers` parameter of this method as an authorization bearer header.
Related guide: [How to register customer in storefront](https://docs.medusajs.com/v2/resources/storefront-development/customers/register)
### Example
```ts
const token = await sdk.auth.register("customer", "emailpass", {
"email": "customer@gmail.com",
"password": "supersecret"
})
sdk.store.customer.create(
{
"email": "customer@gmail.com"
},
{},
{
authorization: `Bearer ${token}`
}
)
.then(({ customer }) => {
console.log(customer)
})
```
### Parameters
<TypeList types={[{"name":"body","type":"`StoreCreateCustomer`","description":"The customer's details.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the customer.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request. This is where you include the authorization JWT registration token.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCustomerResponse&#62;","optional":false,"defaultValue":"","description":"The customer's details.","expandable":false,"children":[{"name":"StoreCustomerResponse","type":"`StoreCustomerResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## update
This method updates the logged-in customer's details. The customer must be logged in
first with the Auth.login method.
It sends a request to the
[Update Customer](https://docs.medusajs.com/v2/api/store#customers\_postcustomersme) API route.
Related guide: [How to edit customer's profile in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/customers/profile).
### Example
```ts
sdk.store.customer.update({
first_name: "John"
})
.then(({ customer }) => {
console.log(customer)
})
```
### Parameters
<TypeList types={[{"name":"body","type":"`StoreUpdateCustomer`","description":"The customer's details to update.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the customer.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCustomerResponse&#62;","optional":false,"defaultValue":"","description":"The customer's details.","expandable":false,"children":[{"name":"StoreCustomerResponse","type":"`StoreCustomerResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## retrieve
This method retrieves the logged-in customer's details. The customer must be logged in
first with the Auth.login method.
It sends a request to the [Get Logged-In Customer](https://docs.medusajs.com/v2/api/store#customers\_getcustomersme)
API route.
### Example
```ts
sdk.store.customer.retrieve()
.then(({ customer }) => {
console.log(customer)
})
```
### Parameters
<TypeList types={[{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the customer.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCustomerResponse&#62;","optional":false,"defaultValue":"","description":"The customer's details.","expandable":false,"children":[{"name":"StoreCustomerResponse","type":"`StoreCustomerResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## createAddress
This method creates an address for the logged-in customer. The customer must be logged in
first with the Auth.login method.
It sends a request to the [Create Address](https://docs.medusajs.com/v2/api/store#customers\_postcustomersmeaddresses)
API route.
Related guides: [How to manage customer's addresses in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/customers/addresses)
### Example
```ts
sdk.store.customer.createAddress({
country_code: "us"
})
.then(({ customer }) => {
console.log(customer)
})
```
### Parameters
<TypeList types={[{"name":"body","type":"`StoreCreateCustomerAddress`","description":"The address's details.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the customer.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCustomerResponse&#62;","optional":false,"defaultValue":"","description":"The customer's details.","expandable":false,"children":[{"name":"StoreCustomerResponse","type":"`StoreCustomerResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## updateAddress
This method updates the address of the logged-in customer. The customer must be logged in
first with the Auth.login method.
It sends a request to the [Update Address](https://docs.medusajs.com/v2/api/store#customers\_postcustomersmeaddressesaddress\_id)
API route.
Related guides: [How to manage customer's addresses in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/customers/addresses)
### Example
```ts
sdk.store.customer.updateAddress(
"caddr_123",
{
country_code: "us"
}
)
.then(({ customer }) => {
console.log(customer)
})
```
### Parameters
<TypeList types={[{"name":"addressId","type":"`string`","description":"The ID of the address to update.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"body","type":"`StoreUpdateCustomerAddress`","description":"The details to update in the address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the customer.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCustomerResponse&#62;","optional":false,"defaultValue":"","description":"The customer's details.","expandable":false,"children":[{"name":"StoreCustomerResponse","type":"`StoreCustomerResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## listAddress
This method retrieves the logged-in customer's address. The customer must be logged in
first with the Auth.login method.
It sends a request to the [List Customer's Address](https://docs.medusajs.com/v2/api/store#customers\_getcustomersmeaddresses)
API route.
Related guides: [How to manage customer's addresses in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/customers/addresses)
### Example
To retrieve the list of addresses:
```ts
sdk.store.customer.listAddress()
.then(({ addresses, count, offset, limit }) => {
console.log(addresses)
})
```
To configure the pagination, pass the `limit` and `offset` query parameters.
For example, to retrieve only 10 items and skip 10 items:
```ts
sdk.store.customer.listAddress({
limit: 10,
offset: 10
})
.then(({ addresses, count, offset, limit }) => {
console.log(addresses)
})
```
Using the `fields` query parameter, you can specify the fields and relations to retrieve
in each address:
```ts
sdk.store.customer.listAddress({
fields: "id,country_code"
})
.then(({ addresses, count, offset, limit }) => {
console.log(addresses)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"query","type":"[FindParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.FindParams/page.mdx) & `StoreCustomerAddressFilters`","description":"Configure the fields to retrieve in the addresses.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCustomerAddressListResponse&#62;","optional":false,"defaultValue":"","description":"The paginated list of addresses.","expandable":false,"children":[{"name":"StoreCustomerAddressListResponse","type":"`StoreCustomerAddressListResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## retrieveAddress
This method retrieves an address of the logged-in customer. The customer must be logged in
first with the Auth.login method.
It sends a request to the [Get Address](https://docs.medusajs.com/v2/api/store#customers\_getcustomersmeaddressesaddress\_id)
API route.
Related guides: [How to manage customer's addresses in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/customers/addresses)
### Example
To retrieve an address by its ID:
```ts
sdk.store.customer.retrieveAddress(
"caddr_123"
)
.then(({ address }) => {
console.log(address)
})
```
To specify the fields and relations to retrieve:
```ts
sdk.store.customer.retrieveAddress(
"caddr_123",
{
fields: "id,country_code"
}
)
.then(({ address }) => {
console.log(address)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"addressId","type":"`string`","description":"The address's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the address.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCustomerAddressResponse&#62;","optional":false,"defaultValue":"","description":"The address's details.","expandable":false,"children":[{"name":"StoreCustomerAddressResponse","type":"`StoreCustomerAddressResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## deleteAddress
This method deletes an address of the logged-in customer. The customer must be logged in
first with the Auth.login method.
It sends a request to the [Remove Address](https://docs.medusajs.com/v2/api/store#customers\_deletecustomersmeaddressesaddress\_id)
API route.
Related guides: [How to manage customer's addresses in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/customers/addresses)
### Example
```ts
sdk.store.customer.deleteAddress("caddr_123")
.then(({ deleted, parent: customer }) => {
console.log(customer)
})
```
### Parameters
<TypeList types={[{"name":"addressId","type":"`string`","description":"The address's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreCustomerAddressDeleteResponse&#62;","optional":false,"defaultValue":"","description":"The deletion's details.","expandable":false,"children":[{"name":"StoreCustomerAddressDeleteResponse","type":"`StoreCustomerAddressDeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
@@ -0,0 +1,64 @@
---
slug: /references/js-sdk/admin/fulfillment
sidebar_label: fulfillment
---
import { TypeList } from "docs-ui"
# fulfillment - JS SDK Store Reference
This documentation provides a reference to the `sdk.store.fulfillment` set of methods used to send requests to Medusa's Store API routes.
## listCartOptions
This method retrieves the list of shipping options for a cart. It sends a request to
the [List Shipping Options](https://docs.medusajs.com/v2/api/store#shipping-options\_getshippingoptions)
API route.
Related guide: [Implement shipping step during checkout](https://docs.medusajs.com/v2/resources/storefront-development/checkout/shipping).
### Example
```ts
sdk.store.fulfillment.listCartOptions({
cart_id: "cart_123"
})
.then(({ shipping_options }) => {
console.log(shipping_options)
})
```
### Parameters
<TypeList types={[{"name":"query","type":"`StoreGetShippingOptionList`","description":"The cart's details along with configurations of the fields to retrieve in the options.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreShippingOptionListResponse&#62;","optional":false,"defaultValue":"","description":"The shipping options that can be used for the cart.","expandable":false,"children":[{"name":"StoreShippingOptionListResponse","type":"`StoreShippingOptionListResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
## listCartOptions
This method retrieves the list of shipping options for a cart. It sends a request to
the [List Shipping Options](https://docs.medusajs.com/v2/api/store#shipping-options\_getshippingoptions)
API route.
Related guide: [Implement shipping step during checkout](https://docs.medusajs.com/v2/resources/storefront-development/checkout/shipping).
### Example
```ts
sdk.store.fulfillment.listCartOptions({
cart_id: "cart_123"
})
.then(({ shipping_options }) => {
console.log(shipping_options)
})
```
### Parameters
<TypeList types={[{"name":"query","type":"`StoreGetShippingOptionList`","description":"The cart's details along with configurations of the fields to retrieve in the options.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreShippingOptionListResponse&#62;","optional":false,"defaultValue":"","description":"The shipping options that can be used for the cart.","expandable":false,"children":[{"name":"StoreShippingOptionListResponse","type":"`StoreShippingOptionListResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
@@ -0,0 +1,194 @@
---
slug: /references/js-sdk/admin/order
sidebar_label: order
---
import { TypeList } from "docs-ui"
# order - JS SDK Store Reference
This documentation provides a reference to the `sdk.store.order` set of methods used to send requests to Medusa's Store API routes.
## list
This method retrieves a paginated list of orders matching the specified filters. It
sends a request to the [List Orders](https://docs.medusajs.com/v2/api/store#orders\_getorders)
API route.
### Example
To retrieve the list of orders:
```ts
sdk.store.order.list()
.then(({ orders, count, offset, limit }) => {
console.log(orders)
})
```
To configure the pagination, pass the `limit` and `offset` query parameters.
For example, to retrieve only 10 items and skip 10 items:
```ts
sdk.store.order.list({
limit: 10,
offset: 10
})
.then(({ orders, count, offset, limit }) => {
console.log(orders)
})
```
Using the `fields` query parameter, you can specify the fields and relations to retrieve
in each order:
```ts
sdk.store.order.list({
fields: "id,*items"
})
.then(({ orders, count, offset, limit }) => {
console.log(orders)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"query","type":"`StoreOrderFilters`","description":"Configure the fields to retrieve in the orders.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreOrderListResponse&#62;","optional":false,"defaultValue":"","description":"The paginated list of orders.","expandable":false,"children":[{"name":"StoreOrderListResponse","type":"`StoreOrderListResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## retrieve
This method retrieves an order by its ID. It sends a request to the
[Get Order](https://docs.medusajs.com/v2/api/store#orders\_getordersid) API route.
### Example
To retrieve an order by its ID:
```ts
sdk.store.order.retrieve("order_123")
.then(({ order }) => {
console.log(order)
})
```
To specify the fields and relations to retrieve:
```ts
sdk.store.order.retrieve("order_123", {
fields: "id,*items"
})
.then(({ order }) => {
console.log(order)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the order.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;object&#62;","optional":false,"defaultValue":"","description":"The order's details.","expandable":false,"children":[{"name":"order","type":"`StoreOrder`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
## list
This method retrieves a paginated list of orders matching the specified filters. It
sends a request to the [List Orders](https://docs.medusajs.com/v2/api/store#orders\_getorders)
API route.
### Example
To retrieve the list of orders:
```ts
sdk.store.order.list()
.then(({ orders, count, offset, limit }) => {
console.log(orders)
})
```
To configure the pagination, pass the `limit` and `offset` query parameters.
For example, to retrieve only 10 items and skip 10 items:
```ts
sdk.store.order.list({
limit: 10,
offset: 10
})
.then(({ orders, count, offset, limit }) => {
console.log(orders)
})
```
Using the `fields` query parameter, you can specify the fields and relations to retrieve
in each order:
```ts
sdk.store.order.list({
fields: "id,*items"
})
.then(({ orders, count, offset, limit }) => {
console.log(orders)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"query","type":"`StoreOrderFilters`","description":"Configure the fields to retrieve in the orders.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreOrderListResponse&#62;","optional":false,"defaultValue":"","description":"The paginated list of orders.","expandable":false,"children":[{"name":"StoreOrderListResponse","type":"`StoreOrderListResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## retrieve
This method retrieves an order by its ID. It sends a request to the
[Get Order](https://docs.medusajs.com/v2/api/store#orders\_getordersid) API route.
### Example
To retrieve an order by its ID:
```ts
sdk.store.order.retrieve("order_123")
.then(({ order }) => {
console.log(order)
})
```
To specify the fields and relations to retrieve:
```ts
sdk.store.order.retrieve("order_123", {
fields: "id,*items"
})
.then(({ order }) => {
console.log(order)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the order.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;object&#62;","optional":false,"defaultValue":"","description":"The order's details.","expandable":false,"children":[{"name":"order","type":"`StoreOrder`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
@@ -0,0 +1,210 @@
---
slug: /references/js-sdk/admin/payment
sidebar_label: payment
---
import { TypeList } from "docs-ui"
# payment - JS SDK Store Reference
This documentation provides a reference to the `sdk.store.payment` set of methods used to send requests to Medusa's Store API routes.
## listPaymentProviders
This method retrieves the payment providers available in a region, which is useful during checkout.
It sends a request to the [List Payment Providers](https://docs.medusajs.com/v2/api/store#payment-providers\_getpaymentproviders)
API route.
Related guide: [Implement payment step during checkout](https://docs.medusajs.com/v2/resources/storefront-development/checkout/payment).
### Example
To retrieve the list of payment providers for a region:
```ts
sdk.store.payment.listPaymentProviders({
region_id: "reg_123"
})
.then(({ payment_providers, count, offset, limit }) => {
console.log(payment_providers)
})
```
To configure the pagination, pass the `limit` and `offset` query parameters.
For example, to retrieve only 10 items and skip 10 items:
```ts
sdk.store.payment.listPaymentProviders({
region_id: "reg_123",
limit: 10,
offset: 10
})
.then(({ payment_providers, count, offset, limit }) => {
console.log(payment_providers)
})
```
Using the `fields` query parameter, you can specify the fields and relations to retrieve
in each provider:
```ts
sdk.store.payment.listPaymentProviders({
region_id: "reg_123",
limit: 10,
offset: 10,
fields: "id"
})
.then(({ payment_providers, count, offset, limit }) => {
console.log(payment_providers)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"query","type":"[FindParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.FindParams/page.mdx) & `StorePaymentProviderFilters`","description":"The filters to apply on the retrieved providers, along with configurations of the \nfields to retrieve in the options.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StorePaymentProviderListResponse&#62;","optional":false,"defaultValue":"","description":"The list of payment providers.","expandable":false,"children":[{"name":"StorePaymentProviderListResponse","type":"`StorePaymentProviderListResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## initiatePaymentSession
This method creates a payment session of a cart's payment collection, selecting a payment provider.
It sends a request to the [Initialize Payment Session](https://docs.medusajs.com/v2/api/store#payment-collections\_postpaymentcollectionsidpaymentsessions)
API route.
If the cart doesn't have a payment collection, a payment collection is created for the cart by
sending a request to the [Create Payment Collection](https://docs.medusajs.com/v2/api/store#payment-collections\_postpaymentcollections)
API route.
Related guide: [Implement payment step during checkout](https://docs.medusajs.com/v2/resources/storefront-development/checkout/payment).
### Example
```ts
sdk.store.payment.initiatePaymentSession(
cart, // assuming you already have the cart object.
{
provider_id: "pp_stripe_stripe",
data: {
// any data relevant for the provider.
}
}
)
.then(({ payment_collection }) => {
console.log(payment_collection)
})
```
### Parameters
<TypeList types={[{"name":"cart","type":"`StoreCart`","description":"The cart's details.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"body","type":"`StoreInitializePaymentSession`","description":"The payment session's details.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the payment collection.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StorePaymentCollectionResponse&#62;","optional":false,"defaultValue":"","description":"The payment collection's details.","expandable":false,"children":[{"name":"StorePaymentCollectionResponse","type":"`StorePaymentCollectionResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
## listPaymentProviders
This method retrieves the payment providers available in a region, which is useful during checkout.
It sends a request to the [List Payment Providers](https://docs.medusajs.com/v2/api/store#payment-providers\_getpaymentproviders)
API route.
Related guide: [Implement payment step during checkout](https://docs.medusajs.com/v2/resources/storefront-development/checkout/payment).
### Example
To retrieve the list of payment providers for a region:
```ts
sdk.store.payment.listPaymentProviders({
region_id: "reg_123"
})
.then(({ payment_providers, count, offset, limit }) => {
console.log(payment_providers)
})
```
To configure the pagination, pass the `limit` and `offset` query parameters.
For example, to retrieve only 10 items and skip 10 items:
```ts
sdk.store.payment.listPaymentProviders({
region_id: "reg_123",
limit: 10,
offset: 10
})
.then(({ payment_providers, count, offset, limit }) => {
console.log(payment_providers)
})
```
Using the `fields` query parameter, you can specify the fields and relations to retrieve
in each provider:
```ts
sdk.store.payment.listPaymentProviders({
region_id: "reg_123",
limit: 10,
offset: 10,
fields: "id"
})
.then(({ payment_providers, count, offset, limit }) => {
console.log(payment_providers)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"query","type":"[FindParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.FindParams/page.mdx) & `StorePaymentProviderFilters`","description":"The filters to apply on the retrieved providers, along with configurations of the \nfields to retrieve in the options.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StorePaymentProviderListResponse&#62;","optional":false,"defaultValue":"","description":"The list of payment providers.","expandable":false,"children":[{"name":"StorePaymentProviderListResponse","type":"`StorePaymentProviderListResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## initiatePaymentSession
This method creates a payment session of a cart's payment collection, selecting a payment provider.
It sends a request to the [Initialize Payment Session](https://docs.medusajs.com/v2/api/store#payment-collections\_postpaymentcollectionsidpaymentsessions)
API route.
If the cart doesn't have a payment collection, a payment collection is created for the cart by
sending a request to the [Create Payment Collection](https://docs.medusajs.com/v2/api/store#payment-collections\_postpaymentcollections)
API route.
Related guide: [Implement payment step during checkout](https://docs.medusajs.com/v2/resources/storefront-development/checkout/payment).
### Example
```ts
sdk.store.payment.initiatePaymentSession(
cart, // assuming you already have the cart object.
{
provider_id: "pp_stripe_stripe",
data: {
// any data relevant for the provider.
}
}
)
.then(({ payment_collection }) => {
console.log(payment_collection)
})
```
### Parameters
<TypeList types={[{"name":"cart","type":"`StoreCart`","description":"The cart's details.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"body","type":"`StoreInitializePaymentSession`","description":"The payment session's details.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the payment collection.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StorePaymentCollectionResponse&#62;","optional":false,"defaultValue":"","description":"The payment collection's details.","expandable":false,"children":[{"name":"StorePaymentCollectionResponse","type":"`StorePaymentCollectionResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
@@ -0,0 +1,212 @@
---
slug: /references/js-sdk/admin/product
sidebar_label: product
---
import { TypeList } from "docs-ui"
# product - JS SDK Store Reference
This documentation provides a reference to the `sdk.store.product` set of methods used to send requests to Medusa's Store API routes.
## list
This method retrieves a list of products. It sends a request to the
[List Products API route](https://docs.medusajs.com/v2/api/store#products\_getproducts).
Related guides:
- [How to list products in a storefront](https://docs.medusajs.com/v2/resources/storefront-development/products/list).
- [How to retrieve a product variant's prices in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/products/price)
### Example
To retrieve the list of products:
```ts
sdk.store.product.list()
.then(({ products, count, offset, limit }) => {
console.log(products)
})
```
To configure the pagination, pass the `limit` and `offset` query parameters.
For example, to retrieve only 10 items and skip 10 items:
```ts
sdk.store.product.list({
limit: 10,
offset: 10
})
.then(({ products, count, offset, limit }) => {
console.log(products)
})
```
Using the `fields` query parameter, you can specify the fields and relations to retrieve
in each product:
```ts
sdk.store.product.list({
fields: "id,*collection"
})
.then(({ products, count, offset, limit }) => {
console.log(products)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"query","type":"`StoreProductParams`","description":"Filters and pagination configurations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreProductListResponse&#62;","optional":false,"defaultValue":"","description":"The paginated list of products.","expandable":false,"children":[{"name":"StoreProductListResponse","type":"`StoreProductListResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## retrieve
This method is used to retrieve a product by its ID. It sends a request to the
[Get Product](https://docs.medusajs.com/v2/api/store#products\_getproductsid) API route.
Related guides:
- [How to retrieve a product in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/products/retrieve).
- [How to retrieve a product variant's prices in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/products/price)
### Example
To retrieve a product by its ID:
```ts
sdk.store.product.retrieve("prod_123")
.then(({ product }) => {
console.log(product)
})
```
To specify the fields and relations to retrieve:
```ts
sdk.store.product.retrieve("prod_123", {
fields: "id,*collection"
})
.then(({ product }) => {
console.log(product)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The product's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the product.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreProductResponse&#62;","optional":false,"defaultValue":"","description":"The product.","expandable":false,"children":[{"name":"StoreProductResponse","type":"`StoreProductResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
## list
This method retrieves a list of products. It sends a request to the
[List Products API route](https://docs.medusajs.com/v2/api/store#products\_getproducts).
Related guides:
- [How to list products in a storefront](https://docs.medusajs.com/v2/resources/storefront-development/products/list).
- [How to retrieve a product variant's prices in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/products/price)
### Example
To retrieve the list of products:
```ts
sdk.store.product.list()
.then(({ products, count, offset, limit }) => {
console.log(products)
})
```
To configure the pagination, pass the `limit` and `offset` query parameters.
For example, to retrieve only 10 items and skip 10 items:
```ts
sdk.store.product.list({
limit: 10,
offset: 10
})
.then(({ products, count, offset, limit }) => {
console.log(products)
})
```
Using the `fields` query parameter, you can specify the fields and relations to retrieve
in each product:
```ts
sdk.store.product.list({
fields: "id,*collection"
})
.then(({ products, count, offset, limit }) => {
console.log(products)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"query","type":"`StoreProductParams`","description":"Filters and pagination configurations.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreProductListResponse&#62;","optional":false,"defaultValue":"","description":"The paginated list of products.","expandable":false,"children":[{"name":"StoreProductListResponse","type":"`StoreProductListResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## retrieve
This method is used to retrieve a product by its ID. It sends a request to the
[Get Product](https://docs.medusajs.com/v2/api/store#products\_getproductsid) API route.
Related guides:
- [How to retrieve a product in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/products/retrieve).
- [How to retrieve a product variant's prices in the storefront](https://docs.medusajs.com/v2/resources/storefront-development/products/price)
### Example
To retrieve a product by its ID:
```ts
sdk.store.product.retrieve("prod_123")
.then(({ product }) => {
console.log(product)
})
```
To specify the fields and relations to retrieve:
```ts
sdk.store.product.retrieve("prod_123", {
fields: "id,*collection"
})
.then(({ product }) => {
console.log(product)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The product's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the product.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreProductResponse&#62;","optional":false,"defaultValue":"","description":"The product.","expandable":false,"children":[{"name":"StoreProductResponse","type":"`StoreProductResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
@@ -0,0 +1,206 @@
---
slug: /references/js-sdk/admin/region
sidebar_label: region
---
import { TypeList } from "docs-ui"
# region - JS SDK Store Reference
This documentation provides a reference to the `sdk.store.region` set of methods used to send requests to Medusa's Store API routes.
## list
This method retrieves the paginated list of regions in the store. It sends a request to the
[List Regions API route](https://docs.medusajs.com/v2/api/store#regions\_getregions).
Related guide: [How to list regions in a storefront](https://docs.medusajs.com/v2/resources/storefront-development/regions/list).
### Example
To retrieve the list of regions:
```ts
sdk.store.region.list()
.then(({ regions, count, limit, offset }) => {
console.log(regions)
})
```
To configure the pagination, pass the `limit` and `offset` query parameters.
For example, to retrieve only 10 items and skip 10 items:
```ts
sdk.store.region.list({
limit: 10,
offset: 10
})
.then(({ regions, count, limit, offset }) => {
console.log(regions)
})
```
Using the `fields` query parameter, you can specify the fields and relations to retrieve
in each region:
```ts
sdk.store.region.list({
fields: "id,*countries"
})
.then(({ regions, count, limit, offset }) => {
console.log(regions)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"query","type":"[FindParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.FindParams/page.mdx) & `StoreRegionFilters`","description":"Filters and pagination configurations.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreRegionListResponse&#62;","optional":false,"defaultValue":"","description":"The paginated list of regions.","expandable":false,"children":[{"name":"StoreRegionListResponse","type":"`StoreRegionListResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## retrieve
This method retrieves a region by its ID. It sends a request to the [Get Region](https://docs.medusajs.com/v2/api/store#regions\_getregionsid)
API route.
Related guide: [Store and retrieve regions in a storefront](https://docs.medusajs.com/v2/resources/storefront-development/regions/store-retrieve-region).
### Example
To retrieve a region by its ID:
```ts
sdk.store.region.retrieve("reg_123")
.then(({ region }) => {
console.log(region)
})
```
To specify the fields and relations to retrieve:
```ts
sdk.store.region.retrieve(
"reg_123",
{
fields: "id,*countries"
}
)
.then(({ region }) => {
console.log(region)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The region's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the region.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreRegionResponse&#62;","optional":false,"defaultValue":"","description":"The region.","expandable":false,"children":[{"name":"StoreRegionResponse","type":"`StoreRegionResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
## list
This method retrieves the paginated list of regions in the store. It sends a request to the
[List Regions API route](https://docs.medusajs.com/v2/api/store#regions\_getregions).
Related guide: [How to list regions in a storefront](https://docs.medusajs.com/v2/resources/storefront-development/regions/list).
### Example
To retrieve the list of regions:
```ts
sdk.store.region.list()
.then(({ regions, count, limit, offset }) => {
console.log(regions)
})
```
To configure the pagination, pass the `limit` and `offset` query parameters.
For example, to retrieve only 10 items and skip 10 items:
```ts
sdk.store.region.list({
limit: 10,
offset: 10
})
.then(({ regions, count, limit, offset }) => {
console.log(regions)
})
```
Using the `fields` query parameter, you can specify the fields and relations to retrieve
in each region:
```ts
sdk.store.region.list({
fields: "id,*countries"
})
.then(({ regions, count, limit, offset }) => {
console.log(regions)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"query","type":"[FindParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.FindParams/page.mdx) & `StoreRegionFilters`","description":"Filters and pagination configurations.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"limit","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"offset","type":"`number`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"order","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreRegionListResponse&#62;","optional":false,"defaultValue":"","description":"The paginated list of regions.","expandable":false,"children":[{"name":"StoreRegionListResponse","type":"`StoreRegionListResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
___
## retrieve
This method retrieves a region by its ID. It sends a request to the [Get Region](https://docs.medusajs.com/v2/api/store#regions\_getregionsid)
API route.
Related guide: [Store and retrieve regions in a storefront](https://docs.medusajs.com/v2/resources/storefront-development/regions/store-retrieve-region).
### Example
To retrieve a region by its ID:
```ts
sdk.store.region.retrieve("reg_123")
.then(({ region }) => {
console.log(region)
})
```
To specify the fields and relations to retrieve:
```ts
sdk.store.region.retrieve(
"reg_123",
{
fields: "id,*countries"
}
)
.then(({ region }) => {
console.log(region)
})
```
Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations).
### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The region's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"[SelectParams](../../../../../types/HttpTypes/interfaces/types.HttpTypes.SelectParams/page.mdx)","description":"Configure the fields to retrieve in the region.","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"fields","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"headers","type":"[ClientHeaders](../../../../admin/types/js_sdk.admin.ClientHeaders/page.mdx)","description":"Headers to pass in the request","optional":true,"defaultValue":"","expandable":false,"children":[{"name":"tags","type":"`string`[]","description":"Tags to cache data under for Next.js applications.\n\nLearn more in [Next.js's documentation](https://nextjs.org/docs/app/building-your-application/caching#fetch-optionsnexttags-and-revalidatetag).","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;StoreRegionResponse&#62;","optional":false,"defaultValue":"","description":"The region.","expandable":false,"children":[{"name":"StoreRegionResponse","type":"`StoreRegionResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="__type"/>
@@ -0,0 +1,21 @@
---
slug: /references/js-sdk/store
---
import { TypeList } from "docs-ui"
# JS SDK Store Reference
The `sdk.store` class provides methods to send requests to Medusa's Store API routes.
## Properties
- [region](../../Store/properties/js_sdk.store.Store.region/page.mdx)
- [collection](../../Store/properties/js_sdk.store.Store.collection/page.mdx)
- [category](../../Store/properties/js_sdk.store.Store.category/page.mdx)
- [product](../../Store/properties/js_sdk.store.Store.product/page.mdx)
- [cart](../../Store/properties/js_sdk.store.Store.cart/page.mdx)
- [fulfillment](../../Store/properties/js_sdk.store.Store.fulfillment/page.mdx)
- [payment](../../Store/properties/js_sdk.store.Store.payment/page.mdx)
- [order](../../Store/properties/js_sdk.store.Store.order/page.mdx)
- [customer](../../Store/properties/js_sdk.store.Store.customer/page.mdx)