chore(docs): Generated References (automated) (#8317)

Co-authored-by: kodiakhq <kodiakhq@users.noreply.github.com>
This commit is contained in:
github-actions[bot]
2024-07-29 09:41:15 +02:00
committed by GitHub
parent e40b4c6183
commit cb33ec5cf1
230 changed files with 54378 additions and 83917 deletions

View File

@@ -3571,246 +3571,6 @@ export const filesMap = [
"filePath": "/www/apps/resources/references/inventory_next_models/classes/inventory_next_models.ReservationItem/page.mdx",
"pathname": "/references/inventory_next_models/classes/inventory_next_models.ReservationItem"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AddressesResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AddressesResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.Admin/page.mdx",
"pathname": "/references/js_client/classes/js_client.Admin"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminAuthResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminAuthResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminBatchJobsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminBatchJobsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminCollectionsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminCollectionsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminCurrenciesResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminCurrenciesResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminCustomResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminCustomResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminCustomerGroupsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminCustomerGroupsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminCustomersResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminCustomersResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminDiscountsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminDiscountsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminDraftOrdersResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminDraftOrdersResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminGiftCardsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminGiftCardsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminInventoryItemsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminInventoryItemsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminInvitesResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminInvitesResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminNotesResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminNotesResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminNotificationsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminNotificationsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminOrderEditsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminOrderEditsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminOrdersResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminOrdersResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminPaymentCollectionsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminPaymentCollectionsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminPaymentsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminPaymentsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminPriceListResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminPriceListResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminProductCategoriesResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminProductCategoriesResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminProductTagsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminProductTagsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminProductTypesResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminProductTypesResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminProductsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminProductsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminPublishableApiKeyResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminPublishableApiKeyResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminRegionsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminRegionsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminReservationsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminReservationsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminReturnReasonsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminReturnReasonsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminReturnsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminReturnsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminSalesChannelsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminSalesChannelsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminShippingOptionsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminShippingOptionsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminShippingProfilesResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminShippingProfilesResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminStockLocationsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminStockLocationsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminStoresResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminStoresResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminSwapsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminSwapsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminTaxRatesResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminTaxRatesResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminUploadsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminUploadsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminUsersResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminUsersResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminVariantsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AdminVariantsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AuthResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.AuthResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.CartsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.CartsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.CollectionsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.CollectionsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.CustomersResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.CustomersResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.GiftCardsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.GiftCardsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.LineItemsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.LineItemsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.OrderEditsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.OrderEditsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.OrdersResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.OrdersResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.PaymentCollectionsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.PaymentCollectionsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.PaymentMethodsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.PaymentMethodsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.ProductCategoriesResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.ProductCategoriesResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.ProductTagsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.ProductTagsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.ProductTypesResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.ProductTypesResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.ProductVariantsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.ProductVariantsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.ProductsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.ProductsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.RegionsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.RegionsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.ReturnReasonsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.ReturnReasonsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.ReturnsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.ReturnsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.ShippingOptionsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.ShippingOptionsResource"
},
{
"filePath": "/www/apps/resources/references/js_client/classes/js_client.SwapsResource/page.mdx",
"pathname": "/references/js_client/classes/js_client.SwapsResource"
},
{
"filePath": "/www/apps/resources/references/medusa/interfaces/medusa.AuthContext/page.mdx",
"pathname": "/references/medusa/interfaces/medusa.AuthContext"
@@ -3911,418 +3671,6 @@ export const filesMap = [
"filePath": "/www/apps/resources/references/medusa_config/types/medusa_config.PluginDetails/page.mdx",
"pathname": "/references/medusa_config/types/medusa_config.PluginDetails"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Auth/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Auth"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Batch_Jobs/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Batch_Jobs"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Claims/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Claims"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Currencies/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Currencies"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Custom/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Custom"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Customer_Groups/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Customer_Groups"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Customers/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Customers"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Discounts/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Discounts"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Draft_Orders/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Draft_Orders"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Gift_Cards/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Gift_Cards"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Inventory_Items/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Inventory_Items"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Invites/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Invites"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Notes/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Notes"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Notifications/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Notifications"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Order_Edits/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Order_Edits"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Orders/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Orders"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Payment_Collections/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Payment_Collections"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Payments/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Payments"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Price_Lists/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Price_Lists"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Product_Categories/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Product_Categories"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Product_Collections/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Product_Collections"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Product_Tags/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Product_Tags"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Product_Types/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Product_Types"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Product_Variants/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Product_Variants"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Products/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Products"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Publishable_API_Keys/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Publishable_API_Keys"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Regions/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Regions"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Reservations/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Reservations"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Return_Reasons/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Return_Reasons"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Returns/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Returns"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Sales_Channels/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Sales_Channels"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Shipping_Options/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Shipping_Options"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Shipping_Profiles/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Shipping_Profiles"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Stock_Locations/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Stock_Locations"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Stores/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Stores"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Swaps/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Swaps"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Tax_Rates/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Tax_Rates"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Uploads/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Uploads"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Users/page.mdx",
"pathname": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Users"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Carts/page.mdx",
"pathname": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Carts"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Customers/page.mdx",
"pathname": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Customers"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Gift_Cards/page.mdx",
"pathname": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Gift_Cards"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Line_Items/page.mdx",
"pathname": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Line_Items"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Order_Edits/page.mdx",
"pathname": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Order_Edits"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Orders/page.mdx",
"pathname": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Orders"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Payment_Collections/page.mdx",
"pathname": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Payment_Collections"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Product_Categories/page.mdx",
"pathname": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Product_Categories"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Product_Collections/page.mdx",
"pathname": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Product_Collections"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Product_Tags/page.mdx",
"pathname": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Product_Tags"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Product_Types/page.mdx",
"pathname": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Product_Types"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Products/page.mdx",
"pathname": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Products"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Regions/page.mdx",
"pathname": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Regions"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Return_Reasons/page.mdx",
"pathname": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Return_Reasons"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Returns/page.mdx",
"pathname": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Returns"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Shipping_Options/page.mdx",
"pathname": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Shipping_Options"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Swaps/page.mdx",
"pathname": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Swaps"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/medusa_react.Hooks.Admin/page.mdx",
"pathname": "/references/medusa_react/Hooks/medusa_react.Hooks.Admin"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Hooks/medusa_react.Hooks.Store/page.mdx",
"pathname": "/references/medusa_react/Hooks/medusa_react.Hooks.Store"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Providers/medusa_react.Providers.Cart/page.mdx",
"pathname": "/references/medusa_react/Providers/medusa_react.Providers.Cart"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Providers/medusa_react.Providers.Medusa/page.mdx",
"pathname": "/references/medusa_react/Providers/medusa_react.Providers.Medusa"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Providers/medusa_react.Providers.Session_Cart/page.mdx",
"pathname": "/references/medusa_react/Providers/medusa_react.Providers.Session_Cart"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Utilities/functions/medusa_react.Utilities.computeAmount/page.mdx",
"pathname": "/references/medusa_react/Utilities/functions/medusa_react.Utilities.computeAmount"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Utilities/functions/medusa_react.Utilities.computeVariantPrice/page.mdx",
"pathname": "/references/medusa_react/Utilities/functions/medusa_react.Utilities.computeVariantPrice"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Utilities/functions/medusa_react.Utilities.formatAmount/page.mdx",
"pathname": "/references/medusa_react/Utilities/functions/medusa_react.Utilities.formatAmount"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Utilities/functions/medusa_react.Utilities.formatVariantPrice/page.mdx",
"pathname": "/references/medusa_react/Utilities/functions/medusa_react.Utilities.formatVariantPrice"
},
{
"filePath": "/www/apps/resources/references/medusa_react/Utilities/functions/medusa_react.Utilities.getVariantPrice/page.mdx",
"pathname": "/references/medusa_react/Utilities/functions/medusa_react.Utilities.getVariantPrice"
},
{
"filePath": "/www/apps/resources/references/medusa_react/interfaces/medusa_react.CartContext/page.mdx",
"pathname": "/references/medusa_react/interfaces/medusa_react.CartContext"
},
{
"filePath": "/www/apps/resources/references/medusa_react/interfaces/medusa_react.CartProps/page.mdx",
"pathname": "/references/medusa_react/interfaces/medusa_react.CartProps"
},
{
"filePath": "/www/apps/resources/references/medusa_react/interfaces/medusa_react.ComputeVariantPriceParams/page.mdx",
"pathname": "/references/medusa_react/interfaces/medusa_react.ComputeVariantPriceParams"
},
{
"filePath": "/www/apps/resources/references/medusa_react/interfaces/medusa_react.FormatVariantPriceParams/page.mdx",
"pathname": "/references/medusa_react/interfaces/medusa_react.FormatVariantPriceParams"
},
{
"filePath": "/www/apps/resources/references/medusa_react/interfaces/medusa_react.Item/page.mdx",
"pathname": "/references/medusa_react/interfaces/medusa_react.Item"
},
{
"filePath": "/www/apps/resources/references/medusa_react/interfaces/medusa_react.MedusaContextState/page.mdx",
"pathname": "/references/medusa_react/interfaces/medusa_react.MedusaContextState"
},
{
"filePath": "/www/apps/resources/references/medusa_react/interfaces/medusa_react.MedusaProviderProps/page.mdx",
"pathname": "/references/medusa_react/interfaces/medusa_react.MedusaProviderProps"
},
{
"filePath": "/www/apps/resources/references/medusa_react/interfaces/medusa_react.SessionCartContextState/page.mdx",
"pathname": "/references/medusa_react/interfaces/medusa_react.SessionCartContextState"
},
{
"filePath": "/www/apps/resources/references/medusa_react/interfaces/medusa_react.SessionCartProviderProps/page.mdx",
"pathname": "/references/medusa_react/interfaces/medusa_react.SessionCartProviderProps"
},
{
"filePath": "/www/apps/resources/references/medusa_react/interfaces/medusa_react.SessionCartState/page.mdx",
"pathname": "/references/medusa_react/interfaces/medusa_react.SessionCartState"
},
{
"filePath": "/www/apps/resources/references/medusa_react/medusa_react.Hooks/page.mdx",
"pathname": "/references/medusa_react/medusa_react.Hooks"
},
{
"filePath": "/www/apps/resources/references/medusa_react/medusa_react.Providers/page.mdx",
"pathname": "/references/medusa_react/medusa_react.Providers"
},
{
"filePath": "/www/apps/resources/references/medusa_react/medusa_react.Utilities/page.mdx",
"pathname": "/references/medusa_react/medusa_react.Utilities"
},
{
"filePath": "/www/apps/resources/references/medusa_react/types/medusa_react.AdminCancelClaimFulfillmentReq/page.mdx",
"pathname": "/references/medusa_react/types/medusa_react.AdminCancelClaimFulfillmentReq"
},
{
"filePath": "/www/apps/resources/references/medusa_react/types/medusa_react.AdminCancelSwapFulfillmentReq/page.mdx",
"pathname": "/references/medusa_react/types/medusa_react.AdminCancelSwapFulfillmentReq"
},
{
"filePath": "/www/apps/resources/references/medusa_react/types/medusa_react.AdminCreateSwapShipmentReq/page.mdx",
"pathname": "/references/medusa_react/types/medusa_react.AdminCreateSwapShipmentReq"
},
{
"filePath": "/www/apps/resources/references/medusa_react/types/medusa_react.AdminDraftOrderUpdateLineItemReq/page.mdx",
"pathname": "/references/medusa_react/types/medusa_react.AdminDraftOrderUpdateLineItemReq"
},
{
"filePath": "/www/apps/resources/references/medusa_react/types/medusa_react.AdminFulfillClaimReq/page.mdx",
"pathname": "/references/medusa_react/types/medusa_react.AdminFulfillClaimReq"
},
{
"filePath": "/www/apps/resources/references/medusa_react/types/medusa_react.AdminFulfillSwapReq/page.mdx",
"pathname": "/references/medusa_react/types/medusa_react.AdminFulfillSwapReq"
},
{
"filePath": "/www/apps/resources/references/medusa_react/types/medusa_react.AdminUpdateClaimReq/page.mdx",
"pathname": "/references/medusa_react/types/medusa_react.AdminUpdateClaimReq"
},
{
"filePath": "/www/apps/resources/references/medusa_react/types/medusa_react.AdminUpdateLocationLevelReq/page.mdx",
"pathname": "/references/medusa_react/types/medusa_react.AdminUpdateLocationLevelReq"
},
{
"filePath": "/www/apps/resources/references/medusa_react/types/medusa_react.AdminUpdateProductOptionReq/page.mdx",
"pathname": "/references/medusa_react/types/medusa_react.AdminUpdateProductOptionReq"
},
{
"filePath": "/www/apps/resources/references/medusa_react/types/medusa_react.AdminUpdateVariantReq/page.mdx",
"pathname": "/references/medusa_react/types/medusa_react.AdminUpdateVariantReq"
},
{
"filePath": "/www/apps/resources/references/medusa_react/types/medusa_react.Cart/page.mdx",
"pathname": "/references/medusa_react/types/medusa_react.Cart"
},
{
"filePath": "/www/apps/resources/references/medusa_react/types/medusa_react.ComputeAmountParams/page.mdx",
"pathname": "/references/medusa_react/types/medusa_react.ComputeAmountParams"
},
{
"filePath": "/www/apps/resources/references/medusa_react/types/medusa_react.CreateCartReq/page.mdx",
"pathname": "/references/medusa_react/types/medusa_react.CreateCartReq"
},
{
"filePath": "/www/apps/resources/references/medusa_react/types/medusa_react.DeletePaymentSessionMutationData/page.mdx",
"pathname": "/references/medusa_react/types/medusa_react.DeletePaymentSessionMutationData"
},
{
"filePath": "/www/apps/resources/references/medusa_react/types/medusa_react.FormatAmountParams/page.mdx",
"pathname": "/references/medusa_react/types/medusa_react.FormatAmountParams"
},
{
"filePath": "/www/apps/resources/references/medusa_react/types/medusa_react.ProductVariant/page.mdx",
"pathname": "/references/medusa_react/types/medusa_react.ProductVariant"
},
{
"filePath": "/www/apps/resources/references/medusa_react/types/medusa_react.ProductVariantInfo/page.mdx",
"pathname": "/references/medusa_react/types/medusa_react.ProductVariantInfo"
},
{
"filePath": "/www/apps/resources/references/medusa_react/types/medusa_react.RefreshPaymentSessionMutationData/page.mdx",
"pathname": "/references/medusa_react/types/medusa_react.RefreshPaymentSessionMutationData"
},
{
"filePath": "/www/apps/resources/references/medusa_react/types/medusa_react.RegionInfo/page.mdx",
"pathname": "/references/medusa_react/types/medusa_react.RegionInfo"
},
{
"filePath": "/www/apps/resources/references/medusa_react/types/medusa_react.TQueryKey/page.mdx",
"pathname": "/references/medusa_react/types/medusa_react.TQueryKey"
},
{
"filePath": "/www/apps/resources/references/medusa_react/types/medusa_react.UpdateLineItemReq/page.mdx",
"pathname": "/references/medusa_react/types/medusa_react.UpdateLineItemReq"
},
{
"filePath": "/www/apps/resources/references/medusa_react/types/medusa_react.UpdateMeReq/page.mdx",
"pathname": "/references/medusa_react/types/medusa_react.UpdateMeReq"
},
{
"filePath": "/www/apps/resources/references/medusa_react/types/medusa_react.UpdatePaymentSessionReq/page.mdx",
"pathname": "/references/medusa_react/types/medusa_react.UpdatePaymentSessionReq"
},
{
"filePath": "/www/apps/resources/references/medusa_react/types/medusa_react.UseQueryOptionsWrapper/page.mdx",
"pathname": "/references/medusa_react/types/medusa_react.UseQueryOptionsWrapper"
},
{
"filePath": "/www/apps/resources/references/modules/api_key/page.mdx",
"pathname": "/references/modules/api_key"
@@ -4395,10 +3743,6 @@ export const filesMap = [
"filePath": "/www/apps/resources/references/modules/inventory_next_models/page.mdx",
"pathname": "/references/modules/inventory_next_models"
},
{
"filePath": "/www/apps/resources/references/modules/js_client/page.mdx",
"pathname": "/references/modules/js_client"
},
{
"filePath": "/www/apps/resources/references/modules/medusa/page.mdx",
"pathname": "/references/modules/medusa"
@@ -4407,10 +3751,6 @@ export const filesMap = [
"filePath": "/www/apps/resources/references/modules/medusa_config/page.mdx",
"pathname": "/references/modules/medusa_config"
},
{
"filePath": "/www/apps/resources/references/modules/medusa_react/page.mdx",
"pathname": "/references/modules/medusa_react"
},
{
"filePath": "/www/apps/resources/references/modules/notification/page.mdx",
"pathname": "/references/modules/notification"
@@ -9643,6 +8983,10 @@ export const filesMap = [
"filePath": "/www/apps/resources/references/types/HttpTypes/interfaces/types.HttpTypes.AdminUpdateReturnItems/page.mdx",
"pathname": "/references/types/HttpTypes/interfaces/types.HttpTypes.AdminUpdateReturnItems"
},
{
"filePath": "/www/apps/resources/references/types/HttpTypes/interfaces/types.HttpTypes.AdminUpdateReturnRequest/page.mdx",
"pathname": "/references/types/HttpTypes/interfaces/types.HttpTypes.AdminUpdateReturnRequest"
},
{
"filePath": "/www/apps/resources/references/types/HttpTypes/interfaces/types.HttpTypes.AdminUpdateReturnShipping/page.mdx",
"pathname": "/references/types/HttpTypes/interfaces/types.HttpTypes.AdminUpdateReturnShipping"

View File

@@ -1294,646 +1294,11 @@ export const slugChanges = [
"newSlug": "/references/inventory-next/models/ReservationItem",
"filePath": "/www/apps/resources/references/inventory_next_models/classes/inventory_next_models.ReservationItem/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AddressesResource",
"newSlug": "/references/js-client/AddressesResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AddressesResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.Admin",
"newSlug": "/references/js-client/Admin",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.Admin/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminAuthResource",
"newSlug": "/references/js-client/AdminAuthResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminAuthResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminBatchJobsResource",
"newSlug": "/references/js-client/AdminBatchJobsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminBatchJobsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminCollectionsResource",
"newSlug": "/references/js-client/AdminCollectionsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminCollectionsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminCurrenciesResource",
"newSlug": "/references/js-client/AdminCurrenciesResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminCurrenciesResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminCustomResource",
"newSlug": "/references/js-client/AdminCustomResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminCustomResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminCustomerGroupsResource",
"newSlug": "/references/js-client/AdminCustomerGroupsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminCustomerGroupsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminCustomersResource",
"newSlug": "/references/js-client/AdminCustomersResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminCustomersResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminDiscountsResource",
"newSlug": "/references/js-client/AdminDiscountsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminDiscountsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminDraftOrdersResource",
"newSlug": "/references/js-client/AdminDraftOrdersResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminDraftOrdersResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminGiftCardsResource",
"newSlug": "/references/js-client/AdminGiftCardsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminGiftCardsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminInventoryItemsResource",
"newSlug": "/references/js-client/AdminInventoryItemsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminInventoryItemsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminInvitesResource",
"newSlug": "/references/js-client/AdminInvitesResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminInvitesResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminNotesResource",
"newSlug": "/references/js-client/AdminNotesResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminNotesResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminNotificationsResource",
"newSlug": "/references/js-client/AdminNotificationsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminNotificationsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminOrderEditsResource",
"newSlug": "/references/js-client/AdminOrderEditsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminOrderEditsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminOrdersResource",
"newSlug": "/references/js-client/AdminOrdersResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminOrdersResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminPaymentCollectionsResource",
"newSlug": "/references/js-client/AdminPaymentCollectionsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminPaymentCollectionsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminPaymentsResource",
"newSlug": "/references/js-client/AdminPaymentsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminPaymentsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminPriceListResource",
"newSlug": "/references/js-client/AdminPriceListResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminPriceListResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminProductCategoriesResource",
"newSlug": "/references/js-client/AdminProductCategoriesResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminProductCategoriesResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminProductTagsResource",
"newSlug": "/references/js-client/AdminProductTagsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminProductTagsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminProductTypesResource",
"newSlug": "/references/js-client/AdminProductTypesResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminProductTypesResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminProductsResource",
"newSlug": "/references/js-client/AdminProductsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminProductsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminPublishableApiKeyResource",
"newSlug": "/references/js-client/AdminPublishableApiKeyResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminPublishableApiKeyResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminRegionsResource",
"newSlug": "/references/js-client/AdminRegionsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminRegionsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminReservationsResource",
"newSlug": "/references/js-client/AdminReservationsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminReservationsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminReturnReasonsResource",
"newSlug": "/references/js-client/AdminReturnReasonsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminReturnReasonsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminReturnsResource",
"newSlug": "/references/js-client/AdminReturnsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminReturnsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminSalesChannelsResource",
"newSlug": "/references/js-client/AdminSalesChannelsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminSalesChannelsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminShippingOptionsResource",
"newSlug": "/references/js-client/AdminShippingOptionsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminShippingOptionsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminShippingProfilesResource",
"newSlug": "/references/js-client/AdminShippingProfilesResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminShippingProfilesResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminStockLocationsResource",
"newSlug": "/references/js-client/AdminStockLocationsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminStockLocationsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminStoresResource",
"newSlug": "/references/js-client/AdminStoresResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminStoresResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminSwapsResource",
"newSlug": "/references/js-client/AdminSwapsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminSwapsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminTaxRatesResource",
"newSlug": "/references/js-client/AdminTaxRatesResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminTaxRatesResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminUploadsResource",
"newSlug": "/references/js-client/AdminUploadsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminUploadsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminUsersResource",
"newSlug": "/references/js-client/AdminUsersResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminUsersResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AdminVariantsResource",
"newSlug": "/references/js-client/AdminVariantsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AdminVariantsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.AuthResource",
"newSlug": "/references/js-client/AuthResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.AuthResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.CartsResource",
"newSlug": "/references/js-client/CartsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.CartsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.CollectionsResource",
"newSlug": "/references/js-client/CollectionsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.CollectionsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.CustomersResource",
"newSlug": "/references/js-client/CustomersResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.CustomersResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.GiftCardsResource",
"newSlug": "/references/js-client/GiftCardsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.GiftCardsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.LineItemsResource",
"newSlug": "/references/js-client/LineItemsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.LineItemsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.OrderEditsResource",
"newSlug": "/references/js-client/OrderEditsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.OrderEditsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.OrdersResource",
"newSlug": "/references/js-client/OrdersResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.OrdersResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.PaymentCollectionsResource",
"newSlug": "/references/js-client/PaymentCollectionsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.PaymentCollectionsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.PaymentMethodsResource",
"newSlug": "/references/js-client/PaymentMethodsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.PaymentMethodsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.ProductCategoriesResource",
"newSlug": "/references/js-client/ProductCategoriesResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.ProductCategoriesResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.ProductTagsResource",
"newSlug": "/references/js-client/ProductTagsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.ProductTagsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.ProductTypesResource",
"newSlug": "/references/js-client/ProductTypesResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.ProductTypesResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.ProductVariantsResource",
"newSlug": "/references/js-client/ProductVariantsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.ProductVariantsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.ProductsResource",
"newSlug": "/references/js-client/ProductsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.ProductsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.RegionsResource",
"newSlug": "/references/js-client/RegionsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.RegionsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.ReturnReasonsResource",
"newSlug": "/references/js-client/ReturnReasonsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.ReturnReasonsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.ReturnsResource",
"newSlug": "/references/js-client/ReturnsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.ReturnsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.ShippingOptionsResource",
"newSlug": "/references/js-client/ShippingOptionsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.ShippingOptionsResource/page.mdx"
},
{
"origSlug": "/references/js_client/classes/js_client.SwapsResource",
"newSlug": "/references/js-client/SwapsResource",
"filePath": "/www/apps/resources/references/js_client/classes/js_client.SwapsResource/page.mdx"
},
{
"origSlug": "/references/medusa_config/interfaces/medusa_config.ConfigModule",
"newSlug": "/references/medusa-config",
"filePath": "/www/apps/resources/references/medusa_config/interfaces/medusa_config.ConfigModule/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Auth",
"newSlug": "/references/medusa-react/hooks/admin/auth",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Auth/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Batch_Jobs",
"newSlug": "/references/medusa-react/hooks/admin/batch_jobs",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Batch_Jobs/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Claims",
"newSlug": "/references/medusa-react/hooks/admin/claims",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Claims/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Currencies",
"newSlug": "/references/medusa-react/hooks/admin/currencies",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Currencies/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Custom",
"newSlug": "/references/medusa-react/hooks/admin/custom",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Custom/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Customer_Groups",
"newSlug": "/references/medusa-react/hooks/admin/customer_groups",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Customer_Groups/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Customers",
"newSlug": "/references/medusa-react/hooks/admin/customers",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Customers/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Discounts",
"newSlug": "/references/medusa-react/hooks/admin/discounts",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Discounts/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Draft_Orders",
"newSlug": "/references/medusa-react/hooks/admin/draft_orders",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Draft_Orders/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Gift_Cards",
"newSlug": "/references/medusa-react/hooks/admin/gift_cards",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Gift_Cards/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Inventory_Items",
"newSlug": "/references/medusa-react/hooks/admin/inventory_items",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Inventory_Items/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Invites",
"newSlug": "/references/medusa-react/hooks/admin/invites",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Invites/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Notes",
"newSlug": "/references/medusa-react/hooks/admin/notes",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Notes/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Notifications",
"newSlug": "/references/medusa-react/hooks/admin/notifications",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Notifications/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Order_Edits",
"newSlug": "/references/medusa-react/hooks/admin/order_edits",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Order_Edits/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Orders",
"newSlug": "/references/medusa-react/hooks/admin/orders",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Orders/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Payment_Collections",
"newSlug": "/references/medusa-react/hooks/admin/payment_collections",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Payment_Collections/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Payments",
"newSlug": "/references/medusa-react/hooks/admin/payments",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Payments/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Price_Lists",
"newSlug": "/references/medusa-react/hooks/admin/price_lists",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Price_Lists/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Product_Categories",
"newSlug": "/references/medusa-react/hooks/admin/product_categories",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Product_Categories/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Product_Collections",
"newSlug": "/references/medusa-react/hooks/admin/product_collections",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Product_Collections/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Product_Tags",
"newSlug": "/references/medusa-react/hooks/admin/product_tags",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Product_Tags/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Product_Types",
"newSlug": "/references/medusa-react/hooks/admin/product_types",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Product_Types/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Product_Variants",
"newSlug": "/references/medusa-react/hooks/admin/product_variants",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Product_Variants/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Products",
"newSlug": "/references/medusa-react/hooks/admin/products",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Products/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Publishable_API_Keys",
"newSlug": "/references/medusa-react/hooks/admin/publishable_api_keys",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Publishable_API_Keys/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Regions",
"newSlug": "/references/medusa-react/hooks/admin/regions",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Regions/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Reservations",
"newSlug": "/references/medusa-react/hooks/admin/reservations",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Reservations/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Return_Reasons",
"newSlug": "/references/medusa-react/hooks/admin/return_reasons",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Return_Reasons/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Returns",
"newSlug": "/references/medusa-react/hooks/admin/returns",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Returns/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Sales_Channels",
"newSlug": "/references/medusa-react/hooks/admin/sales_channels",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Sales_Channels/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Shipping_Options",
"newSlug": "/references/medusa-react/hooks/admin/shipping_options",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Shipping_Options/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Shipping_Profiles",
"newSlug": "/references/medusa-react/hooks/admin/shipping_profiles",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Shipping_Profiles/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Stock_Locations",
"newSlug": "/references/medusa-react/hooks/admin/stock_locations",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Stock_Locations/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Stores",
"newSlug": "/references/medusa-react/hooks/admin/stores",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Stores/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Swaps",
"newSlug": "/references/medusa-react/hooks/admin/swaps",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Swaps/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Tax_Rates",
"newSlug": "/references/medusa-react/hooks/admin/tax_rates",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Tax_Rates/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Uploads",
"newSlug": "/references/medusa-react/hooks/admin/uploads",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Uploads/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Users",
"newSlug": "/references/medusa-react/hooks/admin/users",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Admin/medusa_react.Hooks.Admin.Users/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Carts",
"newSlug": "/references/medusa-react/hooks/store/carts",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Carts/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Customers",
"newSlug": "/references/medusa-react/hooks/store/customers",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Customers/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Gift_Cards",
"newSlug": "/references/medusa-react/hooks/store/gift_cards",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Gift_Cards/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Line_Items",
"newSlug": "/references/medusa-react/hooks/store/line_items",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Line_Items/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Order_Edits",
"newSlug": "/references/medusa-react/hooks/store/order_edits",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Order_Edits/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Orders",
"newSlug": "/references/medusa-react/hooks/store/orders",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Orders/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Payment_Collections",
"newSlug": "/references/medusa-react/hooks/store/payment_collections",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Payment_Collections/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Product_Categories",
"newSlug": "/references/medusa-react/hooks/store/product_categories",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Product_Categories/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Product_Collections",
"newSlug": "/references/medusa-react/hooks/store/product_collections",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Product_Collections/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Product_Tags",
"newSlug": "/references/medusa-react/hooks/store/product_tags",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Product_Tags/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Product_Types",
"newSlug": "/references/medusa-react/hooks/store/product_types",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Product_Types/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Products",
"newSlug": "/references/medusa-react/hooks/store/products",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Products/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Regions",
"newSlug": "/references/medusa-react/hooks/store/regions",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Regions/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Return_Reasons",
"newSlug": "/references/medusa-react/hooks/store/return_reasons",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Return_Reasons/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Returns",
"newSlug": "/references/medusa-react/hooks/store/returns",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Returns/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Shipping_Options",
"newSlug": "/references/medusa-react/hooks/store/shipping_options",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Shipping_Options/page.mdx"
},
{
"origSlug": "/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Swaps",
"newSlug": "/references/medusa-react/hooks/store/swaps",
"filePath": "/www/apps/resources/references/medusa_react/Hooks/Store/medusa_react.Hooks.Store.Swaps/page.mdx"
},
{
"origSlug": "/references/medusa_react/Providers/medusa_react.Providers.Cart",
"newSlug": "/references/medusa-react/providers/cart",
"filePath": "/www/apps/resources/references/medusa_react/Providers/medusa_react.Providers.Cart/page.mdx"
},
{
"origSlug": "/references/medusa_react/Providers/medusa_react.Providers.Medusa",
"newSlug": "/references/medusa-react/providers/medusa",
"filePath": "/www/apps/resources/references/medusa_react/Providers/medusa_react.Providers.Medusa/page.mdx"
},
{
"origSlug": "/references/medusa_react/Providers/medusa_react.Providers.Session_Cart",
"newSlug": "/references/medusa-react/providers/session_cart",
"filePath": "/www/apps/resources/references/medusa_react/Providers/medusa_react.Providers.Session_Cart/page.mdx"
},
{
"origSlug": "/references/medusa_react/Utilities/functions/medusa_react.Utilities.computeAmount",
"newSlug": "/references/medusa-react/utilities/computeAmount",
"filePath": "/www/apps/resources/references/medusa_react/Utilities/functions/medusa_react.Utilities.computeAmount/page.mdx"
},
{
"origSlug": "/references/medusa_react/Utilities/functions/medusa_react.Utilities.computeVariantPrice",
"newSlug": "/references/medusa-react/utilities/computeVariantPrice",
"filePath": "/www/apps/resources/references/medusa_react/Utilities/functions/medusa_react.Utilities.computeVariantPrice/page.mdx"
},
{
"origSlug": "/references/medusa_react/Utilities/functions/medusa_react.Utilities.formatAmount",
"newSlug": "/references/medusa-react/utilities/formatAmount",
"filePath": "/www/apps/resources/references/medusa_react/Utilities/functions/medusa_react.Utilities.formatAmount/page.mdx"
},
{
"origSlug": "/references/medusa_react/Utilities/functions/medusa_react.Utilities.formatVariantPrice",
"newSlug": "/references/medusa-react/utilities/formatVariantPrice",
"filePath": "/www/apps/resources/references/medusa_react/Utilities/functions/medusa_react.Utilities.formatVariantPrice/page.mdx"
},
{
"origSlug": "/references/medusa_react/Utilities/functions/medusa_react.Utilities.getVariantPrice",
"newSlug": "/references/medusa-react/utilities/getVariantPrice",
"filePath": "/www/apps/resources/references/medusa_react/Utilities/functions/medusa_react.Utilities.getVariantPrice/page.mdx"
},
{
"origSlug": "/references/medusa_react/medusa_react.Hooks",
"newSlug": "/references/medusa-react/hooks",
"filePath": "/www/apps/resources/references/medusa_react/medusa_react.Hooks/page.mdx"
},
{
"origSlug": "/references/medusa_react/medusa_react.Providers",
"newSlug": "/references/medusa-react/providers",
"filePath": "/www/apps/resources/references/medusa_react/medusa_react.Providers/page.mdx"
},
{
"origSlug": "/references/medusa_react/medusa_react.Utilities",
"newSlug": "/references/medusa-react/utilities",
"filePath": "/www/apps/resources/references/medusa_react/medusa_react.Utilities/page.mdx"
},
{
"origSlug": "/references/modules/api_key_models",
"newSlug": "/references/api-key/models",

View File

@@ -58,4 +58,4 @@ const fulfillmentSet = await fulfillmentModuleService.createFulfillmentSets({
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[FulfillmentSetDTO](../../../interfaces/fulfillment.FulfillmentSetDTO/page.mdx)&#62;","optional":false,"defaultValue":"","description":"The created fulfillment set.","expandable":false,"children":[{"name":"FulfillmentSetDTO","type":"[FulfillmentSetDTO](../../../interfaces/fulfillment.FulfillmentSetDTO/page.mdx)","optional":false,"defaultValue":"","description":"The fulfillment set details.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`string`","description":"The type of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"service_zones","type":"[ServiceZoneDTO](../../../interfaces/fulfillment.ServiceZoneDTO/page.mdx)[]","description":"The service zones associated with the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillment_sets","type":"[FulfillmentSetDTO](../../../interfaces/fulfillment.FulfillmentSetDTO/page.mdx)[]","description":"The fulfillment sets assoiated with the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"geo_zones","type":"[GeoZoneDTO](../../../interfaces/fulfillment.GeoZoneDTO/page.mdx)[]","description":"The geo zones assoiated with the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_options","type":"[ShippingOptionDTO](../../../interfaces/fulfillment.ShippingOptionDTO/page.mdx)[]","description":"The shipping options assoiated with the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The creation date of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The update date of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The deletion date of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"created_at","type":"`Date`","description":"The creation date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The update date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The deletion date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} sectionTitle="createFulfillmentSets"/>
<TypeList types={[{"name":"Promise","type":"Promise&#60;[FulfillmentSetDTO](../../../interfaces/fulfillment.FulfillmentSetDTO/page.mdx)&#62;","optional":false,"defaultValue":"","description":"The created fulfillment set.","expandable":false,"children":[{"name":"FulfillmentSetDTO","type":"[FulfillmentSetDTO](../../../interfaces/fulfillment.FulfillmentSetDTO/page.mdx)","optional":false,"defaultValue":"","description":"The fulfillment set details.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`string`","description":"The type of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"service_zones","type":"[ServiceZoneDTO](../../../interfaces/fulfillment.ServiceZoneDTO/page.mdx)[]","description":"The service zones associated with the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillment_set","type":"[FulfillmentSetDTO](../../../interfaces/fulfillment.FulfillmentSetDTO/page.mdx)","description":"The fulfillment set assoiated with the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillment_set_id","type":"`string`","description":"The fulfillment set id of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"geo_zones","type":"[GeoZoneDTO](../../../interfaces/fulfillment.GeoZoneDTO/page.mdx)[]","description":"The geo zones assoiated with the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_options","type":"[ShippingOptionDTO](../../../interfaces/fulfillment.ShippingOptionDTO/page.mdx)[]","description":"The shipping options assoiated with the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The creation date of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The update date of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The deletion date of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"created_at","type":"`Date`","description":"The creation date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The update date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The deletion date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} sectionTitle="createFulfillmentSets"/>

View File

@@ -39,4 +39,4 @@ const fulfillmentSet = await fulfillmentModuleService.retrieveFulfillmentSet(
## Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[FulfillmentSetDTO](../../../interfaces/fulfillment.FulfillmentSetDTO/page.mdx)&#62;","optional":false,"defaultValue":"","description":"The retrieved fulfillment set.","expandable":false,"children":[{"name":"FulfillmentSetDTO","type":"[FulfillmentSetDTO](../../../interfaces/fulfillment.FulfillmentSetDTO/page.mdx)","optional":false,"defaultValue":"","description":"The fulfillment set details.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`string`","description":"The type of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"service_zones","type":"[ServiceZoneDTO](../../../interfaces/fulfillment.ServiceZoneDTO/page.mdx)[]","description":"The service zones associated with the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillment_sets","type":"[FulfillmentSetDTO](../../../interfaces/fulfillment.FulfillmentSetDTO/page.mdx)[]","description":"The fulfillment sets assoiated with the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"geo_zones","type":"[GeoZoneDTO](../../../interfaces/fulfillment.GeoZoneDTO/page.mdx)[]","description":"The geo zones assoiated with the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_options","type":"[ShippingOptionDTO](../../../interfaces/fulfillment.ShippingOptionDTO/page.mdx)[]","description":"The shipping options assoiated with the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The creation date of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The update date of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The deletion date of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"created_at","type":"`Date`","description":"The creation date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The update date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The deletion date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} sectionTitle="retrieveFulfillmentSet"/>
<TypeList types={[{"name":"Promise","type":"Promise&#60;[FulfillmentSetDTO](../../../interfaces/fulfillment.FulfillmentSetDTO/page.mdx)&#62;","optional":false,"defaultValue":"","description":"The retrieved fulfillment set.","expandable":false,"children":[{"name":"FulfillmentSetDTO","type":"[FulfillmentSetDTO](../../../interfaces/fulfillment.FulfillmentSetDTO/page.mdx)","optional":false,"defaultValue":"","description":"The fulfillment set details.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`string`","description":"The type of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"service_zones","type":"[ServiceZoneDTO](../../../interfaces/fulfillment.ServiceZoneDTO/page.mdx)[]","description":"The service zones associated with the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillment_set","type":"[FulfillmentSetDTO](../../../interfaces/fulfillment.FulfillmentSetDTO/page.mdx)","description":"The fulfillment set assoiated with the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillment_set_id","type":"`string`","description":"The fulfillment set id of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"geo_zones","type":"[GeoZoneDTO](../../../interfaces/fulfillment.GeoZoneDTO/page.mdx)[]","description":"The geo zones assoiated with the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_options","type":"[ShippingOptionDTO](../../../interfaces/fulfillment.ShippingOptionDTO/page.mdx)[]","description":"The shipping options assoiated with the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The creation date of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The update date of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The deletion date of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"created_at","type":"`Date`","description":"The creation date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The update date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The deletion date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} sectionTitle="retrieveFulfillmentSet"/>

View File

@@ -58,4 +58,4 @@ const fulfillmentSet = await fulfillmentModuleService.updateFulfillmentSets({
### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[FulfillmentSetDTO](../../../interfaces/fulfillment.FulfillmentSetDTO/page.mdx)&#62;","optional":false,"defaultValue":"","description":"The updated fulfillment set.","expandable":false,"children":[{"name":"FulfillmentSetDTO","type":"[FulfillmentSetDTO](../../../interfaces/fulfillment.FulfillmentSetDTO/page.mdx)","optional":false,"defaultValue":"","description":"The fulfillment set details.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`string`","description":"The type of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"service_zones","type":"[ServiceZoneDTO](../../../interfaces/fulfillment.ServiceZoneDTO/page.mdx)[]","description":"The service zones associated with the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillment_sets","type":"[FulfillmentSetDTO](../../../interfaces/fulfillment.FulfillmentSetDTO/page.mdx)[]","description":"The fulfillment sets assoiated with the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"geo_zones","type":"[GeoZoneDTO](../../../interfaces/fulfillment.GeoZoneDTO/page.mdx)[]","description":"The geo zones assoiated with the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_options","type":"[ShippingOptionDTO](../../../interfaces/fulfillment.ShippingOptionDTO/page.mdx)[]","description":"The shipping options assoiated with the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The creation date of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The update date of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The deletion date of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"created_at","type":"`Date`","description":"The creation date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The update date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The deletion date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} sectionTitle="updateFulfillmentSets"/>
<TypeList types={[{"name":"Promise","type":"Promise&#60;[FulfillmentSetDTO](../../../interfaces/fulfillment.FulfillmentSetDTO/page.mdx)&#62;","optional":false,"defaultValue":"","description":"The updated fulfillment set.","expandable":false,"children":[{"name":"FulfillmentSetDTO","type":"[FulfillmentSetDTO](../../../interfaces/fulfillment.FulfillmentSetDTO/page.mdx)","optional":false,"defaultValue":"","description":"The fulfillment set details.","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"type","type":"`string`","description":"The type of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"service_zones","type":"[ServiceZoneDTO](../../../interfaces/fulfillment.ServiceZoneDTO/page.mdx)[]","description":"The service zones associated with the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"name","type":"`string`","description":"The name of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"metadata","type":"`null` \\| `Record<string, unknown>`","description":"Holds custom data in key-value pairs.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillment_set","type":"[FulfillmentSetDTO](../../../interfaces/fulfillment.FulfillmentSetDTO/page.mdx)","description":"The fulfillment set assoiated with the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillment_set_id","type":"`string`","description":"The fulfillment set id of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"geo_zones","type":"[GeoZoneDTO](../../../interfaces/fulfillment.GeoZoneDTO/page.mdx)[]","description":"The geo zones assoiated with the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_options","type":"[ShippingOptionDTO](../../../interfaces/fulfillment.ShippingOptionDTO/page.mdx)[]","description":"The shipping options assoiated with the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"created_at","type":"`Date`","description":"The creation date of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The update date of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The deletion date of the service zone.","optional":false,"defaultValue":"","expandable":false,"children":[]}]},{"name":"created_at","type":"`Date`","description":"The creation date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"updated_at","type":"`Date`","description":"The update date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"deleted_at","type":"`null` \\| `Date`","description":"The deletion date of the fulfillment set.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]}]} sectionTitle="updateFulfillmentSets"/>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,100 +0,0 @@
---
slug: /references/js-client/AddressesResource
---
import { TypeList } from "docs-ui"
# AddressesResource
This class is used to send requests to Address API Routes part of the [Store Customer API Routes](https://docs.medusajs.com/api/store#customers\_postcustomers). All its method
are available in the JS Client under the `medusa.customers.addresses` property.
All methods in this class require [authentication](../../../modules/customer/page.mdx).
## Methods
### addAddress
Add an address to the logged-in customer's saved addresses.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged
medusa.customers.addresses.addAddress({
address: {
first_name: "Celia",
last_name: "Schumm",
address_1: "225 Bednar Curve",
city: "Danielville",
country_code: "US",
postal_code: "85137",
phone: "981-596-6748 x90188",
company: "Wyman LLC",
province: "Georgia",
}
})
.then(({ customer }) => {
console.log(customer.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`StorePostCustomersCustomerAddressesReq`","description":"The address to add.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addAddress"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCustomersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer's details, including the customer's addresses in the `shipping_addresses` attribute.","expandable":false,"children":[{"name":"StoreCustomersRes","type":"`StoreCustomersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addAddress"/>
### deleteAddress
Delete an address of the logged-in customer.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged
medusa.customers.addresses.deleteAddress(addressId)
.then(({ customer }) => {
console.log(customer.id);
})
```
#### Parameters
<TypeList types={[{"name":"address_id","type":"`string`","description":"The ID of the address to delete.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteAddress"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCustomersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer's details, including the customer's addresses in the `shipping_addresses` attribute.","expandable":false,"children":[{"name":"StoreCustomersRes","type":"`StoreCustomersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteAddress"/>
### updateAddress
Update an address of the logged-in customer.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged
medusa.customers.addresses.updateAddress(addressId, {
first_name: "Gina"
})
.then(({ customer }) => {
console.log(customer.id);
})
```
#### Parameters
<TypeList types={[{"name":"address_id","type":"`string`","description":"The address's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`StorePostCustomersCustomerAddressesAddressReq`","description":"The attributes to update in the address.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateAddress"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCustomersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer's details, including the customer's addresses in the `shipping_addresses` attribute.","expandable":false,"children":[{"name":"StoreCustomersRes","type":"`StoreCustomersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateAddress"/>

File diff suppressed because one or more lines are too long

View File

@@ -1,117 +0,0 @@
---
slug: /references/js-client/AdminAuthResource
---
import { TypeList } from "docs-ui"
# AdminAuthResource
This class is used to send requests to [Admin Auth API Routes](https://docs.medusajs.com/api/admin#auth\_getauth). All its method
are available in the JS Client under the `medusa.admin.auth` property.
The methods in this class allow admin users to manage their session, such as login or log out.
You can send authenticated requests for an admin user either using the Cookie header, their API token, or the JWT Token.
When you log the admin user in using the [createSession](page.mdx#createsession) method, the JS client will automatically attach the
cookie header in all subsequent requests.
Related Guide: [How to implement user profiles](https://docs.medusajs.com/modules/users/admin/manage-profile).
## Methods
### getSession
Get the currently logged in user's details. Can also be used to check if there is an authenticated user.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.auth.getSession()
.then(({ user }) => {
console.log(user.id);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getSession"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminAuthRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the logged-in user's details.","expandable":false,"children":[{"name":"AdminAuthRes","type":"`AdminAuthRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getSession"/>
### deleteSession
Log out the user and remove their authentication session. This will only work if you're using Cookie session for authentication. If the API token is still passed in the header,
the user is still authorized to perform admin functionalities in other API Routes.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in
medusa.admin.auth.deleteSession()
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteSession"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;void&#62;","optional":false,"defaultValue":"","description":"Resolves when user is logged out successfully.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteSession"/>
### createSession
Log a User in using their credentials. If the user is authenticated successfully, the cookie is automatically attached to subsequent requests sent with the JS Client.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.admin.AdminAuthResource.createSession({
email: "user@example.com",
password: "supersecret"
})
.then(({ user }) => {
console.log(user.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostAuthReq`","description":"The credentials of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createSession"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminAuthRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the user's details.","expandable":false,"children":[{"name":"AdminAuthRes","type":"`AdminAuthRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createSession"/>
### getToken
Authenticate the user and retrieve a JWT token to use for subsequent authenticated requests.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.admin.auth.getToken({
email: 'user@example.com',
password: 'supersecret'
})
.then(({ access_token }) => {
console.log(access_token);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostAuthReq`","description":"The credentials of the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getToken"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminBearerAuthRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the access token of the user, if they're authenticated successfully.","expandable":false,"children":[{"name":"AdminBearerAuthRes","type":"`AdminBearerAuthRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getToken"/>

View File

@@ -1,175 +0,0 @@
---
slug: /references/js-client/AdminBatchJobsResource
---
import { TypeList } from "docs-ui"
# AdminBatchJobsResource
This class is used to send requests to [Admin Batch Job API Routes](https://docs.medusajs.com/api/admin#batch-jobs). All its method
are available in the JS Client under the `medusa.admin.batchJobs` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A batch job is a task that is performed by the Medusa backend asynchronusly. For example, the Import Product feature is implemented using batch jobs.
The methods in this class allow admins to manage the batch jobs and their state.
Related Guide: [How to import products](https://docs.medusajs.com/modules/products/admin/import-products).
## Methods
### create
Create a Batch Job to be executed asynchronously in the Medusa backend. If `dry_run` is set to `true`, the batch job will not be executed until the it is confirmed,
which can be done using the [confirm](page.mdx#confirm) method.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.batchJobs.create({
type: 'product-export',
context: {},
dry_run: false
}).then((({ batch_job }) => {
console.log(batch_job.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostBatchesReq`","description":"The data of the batch job to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminBatchJobRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the batch job's details.","expandable":false,"children":[{"name":"AdminBatchJobRes","type":"`AdminBatchJobRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### list
Retrieve a list of Batch Jobs. The batch jobs can be filtered by fields such as `type` or `confirmed_at`. The batch jobs can also be sorted or paginated.
#### Example
To list batch jobs:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.batchJobs.list()
.then(({ batch_jobs, limit, offset, count }) => {
console.log(batch_jobs.length)
})
```
To specify relations that should be retrieved within the batch jobs:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.batchJobs.list({
expand: "created_by_user"
})
.then(({ batch_jobs, limit, offset, count }) => {
console.log(batch_jobs.length)
})
```
By default, only the first `10` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.batchJobs.list({
expand: "created_by_user",
limit,
offset
})
.then(({ batch_jobs, limit, offset, count }) => {
console.log(batch_jobs.length)
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetBatchParams`","description":"Filters and pagination configurations to apply on the retrieved batch jobs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminBatchJobListRes&#62;","optional":false,"defaultValue":"","description":"The list of batch jobs with pagination fields.","expandable":false,"children":[{"name":"AdminBatchJobListRes","type":"`AdminBatchJobListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### cancel
Mark a batch job as canceled. When a batch job is canceled, the processing of the batch job doesnt automatically stop.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.batchJobs.cancel(batchJobId)
.then(({ batch_job }) => {
console.log(batch_job.id);
})
```
#### Parameters
<TypeList types={[{"name":"batchJobId","type":"`string`","description":"The ID of the batch job.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancel"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminBatchJobRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the batch job's details.","expandable":false,"children":[{"name":"AdminBatchJobRes","type":"`AdminBatchJobRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancel"/>
### confirm
When a batch job is created, it's not executed automatically if `dry_run` is set to `true`. This method confirms that the batch job should be executed.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.batchJobs.confirm(batchJobId)
.then(({ batch_job }) => {
console.log(batch_job.id);
})
```
#### Parameters
<TypeList types={[{"name":"batchJobId","type":"`string`","description":"The ID of the batch job.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="confirm"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminBatchJobRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the batch job's details.","expandable":false,"children":[{"name":"AdminBatchJobRes","type":"`AdminBatchJobRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="confirm"/>
### retrieve
Retrieve the details of a batch job.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.batchJobs.retrieve(batchJobId)
.then(({ batch_job }) => {
console.log(batch_job.id);
})
```
#### Parameters
<TypeList types={[{"name":"batchJobId","type":"`string`","description":"The ID of the batch job.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminBatchJobRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the batch job's details.","expandable":false,"children":[{"name":"AdminBatchJobRes","type":"`AdminBatchJobRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>

View File

@@ -1,215 +0,0 @@
---
slug: /references/js-client/AdminCollectionsResource
---
import { TypeList } from "docs-ui"
# AdminCollectionsResource
This class is used to send requests to [Admin Product Collection API Routes](https://docs.medusajs.com/api/admin#product-collections). All its method
are available in the JS Client under the `medusa.admin.collections` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A product collection is used to organize products for different purposes such as marketing or discount purposes. For example, you can create a Summer Collection.
## Methods
### create
Create a product collection.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.collections.create({
title: "New Collection"
})
.then(({ collection }) => {
console.log(collection.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostCollectionsReq`","description":"The data of the product collection to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the created product collection's details.","expandable":false,"children":[{"name":"AdminCollectionsRes","type":"`AdminCollectionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update a product collection's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.collections.update(collectionId, {
title: "New Collection"
})
.then(({ collection }) => {
console.log(collection.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostCollectionsCollectionReq`","description":"The data to update in the product collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product collection's details.","expandable":false,"children":[{"name":"AdminCollectionsRes","type":"`AdminCollectionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete a product collection. This does not delete associated products.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.collections.delete(collectionId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation details.","expandable":false,"children":[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### retrieve
Retrieve a product collection by its ID. The products associated with it are expanded and returned as well.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.collections.retrieve(collectionId)
.then(({ collection }) => {
console.log(collection.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product collection's details.","expandable":false,"children":[{"name":"AdminCollectionsRes","type":"`AdminCollectionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of product collections. The product collections can be filtered by fields such as `handle` or `title`. The collections can also be sorted or paginated.
#### Example
To list product collections:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.collections.list()
.then(({ collections, limit, offset, count }) => {
console.log(collections.length);
})
```
By default, only the first `10` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.collections.list({
limit,
offset
})
.then(({ collections, limit, offset, count }) => {
console.log(collections.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetCollectionsParams`","description":"Filters and pagination configurations to apply on the retrieved product collections.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCollectionsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of product collections with pagination fields.","expandable":false,"children":[{"name":"AdminCollectionsListRes","type":"`AdminCollectionsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### addProducts
Add products to collection.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.collections.addProducts(collectionId, {
product_ids: [
productId1,
productId2
]
})
.then(({ collection }) => {
console.log(collection.products)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostProductsToCollectionReq`","description":"The products to add.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addProducts"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product collection's details.","expandable":false,"children":[{"name":"AdminCollectionsRes","type":"`AdminCollectionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addProducts"/>
### removeProducts
Remove a list of products from a collection. This would not delete the product, only the association between the product and the collection.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.collections.removeProducts(collectionId, {
product_ids: [
productId1,
productId2
]
})
.then(({ id, object, removed_products }) => {
console.log(removed_products)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"the ID of the product collection","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminDeleteProductsFromCollectionReq`","description":"The products to remove from the collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeProducts"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDeleteProductsFromCollectionRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation details.","expandable":false,"children":[{"name":"AdminDeleteProductsFromCollectionRes","type":"`AdminDeleteProductsFromCollectionRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeProducts"/>

View File

@@ -1,86 +0,0 @@
---
slug: /references/js-client/AdminCurrenciesResource
---
import { TypeList } from "docs-ui"
# AdminCurrenciesResource
This class is used to send requests to [Admin Currency API Routes](https://docs.medusajs.com/api/admin#currencies). All its method
are available in the JS Client under the `medusa.admin.currencies` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A store can use unlimited currencies, and each region must be associated with at least one currency.
Currencies are defined within the Medusa backend. The methods in this class allow admins to list and update currencies.
Related Guide: [How to manage currencies](https://docs.medusajs.com/modules/regions-and-currencies/admin/manage-currencies).
## Methods
### list
Retrieve a list of currencies. The currencies can be filtered by fields such as `code`. The currencies can also be sorted or paginated.
#### Example
To list currencies:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.currencies.list()
.then(({ currencies, count, offset, limit }) => {
console.log(currencies.length);
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.currencies.list({
limit,
offset
})
.then(({ currencies, count, offset, limit }) => {
console.log(currencies.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetCurrenciesParams`","description":"Filters and pagination configurations to apply on retrieved currencies.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCurrenciesListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of currencies with pagination fields.","expandable":false,"children":[{"name":"AdminCurrenciesListRes","type":"`AdminCurrenciesListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### update
Update a Currency's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.currencies.update(code, {
includes_tax: true
})
.then(({ currency }) => {
console.log(currency.code);
})
```
#### Parameters
<TypeList types={[{"name":"code","type":"`string`","description":"The code of the currency to update.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostCurrenciesCurrencyReq`","description":"The attributes to update in the currency.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCurrenciesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the currency's details.","expandable":false,"children":[{"name":"AdminCurrenciesRes","type":"`AdminCurrenciesRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>

View File

@@ -1,116 +0,0 @@
---
slug: /references/js-client/AdminCustomResource
---
import { TypeList } from "docs-ui"
# AdminCustomResource
This class is used to send requests custom API Routes. All its method
are available in the JS Client under the `medusa.admin.custom` property.
## Methods
### get
Send a `GET` request to a custom API Route. The method accepts a tuple of type parameters: the first `TQuery` is the type of accepted query parameters,
which defaults to `Record<string, any>`; the second `TResponse` is the type of response, which defaults to `any`.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
type PostsResponse = {
posts: Post[]
}
// must be previously logged in or use api token
medusa.admin.custom.get<Record<string, any>, PostsResponse>(
"/blog/posts"
)
.then(({ posts }) => {
console.log(posts.length);
})
```
#### Type Parameters
<TypeList types={[{"name":"TQuery","type":"`Record<string, any>`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"TResponse","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="get"/>
#### Parameters
<TypeList types={[{"name":"path","type":"`string`","description":"The path of the custom API Route.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"TQuery","description":"Query path parameters to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`RequestOptions`","description":"Configurations to apply on the request.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="get"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;TResponse&#62;","optional":false,"defaultValue":"","description":"The response data.","expandable":false,"children":[{"name":"TResponse","type":"TResponse","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="get"/>
### post
Send a `POST` request to a custom API Route. The method accepts a tuple of type parameters: the first `TPayload` is the type of accepted body parameters,
which defaults to `Record<string, any>`; the second `TResponse` is the type of response, which defaults to `any`.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
type PostRequest = {
title: string
}
type PostResponse = {
post: Post
}
// must be previously logged in or use api token
medusa.admin.custom.post<PostRequest, PostResponse>(
"/blog/posts",
{
title: "My post",
}
)
.then(({ post }) => {
console.log(post.id);
})
```
#### Type Parameters
<TypeList types={[{"name":"TPayload","type":"`Record<string, any>`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"TResponse","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="post"/>
#### Parameters
<TypeList types={[{"name":"path","type":"`string`","description":"The path of the custom API Route.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"TPayload","description":"Body parameters to pass in the request.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`RequestOptions`","description":"Configurations to apply on the request.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="post"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;TResponse&#62;","optional":false,"defaultValue":"","description":"The response data.","expandable":false,"children":[{"name":"TResponse","type":"TResponse","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="post"/>
### delete
Send a `DELETE` request to a custom API Route. The method accepts a type parameters `TResponse` indicating the type of response, which defaults to `any`.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.custom.delete(
`/blog/posts/${postId}`
)
.then(() => {
// deleted successfully
})
```
#### Type Parameters
<TypeList types={[{"name":"TResponse","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Parameters
<TypeList types={[{"name":"path","type":"`string`","description":"The path of the custom API Route.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"`RequestOptions`","description":"Configurations to apply on the request.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;TResponse&#62;","optional":false,"defaultValue":"","description":"The response data.","expandable":false,"children":[{"name":"TResponse","type":"TResponse","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>

View File

@@ -1,227 +0,0 @@
---
slug: /references/js-client/AdminCustomerGroupsResource
---
import { TypeList } from "docs-ui"
# AdminCustomerGroupsResource
This class is used to send requests to [Admin Customer Group API Routes](https://docs.medusajs.com/api/admin#customer-groups). All its method
are available in the JS Client under the `medusa.admin.customerGroups` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Customer Groups can be used to organize customers that share similar data or attributes into dedicated groups.
This can be useful for different purposes such as setting a different price for a specific customer group.
Related Guide: [How to manage customer groups](https://docs.medusajs.com/modules/customers/admin/manage-customer-groups).
## Methods
### create
Create a customer group.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customerGroups.create({
name: "VIP"
})
.then(({ customer_group }) => {
console.log(customer_group.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostCustomerGroupsReq`","description":"The data of the customer group to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCustomerGroupsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer group's details.","expandable":false,"children":[{"name":"AdminCustomerGroupsRes","type":"`AdminCustomerGroupsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### retrieve
Retrieve a customer group by its ID. You can expand the customer group's relations or select the fields that should be returned.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customerGroups.retrieve(customerGroupId)
.then(({ customer_group }) => {
console.log(customer_group.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the customer group.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetCustomerGroupsGroupParams`","description":"Configurations to apply on the retrieved customer group.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCustomerGroupsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer group's details.","expandable":false,"children":[{"name":"AdminCustomerGroupsRes","type":"`AdminCustomerGroupsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### update
Update a customer group's details.
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the customer group.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostCustomerGroupsGroupReq`","description":"The attributes to update in the customer group.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCustomerGroupsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer group's details.","expandable":false,"children":[{"name":"AdminCustomerGroupsRes","type":"`AdminCustomerGroupsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete a customer group. This doesn't delete the customers associated with the customer group.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customerGroups.delete(customerGroupId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the customer group.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation details.","expandable":false,"children":[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### list
Retrieve a list of customer groups. The customer groups can be filtered by fields such as `name` or `id`. The customer groups can also be sorted or paginated.
#### Example
To list customer groups:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customerGroups.list()
.then(({ customer_groups, limit, offset, count }) => {
console.log(customer_groups.length);
})
```
To specify relations that should be retrieved within the customer groups:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customerGroups.list({
expand: "customers"
})
.then(({ customer_groups, limit, offset, count }) => {
console.log(customer_groups.length);
})
```
By default, only the first `10` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customerGroups.list({
"expand": "customers",
limit,
offset
})
.then(({ customer_groups, limit, offset, count }) => {
console.log(customer_groups.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetCustomerGroupsParams`","description":"Filters and pagination configurations to apply on the retrieved customer groups.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCustomerGroupsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of customer groups with pagination fields.","expandable":false,"children":[{"name":"AdminCustomerGroupsListRes","type":"`AdminCustomerGroupsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### addCustomers
Add a list of customers to a customer group.
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the customer group.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostCustomerGroupsGroupCustomersBatchReq`","description":"The customers to add to the customer group.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addCustomers"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCustomerGroupsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer group's details.","expandable":false,"children":[{"name":"AdminCustomerGroupsRes","type":"`AdminCustomerGroupsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addCustomers"/>
### removeCustomers
Remove a list of customers from a customer group. This doesn't delete the customer, only the association between the customer and the customer group.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customerGroups.removeCustomers(customerGroupId, {
customer_ids: [
{
id: customerId
}
]
})
.then(({ customer_group }) => {
console.log(customer_group.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the customer group.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminDeleteCustomerGroupsGroupCustomerBatchReq`","description":"The customers to remove from the customer group.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeCustomers"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCustomerGroupsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer group's details.","expandable":false,"children":[{"name":"AdminCustomerGroupsRes","type":"`AdminCustomerGroupsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeCustomers"/>
### listCustomers
Retrieve a list of customers in a customer group. The customers can be filtered by the `q` field. The customers can also be paginated.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customerGroups.listCustomers(customerGroupId)
.then(({ customers }) => {
console.log(customers.length);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the customer group.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetCustomersParams`","description":"Filters and pagination configurations to apply on the retrieved customers.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listCustomers"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCustomersListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of customers with pagination fields.","expandable":false,"children":[{"name":"AdminCustomersListRes","type":"`AdminCustomersListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listCustomers"/>

View File

@@ -1,153 +0,0 @@
---
slug: /references/js-client/AdminCustomersResource
---
import { TypeList } from "docs-ui"
# AdminCustomersResource
This class is used to send requests to [Admin Customer API Routes](https://docs.medusajs.com/api/admin#customers). All its method
are available in the JS Client under the `medusa.admin.customers` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Customers can either be created when they register through the [CustomersResource.create](../js_client.CustomersResource/page.mdx#create) method, or created by the admin using the [create](page.mdx#create) method.
Related Guide: [How to manage customers](https://docs.medusajs.com/modules/customers/admin/manage-customers).
## Methods
### create
Create a customer as an admin.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customers.create({
email: "user@example.com",
first_name: "Caterina",
last_name: "Yost",
password: "supersecret"
})
.then(({ customer }) => {
console.log(customer.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostCustomersReq`","description":"The customer to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCustomersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer's details.","expandable":false,"children":[{"name":"AdminCustomersRes","type":"`AdminCustomersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update a customer's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customers.update(customerId, {
first_name: "Dolly"
})
.then(({ customer }) => {
console.log(customer.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The customer's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostCustomersCustomerReq`","description":"The attributes to update in the customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCustomersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer's details.","expandable":false,"children":[{"name":"AdminCustomersRes","type":"`AdminCustomersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### retrieve
Retrieve the details of a customer.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customers.retrieve(customerId)
.then(({ customer }) => {
console.log(customer.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The customer's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCustomersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer's details.","expandable":false,"children":[{"name":"AdminCustomersRes","type":"`AdminCustomersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of Customers. The customers can be filtered by fields such as `q` or `groups`. The customers can also be paginated.
#### Example
To list customers:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customers.list()
.then(({ customers, limit, offset, count }) => {
console.log(customers.length);
})
```
To specify relations that should be retrieved within the customers:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customers.list({
expand: "billing_address"
})
.then(({ customers, limit, offset, count }) => {
console.log(customers.length);
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customers.list({
expand: "billing_address",
limit,
offset
})
.then(({ customers, limit, offset, count }) => {
console.log(customers.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetCustomersParams`","description":"Filters and pagination configurations to apply on the retrieved customers.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminCustomersListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of customers with pagination fields.","expandable":false,"children":[{"name":"AdminCustomersListRes","type":"`AdminCustomersListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>

View File

@@ -1,540 +0,0 @@
---
slug: /references/js-client/AdminDiscountsResource
---
import { TypeList } from "docs-ui"
# AdminDiscountsResource
This class is used to send requests to [Admin Discount API Routes](https://docs.medusajs.com/api/admin#discounts). All its method
are available in the JS Client under the `medusa.admin.discounts` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Admins can create discounts with conditions and rules, providing them with advanced settings for variety of cases.
The methods in this class can be used to manage discounts, their conditions, resources, and more.
Related Guide: [How to manage discounts](https://docs.medusajs.com/modules/discounts/admin/manage-discounts).
## Methods
### addRegion
Add a Region to the list of Regions a Discount can be used in.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.addRegion(discountId, regionId)
.then(({ discount }) => {
console.log(discount.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"regionId","type":"`string`","description":"The ID of the region to add.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addRegion"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the discount's details.","expandable":false,"children":[{"name":"AdminDiscountsRes","type":"`AdminDiscountsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addRegion"/>
### create
Create a discount with a given set of rules that defines how the discount is applied.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
import { AllocationType, DiscountRuleType } from "@medusajs/medusa"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.create({
code: "TEST",
rule: {
type: DiscountRuleType.FIXED,
value: 10,
allocation: AllocationType.ITEM
},
regions: ["reg_XXXXXXXX"],
is_dynamic: false,
is_disabled: false
})
.then(({ discount }) => {
console.log(discount.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostDiscountsReq`","description":"The discount to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the discount's details.","expandable":false,"children":[{"name":"AdminDiscountsRes","type":"`AdminDiscountsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update a discount with a given set of rules that define how the discount is applied.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.update(discountId, {
code: "TEST"
})
.then(({ discount }) => {
console.log(discount.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostDiscountsDiscountReq`","description":"The attributes to update in the discount.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the discount.","expandable":false,"children":[{"name":"AdminDiscountsRes","type":"`AdminDiscountsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### createDynamicCode
Create a dynamic unique code that can map to a parent discount. This is useful if you want to automatically generate codes with the same rules and conditions.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.createDynamicCode(discountId, {
code: "TEST",
usage_limit: 1
})
.then(({ discount }) => {
console.log(discount.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostDiscountsDiscountDynamicCodesReq`","description":"The dynamic code to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createDynamicCode"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the discount.","expandable":false,"children":[{"name":"AdminDiscountsRes","type":"`AdminDiscountsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createDynamicCode"/>
### delete
Delete a discount. Deleting the discount will make it unavailable for customers to use.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.delete(discountId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the delete operation details.","expandable":false,"children":[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### deleteDynamicCode
Delete a dynamic code from a discount.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.deleteDynamicCode(discountId, code)
.then(({ discount }) => {
console.log(discount.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string`","description":"The code of the dynamic code to delete.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteDynamicCode"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the discount.","expandable":false,"children":[{"name":"AdminDiscountsRes","type":"`AdminDiscountsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteDynamicCode"/>
### retrieve
Retrieve a discount.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.retrieve(discountId)
.then(({ discount }) => {
console.log(discount.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetDiscountParams`","description":"Configurations to apply on the retrieved product category.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the discount.","expandable":false,"children":[{"name":"AdminDiscountsRes","type":"`AdminDiscountsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### retrieveByCode
Retrieve a discount's details by its discount code.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.retrieveByCode(code)
.then(({ discount }) => {
console.log(discount.id);
})
```
#### Parameters
<TypeList types={[{"name":"code","type":"`string`","description":"The code of the discount.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieveByCode"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the discount.","expandable":false,"children":[{"name":"AdminDiscountsRes","type":"`AdminDiscountsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieveByCode"/>
### list
Retrieve a list of Discounts. The discounts can be filtered by fields such as `rule` or `is_dynamic`. The discounts can also be paginated.
#### Example
To list discounts:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.list()
.then(({ discounts, limit, offset, count }) => {
console.log(discounts.id);
})
```
To specify relations that should be retrieved within the discounts:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.list({
expand: "rule"
})
.then(({ discounts, limit, offset, count }) => {
console.log(discounts.id);
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.list({
expand: "rule",
limit,
offset
})
.then(({ discounts, limit, offset, count }) => {
console.log(discounts.id);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetDiscountsParams`","description":"Filters and pagination configurations to apply on the retrieved discounts.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of discounts with pagination fields.","expandable":false,"children":[{"name":"AdminDiscountsListRes","type":"`AdminDiscountsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### removeRegion
Remove a Region from the list of Regions that a Discount can be used in. This does not delete a region, only the association between it and the discount.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.removeRegion(discountId, regionId)
.then(({ discount }) => {
console.log(discount.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"regionId","type":"`string`","description":"The ID of the region to remove.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeRegion"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the discount.","expandable":false,"children":[{"name":"AdminDiscountsRes","type":"`AdminDiscountsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeRegion"/>
### createCondition
Create a discount condition. Only one of `products`, `product_types`, `product_collections`, `product_tags`, and `customer_groups` should be provided in the `payload` parameter,
based on the type of discount condition. For example, if the discount condition's type is `products`, the `products` field should be provided in the `payload` parameter.
#### Example
To create a condition in a discount:
```ts
import Medusa from "@medusajs/medusa-js"
import { DiscountConditionOperator } from "@medusajs/medusa"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.createCondition(discountId, {
operator: DiscountConditionOperator.IN,
products: [productId]
})
.then(({ discount }) => {
console.log(discount.id);
})
```
To specify relations that should be retrieved as part of the response:
```ts
import Medusa from "@medusajs/medusa-js"
import { DiscountConditionOperator } from "@medusajs/medusa"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.createCondition(discountId, {
operator: DiscountConditionOperator.IN,
products: [productId]
}, {
expand: "rule"
})
.then(({ discount }) => {
console.log(discount.id);
})
```
#### Parameters
<TypeList types={[{"name":"discountId","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostDiscountsDiscountConditions`","description":"The discount condition to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"`AdminPostDiscountsDiscountConditionsParams`","description":"Configurations to apply on the returned discount.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createCondition"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the discount.","expandable":false,"children":[{"name":"AdminDiscountsRes","type":"`AdminDiscountsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createCondition"/>
### updateCondition
Update a discount condition. Only one of `products`, `product_types`, `product_collections`, `product_tags`, and `customer_groups` should be provided in the `payload` parameter,
based on the type of discount condition. For example, if the discount condition's type is `products`, the `products` field should be provided in the `payload` parameter.
#### Example
To update a condition in a discount:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.updateCondition(discountId, conditionId, {
products: [
productId
]
})
.then(({ discount }) => {
console.log(discount.id);
})
```
To specify relations that should be retrieved as part of the response:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.updateCondition(discountId, conditionId, {
products: [
productId
]
}, {
expand: "rule"
})
.then(({ discount }) => {
console.log(discount.id);
})
```
#### Parameters
<TypeList types={[{"name":"discountId","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"conditionId","type":"`string`","description":"The ID of the discount condition.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostDiscountsDiscountConditionsCondition`","description":"The attributes to update in the discount condition.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"`AdminPostDiscountsDiscountConditionsConditionParams`","description":"Configurations to apply on the returned discount.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateCondition"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the discount.","expandable":false,"children":[{"name":"AdminDiscountsRes","type":"`AdminDiscountsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateCondition"/>
### deleteCondition
Delete a discount condition. This doesn't delete resources associated to the discount condition.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.deleteCondition(discountId, conditionId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"discountId","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"conditionId","type":"`string`","description":"The ID of the discount condition.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteCondition"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation details.","expandable":false,"children":[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteCondition"/>
### getCondition
Retrieve a Discount Condition's details.
#### Example
A simple example that retrieves a discount condition by its ID:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.getCondition(discountId, conditionId)
.then(({ discount_condition }) => {
console.log(discount_condition.id);
})
```
To specify relations that should be retrieved:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.getCondition(discountId, conditionId, {
expand: "discount_rule"
})
.then(({ discount_condition }) => {
console.log(discount_condition.id);
})
```
#### Parameters
<TypeList types={[{"name":"discountId","type":"`string`","description":"The ID of the discount that the condition belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"conditionId","type":"`string`","description":"The ID of the discount condition.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetDiscountsDiscountConditionsConditionParams`","description":"Configurations to apply on the retrieved discount condition.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getCondition"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountConditionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the discount condition details.","expandable":false,"children":[{"name":"AdminDiscountConditionsRes","type":"`AdminDiscountConditionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getCondition"/>
### addConditionResourceBatch
Add a batch of resources to a discount condition. The type of resource depends on the type of discount condition. For example, if the discount condition's type is `products`,
the resources being added should be products.
#### Example
To add resources to a discount condition:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.addConditionResourceBatch(discountId, conditionId, {
resources: [{ id: itemId }]
})
.then(({ discount }) => {
console.log(discount.id);
})
```
To specify relations to include in the returned discount:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.addConditionResourceBatch(discountId, conditionId, {
resources: [{ id: itemId }]
}, {
expand: "rule"
})
.then(({ discount }) => {
console.log(discount.id);
})
```
#### Parameters
<TypeList types={[{"name":"discountId","type":"`string`","description":"The ID of the discount the condition belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"conditionId","type":"`string`","description":"The ID of the discount condition.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostDiscountsDiscountConditionsConditionBatchReq`","description":"The resources to add to the discount condition.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminPostDiscountsDiscountConditionsConditionBatchParams`","description":"Configurations to apply on the retrieved discount.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addConditionResourceBatch"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the discount.","expandable":false,"children":[{"name":"AdminDiscountsRes","type":"`AdminDiscountsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addConditionResourceBatch"/>
### deleteConditionResourceBatch
Remove a batch of resources from a discount condition. This will only remove the association between the resource and the discount condition, not the resource itself.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.deleteConditionResourceBatch(discountId, conditionId, {
resources: [{ id: itemId }]
})
.then(({ discount }) => {
console.log(discount.id);
})
```
#### Parameters
<TypeList types={[{"name":"discountId","type":"`string`","description":"The ID of the discount the condition belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"conditionId","type":"`string`","description":"The ID of the discount condition.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminDeleteDiscountsDiscountConditionsConditionBatchReq`","description":"The resources to remove.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteConditionResourceBatch"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDiscountsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the discount.","expandable":false,"children":[{"name":"AdminDiscountsRes","type":"`AdminDiscountsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteConditionResourceBatch"/>

View File

@@ -1,271 +0,0 @@
---
slug: /references/js-client/AdminDraftOrdersResource
---
import { TypeList } from "docs-ui"
# AdminDraftOrdersResource
This class is used to send requests to [Admin Draft Order API Routes](https://docs.medusajs.com/api/admin#draft-orders). All its method
are available in the JS Client under the `medusa.admin.draftOrders` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A draft order is an order created manually by the admin. It allows admins to create orders without direct involvement from the customer.
Related Guide: [How to manage draft orders](https://docs.medusajs.com/modules/orders/admin/manage-draft-orders).
## Methods
### create
Create a Draft Order. A draft order is not transformed into an order until payment is captured.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.draftOrders.create({
email: "user@example.com",
region_id,
items: [
{
quantity: 1
}
],
shipping_methods: [
{
option_id
}
],
})
.then(({ draft_order }) => {
console.log(draft_order.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostDraftOrdersReq`","description":"The draft order to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDraftOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the draft order's details","expandable":false,"children":[{"name":"AdminDraftOrdersRes","type":"`AdminDraftOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### addLineItem
Create a Line Item in the Draft Order.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.draftOrders.addLineItem(draftOrderId, {
quantity: 1
})
.then(({ draft_order }) => {
console.log(draft_order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the draft order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostDraftOrdersDraftOrderLineItemsReq`","description":"The line item to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addLineItem"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDraftOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the draft order's details","expandable":false,"children":[{"name":"AdminDraftOrdersRes","type":"`AdminDraftOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addLineItem"/>
### delete
Delete a Draft Order.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.draftOrders.delete(draftOrderId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the draft order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation details.","expandable":false,"children":[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### removeLineItem
Delete a Line Item from a Draft Order.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.draftOrders.removeLineItem(draftOrderId, itemId)
.then(({ draft_order }) => {
console.log(draft_order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the draft order that the line item belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"itemId","type":"`string`","description":"The ID of the line item to delete from the draft order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeLineItem"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDraftOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the draft order's details","expandable":false,"children":[{"name":"AdminDraftOrdersRes","type":"`AdminDraftOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeLineItem"/>
### retrieve
Retrieve a Draft Order's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.draftOrders.retrieve(draftOrderId)
.then(({ draft_order }) => {
console.log(draft_order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the draft order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDraftOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the draft order's details.","expandable":false,"children":[{"name":"AdminDraftOrdersRes","type":"`AdminDraftOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve an list of Draft Orders. The draft orders can be filtered by parameters such as `query`. The draft orders can also paginated.
#### Example
To list draft orders:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.draftOrders.list()
.then(({ draft_orders, limit, offset, count }) => {
console.log(draft_orders.length);
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.draftOrders.list({
limit,
offset
})
.then(({ draft_orders, limit, offset, count }) => {
console.log(draft_orders.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetDraftOrdersParams`","description":"Filters and pagination configurations to apply on the retrieved draft orders.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDraftOrdersListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of draft orders with pagination fields.","expandable":false,"children":[{"name":"AdminDraftOrdersListRes","type":"`AdminDraftOrdersListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### markPaid
Capture the draft order's payment. This will also set the draft order's status to `completed` and create an order from the draft order. The payment is captured through Medusa's system payment,
which is manual payment that isn't integrated with any third-party payment provider. It is assumed that the payment capturing is handled manually by the admin.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.draftOrders.markPaid(draftOrderId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the draft order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="markPaid"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPostDraftOrdersDraftOrderRegisterPaymentRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the created order's details.","expandable":false,"children":[{"name":"AdminPostDraftOrdersDraftOrderRegisterPaymentRes","type":"`AdminPostDraftOrdersDraftOrderRegisterPaymentRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="markPaid"/>
### update
Update a Draft Order's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.draftOrders.update(draftOrderId, {
email: "user@example.com"
})
.then(({ draft_order }) => {
console.log(draft_order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the draft order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostDraftOrdersDraftOrderReq`","description":"The attributes to update in the draft order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDraftOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the draft order's details.","expandable":false,"children":[{"name":"AdminDraftOrdersRes","type":"`AdminDraftOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### updateLineItem
Update a Line Item in a Draft Order.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.draftOrders.updateLineItem(draftOrderId, lineId, {
quantity: 1
})
.then(({ draft_order }) => {
console.log(draft_order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the draft order that the line item belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"itemId","type":"`string`","description":"The ID of the line item to update.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostDraftOrdersDraftOrderLineItemsItemReq`","description":"The attributes to update in the line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateLineItem"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminDraftOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the draft order's details.","expandable":false,"children":[{"name":"AdminDraftOrdersRes","type":"`AdminDraftOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateLineItem"/>

View File

@@ -1,160 +0,0 @@
---
slug: /references/js-client/AdminGiftCardsResource
---
import { TypeList } from "docs-ui"
# AdminGiftCardsResource
This class is used to send requests to [Admin Gift Card API Routes](https://docs.medusajs.com/api/admin#gift-cards). All its method
are available in the JS Client under the `medusa.admin.giftCards` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Admins can create gift cards and send them directly to customers, specifying options like their balance, region, and more.
These gift cards are different than the saleable gift cards in a store, which are created and managed through [AdminProductsResource](../js_client.AdminProductsResource/page.mdx).
Related Guide: [How to manage gift cards](https://docs.medusajs.com/modules/gift-cards/admin/manage-gift-cards#manage-custom-gift-cards).
## Methods
### create
Create a gift card that can redeemed by its unique code. The Gift Card is only valid within one region.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.giftCards.create({
region_id
})
.then(({ gift_card }) => {
console.log(gift_card.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostGiftCardsReq`","description":"The gift card to be created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminGiftCardsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the gift card's details.","expandable":false,"children":[{"name":"AdminGiftCardsRes","type":"`AdminGiftCardsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update a gift card's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.giftCards.update(giftCardId, {
region_id
})
.then(({ gift_card }) => {
console.log(gift_card.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the gift card.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostGiftCardsGiftCardReq`","description":"The attributes to update in the gift card.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminGiftCardsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the gift card's details.","expandable":false,"children":[{"name":"AdminGiftCardsRes","type":"`AdminGiftCardsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete a gift card. Once deleted, it can't be used by customers.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.giftCards.delete(giftCardId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the gift card.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### retrieve
Retrieve a gift card's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.giftCards.retrieve(giftCardId)
.then(({ gift_card }) => {
console.log(gift_card.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the gift card.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminGiftCardsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the gift card's details.","expandable":false,"children":[{"name":"AdminGiftCardsRes","type":"`AdminGiftCardsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of gift cards. The gift cards can be filtered by fields such as `q` passed in the `query` parameter. The gift cards can also paginated.
#### Example
To list gift cards:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.giftCards.list()
.then(({ gift_cards, limit, offset, count }) => {
console.log(gift_cards.length);
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.giftCards.list({
limit,
offset
})
.then(({ gift_cards, limit, offset, count }) => {
console.log(gift_cards.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetGiftCardsParams`","description":"Filters and pagination configurations to apply on the retrieved gift cards.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminGiftCardsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of gift cards with pagination fields.","expandable":false,"children":[{"name":"AdminGiftCardsListRes","type":"`AdminGiftCardsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>

View File

@@ -1,262 +0,0 @@
---
slug: /references/js-client/AdminInventoryItemsResource
---
import { TypeList } from "docs-ui"
# AdminInventoryItemsResource
This class is used to send requests to [Admin Inventory Item API Routes](https://docs.medusajs.com/api/admin#inventory-items). To use these API Routes, make sure to install the
[@medusajs/inventory](https://docs.medusajs.com/modules/multiwarehouse/install-modules#inventory-module) module in your Medusa backend. All its method
are available in the JS Client under the `medusa.admin.inventoryItems` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Inventory items, provided by the [Inventory Module](https://docs.medusajs.com/modules/multiwarehouse/inventory-module), can be used to manage the inventory of saleable items in your store.
Related Guide: [How to manage inventory items](https://docs.medusajs.com/modules/multiwarehouse/admin/manage-inventory-items).
## Methods
### retrieve
Retrieve an Inventory Item's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.inventoryItems.retrieve(inventoryItemId)
.then(({ inventory_item }) => {
console.log(inventory_item.id);
})
```
#### Parameters
<TypeList types={[{"name":"inventoryItemId","type":"`string`","description":"The ID of the inventory item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetInventoryItemsItemParams`","description":"Configurations applied on the retrieved inventory item.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminInventoryItemsRes&#62;","optional":false,"defaultValue":"","description":"The inventory item's details.","expandable":false,"children":[{"name":"AdminInventoryItemsRes","type":"`AdminInventoryItemsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### update
Update an Inventory Item's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.inventoryItems.update(inventoryItemId, {
origin_country: "US",
})
.then(({ inventory_item }) => {
console.log(inventory_item.id);
})
```
#### Parameters
<TypeList types={[{"name":"inventoryItemId","type":"`string`","description":"The ID of the inventory item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostInventoryItemsInventoryItemReq`","description":"The attributes to update in the inventory item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminPostInventoryItemsInventoryItemParams`","description":"Configurations to apply on the retrieved inventory item.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminInventoryItemsRes&#62;","optional":false,"defaultValue":"","description":"The inventory item's details.","expandable":false,"children":[{"name":"AdminInventoryItemsRes","type":"`AdminInventoryItemsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete an Inventory Item. This does not delete the associated product variant.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.inventoryItems.delete(inventoryItemId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
#### Parameters
<TypeList types={[{"name":"inventoryItemId","type":"`string`","description":"The ID of the inventory item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"The deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### create
Create an Inventory Item for a product variant.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.inventoryItems.create({
variant_id: "variant_123",
})
.then(({ inventory_item }) => {
console.log(inventory_item.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostInventoryItemsReq`","description":"The inventory item to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminPostInventoryItemsParams`","description":"Configurations to apply on the retrieved inventory item.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminInventoryItemsRes&#62;","optional":false,"defaultValue":"","description":"The inventory item's details.","expandable":false,"children":[{"name":"AdminInventoryItemsRes","type":"`AdminInventoryItemsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### list
Retrieve a list of inventory items. The inventory items can be filtered by fields such as `q` or `location_id` passed in the `query` parameter.
The inventory items can also be paginated.
#### Example
To list inventory items:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.inventoryItems.list()
.then(({ inventory_items, count, offset, limit }) => {
console.log(inventory_items.length);
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.inventoryItems.list({
limit,
offset
})
.then(({ inventory_items, count, offset, limit }) => {
console.log(inventory_items.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetInventoryItemsParams`","description":"Filters and pagination configurations applied on the retrieved inventory items.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminInventoryItemsListWithVariantsAndLocationLevelsRes&#62;","optional":false,"defaultValue":"","description":"The list of inventory items with pagination fields.","expandable":false,"children":[{"name":"AdminInventoryItemsListWithVariantsAndLocationLevelsRes","type":"`AdminInventoryItemsListWithVariantsAndLocationLevelsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### updateLocationLevel
Update a location level's details for a given inventory item.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.inventoryItems.updateLocationLevel(inventoryItemId, locationId, {
stocked_quantity: 15,
})
.then(({ inventory_item }) => {
console.log(inventory_item.id);
})
```
#### Parameters
<TypeList types={[{"name":"inventoryItemId","type":"`string`","description":"The ID of the inventory item that the location level belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"locationId","type":"`string`","description":"The ID of the location level to update.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostInventoryItemsItemLocationLevelsLevelReq`","description":"The attributes to update in the location level.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminPostInventoryItemsItemLocationLevelsLevelParams`","description":"Configurations to apply on the returned inventory item.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateLocationLevel"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminInventoryItemsRes&#62;","optional":false,"defaultValue":"","description":"the inventory item's details.","expandable":false,"children":[{"name":"AdminInventoryItemsRes","type":"`AdminInventoryItemsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateLocationLevel"/>
### createLocationLevel
Create a Location Level for a given Inventory Item.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.inventoryItems.createLocationLevel(inventoryItemId, {
location_id: "sloc_123",
stocked_quantity: 10,
})
.then(({ inventory_item }) => {
console.log(inventory_item.id);
})
```
#### Parameters
<TypeList types={[{"name":"inventoryItemId","type":"`string`","description":"The ID of the inventory item that the location level belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostInventoryItemsItemLocationLevelsReq`","description":"The location level to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminPostInventoryItemsItemLocationLevelsParams`","description":"Configurations to apply on the returned inventory item.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createLocationLevel"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminInventoryItemsRes&#62;","optional":false,"defaultValue":"","description":"the inventory item's details.","expandable":false,"children":[{"name":"AdminInventoryItemsRes","type":"`AdminInventoryItemsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createLocationLevel"/>
### deleteLocationLevel
Delete a location level of an Inventory Item.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.inventoryItems.deleteLocationLevel(inventoryItemId, locationId)
.then(({ inventory_item }) => {
console.log(inventory_item.id);
})
```
#### Parameters
<TypeList types={[{"name":"inventoryItemId","type":"`string`","description":"The ID of the inventory item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"locationId","type":"`string`","description":"The ID of the location level to delete.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteLocationLevel"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminInventoryItemsRes&#62;","optional":false,"defaultValue":"","description":"the inventory item's details.","expandable":false,"children":[{"name":"AdminInventoryItemsRes","type":"`AdminInventoryItemsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteLocationLevel"/>
### listLocationLevels
Retrieve a list of inventory levels of an inventory item. The inventory levels can be filtered by fields such as `location_id` passed in the `query` parameter.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.inventoryItems.listLocationLevels(inventoryItemId)
.then(({ inventory_item }) => {
console.log(inventory_item.location_levels);
})
```
#### Parameters
<TypeList types={[{"name":"inventoryItemId","type":"`string`","description":"The ID of the inventory item that the location levels belong to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetInventoryItemsItemLocationLevelsParams`","description":"Filters to apply on the retrieved location levels.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listLocationLevels"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminInventoryItemsLocationLevelsRes&#62;","optional":false,"defaultValue":"","description":"The inventory item's details and list of location levels.","expandable":false,"children":[{"name":"AdminInventoryItemsLocationLevelsRes","type":"`AdminInventoryItemsLocationLevelsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listLocationLevels"/>

View File

@@ -1,161 +0,0 @@
---
slug: /references/js-client/AdminInvitesResource
---
import { TypeList } from "docs-ui"
# AdminInvitesResource
This class is used to send requests to [Admin Invite API Routes](https://docs.medusajs.com/api/admin#invites). All its method
are available in the JS Client under the `medusa.admin.invites` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
An admin can invite new users to manage their team. This would allow new users to authenticate as admins and perform admin functionalities.
Related Guide: [How to manage invites](https://docs.medusajs.com/modules/users/admin/manage-invites).
## Methods
### accept
Accept an Invite. This will also delete the invite and create a new user that can log in and perform admin functionalities.
The user will have the email associated with the invite, and the password provided in the `payload` parameter.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.invites.accept({
token,
user: {
first_name: "Brigitte",
last_name: "Collier",
password: "supersecret"
}
})
.then(() => {
// successful
})
.catch(() => {
// an error occurred
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostInvitesInviteAcceptReq`","description":"The user accepting the invite.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="accept"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"`ResponsePromise`","optional":false,"defaultValue":"","description":"Resolves when the invite is accepted successfully.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="accept"/>
### create
Create an invite. This will generate a token associated with the invite and trigger an `invite.created` event. If you have a Notification Provider installed that handles this
event, a notification should be sent to the email associated with the invite to allow them to accept the invite.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.invites.create({
user: "user@example.com",
role: "admin"
})
.then(() => {
// successful
})
.catch(() => {
// an error occurred
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostInvitesPayload`","description":"The invite to be created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"`ResponsePromise`","optional":false,"defaultValue":"","description":"Resolves when the invite is created successfully.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### delete
Delete an invite. Only invites that weren't accepted can be deleted.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.invites.delete(inviteId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The invite's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### list
Retrieve a list of invites.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.invites.list()
.then(({ invites }) => {
console.log(invites.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminListInvitesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of invites.","expandable":false,"children":[{"name":"AdminListInvitesRes","type":"`AdminListInvitesRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### resend
Resend an invite. This renews the expiry date by seven days and generates a new token for the invite. It also triggers the `invite.created` event,
so if you have a Notification Provider installed that handles this event, a notification should be sent to the email associated with the
invite to allow them to accept the invite.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.invites.resend(inviteId)
.then(() => {
// successful
})
.catch(() => {
// an error occurred
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The invite's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="resend"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"`ResponsePromise`","optional":false,"defaultValue":"","description":"Resolves when the invite is resent successfully.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="resend"/>

View File

@@ -1,159 +0,0 @@
---
slug: /references/js-client/AdminNotesResource
---
import { TypeList } from "docs-ui"
# AdminNotesResource
This class is used to send requests to [Admin Note API Routes](https://docs.medusajs.com/api/admin#notes). All its method
are available in the JS Client under the `medusa.admin.notes` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Notes are created by admins and can be associated with any resource. For example, an admin can add a note to an order for additional details or remarks.
## Methods
### create
Create a Note which can be associated with any resource.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notes.create({
resource_id,
resource_type: "order",
value: "We delivered this order"
})
.then(({ note }) => {
console.log(note.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostNotesReq`","description":"The note to be created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminNotesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the note's details.","expandable":false,"children":[{"name":"AdminNotesRes","type":"`AdminNotesRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update a Note's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notes.update(noteId, {
value: "We delivered this order"
})
.then(({ note }) => {
console.log(note.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The note's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostNotesNoteReq`","description":"The attributes to update in the note.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminNotesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the note's details.","expandable":false,"children":[{"name":"AdminNotesRes","type":"`AdminNotesRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete a Note.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notes.delete(noteId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The note's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### retrieve
Retrieve a note's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notes.retrieve(noteId)
.then(({ note }) => {
console.log(note.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The note's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminNotesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the note's details.","expandable":false,"children":[{"name":"AdminNotesRes","type":"`AdminNotesRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of notes. The notes can be filtered by fields such as `resource_id` passed in the `query` parameter. The notes can also be paginated.
#### Example
To list notes:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notes.list()
.then(({ notes, limit, offset, count }) => {
console.log(notes.length);
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notes.list({
limit,
offset
})
.then(({ notes, limit, offset, count }) => {
console.log(notes.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetNotesParams`","description":"Filters and pagination configurations applied on retrieved notes.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminNotesListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of notes with pagination fields.","expandable":false,"children":[{"name":"AdminNotesListRes","type":"`AdminNotesListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>

View File

@@ -1,98 +0,0 @@
---
slug: /references/js-client/AdminNotificationsResource
---
import { TypeList } from "docs-ui"
# AdminNotificationsResource
This class is used to send requests to [Admin Notification API Routes](https://docs.medusajs.com/api/admin#notifications). All its method
are available in the JS Client under the `medusa.admin.notifications` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Notifications are sent to customers to inform them of new updates. For example, a notification can be sent to the customer when their order is place or its state is updated.
The notification's type, such as an email or SMS, is determined by the notification provider installed on the Medusa backend.
## Methods
### list
Retrieve a list of notifications. The notifications can be filtered by fields such as `event_name` or `resource_type` passed in the `query` parameter.
The notifications can also be paginated.
#### Example
To list notifications:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notifications.list()
.then(({ notifications }) => {
console.log(notifications.length);
})
```
To specify relations that should be retrieved within the notifications:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notifications.list({
expand: "provider"
})
.then(({ notifications }) => {
console.log(notifications.length);
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notifications.list({
expand: "provider",
limit,
offset
})
.then(({ notifications }) => {
console.log(notifications.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetNotificationsParams`","description":"Filters and pagination configurations applied to the retrieved notifications.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminNotificationsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of notifications with pagination fields.","expandable":false,"children":[{"name":"AdminNotificationsListRes","type":"`AdminNotificationsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### resend
Resend a previously sent notifications, with the same data but optionally to a different address.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notifications.resend(notificationId)
.then(({ notification }) => {
console.log(notification.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The notification's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostNotificationsNotificationResendReq`","description":"The details necessary to resend the notification.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="resend"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminNotificationsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the notification's details.","expandable":false,"children":[{"name":"AdminNotificationsRes","type":"`AdminNotificationsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="resend"/>

View File

@@ -1,365 +0,0 @@
---
slug: /references/js-client/AdminOrderEditsResource
---
import { TypeList } from "docs-ui"
# AdminOrderEditsResource
This class is used to send requests to [Admin Order Edit API Routes](https://docs.medusajs.com/api/admin#order-edits). All its method
are available in the JS Client under the `medusa.admin.orderEdits` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
An admin can edit an order to remove, add, or update an item's quantity. When an admin edits an order, they're stored as an `OrderEdit`.
Related Guide: [How to edit an order](https://docs.medusajs.com/modules/orders/admin/edit-order).
## Methods
### retrieve
Retrieve an order edit's details.
#### Example
A simple example that retrieves an order edit by its ID:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.retrieve(orderEditId)
.then(({ order_edit }) => {
console.log(order_edit.id)
})
```
To specify relations that should be retrieved:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.retrieve(orderEditId, {
expand: "order"
})
.then(({ order_edit }) => {
console.log(order_edit.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order edit.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`GetOrderEditsOrderEditParams`","description":"Configurations to apply on the retrieved order edit.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrderEditsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order edit's details.","expandable":false,"children":[{"name":"AdminOrderEditsRes","type":"`AdminOrderEditsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of order edits. The order edits can be filtered by fields such as `q` or `order_id` passed to the `query` parameter. The order edits can also be paginated.
#### Example
To list order edits:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.list()
.then(({ order_edits, count, limit, offset }) => {
console.log(order_edits.length)
})
```
To specify relations that should be retrieved within the order edits:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.list({
expand: "order"
})
.then(({ order_edits, count, limit, offset }) => {
console.log(order_edits.length)
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.list({
expand: "order",
limit,
offset
})
.then(({ order_edits, count, limit, offset }) => {
console.log(order_edits.length)
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`GetOrderEditsParams`","description":"Filters and pagination configurations applied to retrieved order edits.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrderEditsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of order edits with pagination fields.","expandable":false,"children":[{"name":"AdminOrderEditsListRes","type":"`AdminOrderEditsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### create
Create an order edit.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.create({ orderId })
.then(({ order_edit }) => {
console.log(order_edit.id)
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostOrderEditsReq`","description":"The order edit to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrderEditsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order edit's details.","expandable":false,"children":[{"name":"AdminOrderEditsRes","type":"`AdminOrderEditsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update an Order Edit's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.update(orderEditId, {
internal_note: "internal reason XY"
})
.then(({ order_edit }) => {
console.log(order_edit.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order edit.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostOrderEditsOrderEditReq`","description":"The attributes to update in an order edit.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrderEditsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order edit's details.","expandable":false,"children":[{"name":"AdminOrderEditsRes","type":"`AdminOrderEditsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete an order edit. Only order edits that have the status `created` can be deleted.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.delete(orderEditId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order edit.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### addLineItem
Create a line item change in the order edit that indicates adding an item in the original order. The item will not be added to the original order until the order edit is
confirmed.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.addLineItem(orderEditId, {
variant_id,
quantity
})
.then(({ order_edit }) => {
console.log(order_edit.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order edit to add the line item change to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostOrderEditsEditLineItemsReq`","description":"The line item change to be created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addLineItem"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrderEditsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order edit's details.","expandable":false,"children":[{"name":"AdminOrderEditsRes","type":"`AdminOrderEditsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addLineItem"/>
### deleteItemChange
Delete a line item change that indicates the addition, deletion, or update of a line item in the original order.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.deleteItemChange(orderEdit_id, itemChangeId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
#### Parameters
<TypeList types={[{"name":"orderEditId","type":"`string`","description":"The ID of the order edit.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"itemChangeId","type":"`string`","description":"The ID of the line item change.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteItemChange"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrderEditItemChangeDeleteRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"AdminOrderEditItemChangeDeleteRes","type":"`AdminOrderEditItemChangeDeleteRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteItemChange"/>
### requestConfirmation
Request customer confirmation of an order edit. This would emit the event `order-edit.requested` which Notification Providers listen to and send
a notification to the customer about the order edit.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.requestConfirmation(orderEditId)
.then({ order_edit }) => {
console.log(order_edit.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order edit.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="requestConfirmation"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrderEditsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order edit's details.","expandable":false,"children":[{"name":"AdminOrderEditsRes","type":"`AdminOrderEditsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="requestConfirmation"/>
### cancel
Cancel an order edit.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.cancel(orderEditId)
.then(({ order_edit }) => {
console.log(order_edit.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order edit to cancel.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancel"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrderEditsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order edit's details.","expandable":false,"children":[{"name":"AdminOrderEditsRes","type":"`AdminOrderEditsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancel"/>
### confirm
Confirm an order edit. This will reflect the changes in the order edit on the associated order.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.confirm(orderEditId)
.then(({ order_edit }) => {
console.log(order_edit.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order edit to confirm.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="confirm"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrderEditsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order edit's details.","expandable":false,"children":[{"name":"AdminOrderEditsRes","type":"`AdminOrderEditsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="confirm"/>
### updateLineItem
Create or update a line item change in the order edit that indicates addition, deletion, or update of a line item into an original order. Line item changes
are only reflected on the original order after the order edit is confirmed.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.updateLineItem(orderEditId, lineItemId, {
quantity: 5
})
.then(({ order_edit }) => {
console.log(order_edit.id)
})
```
#### Parameters
<TypeList types={[{"name":"orderEditId","type":"`string`","description":"The ID of the order edit that the line item belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"itemId","type":"`string`","description":"The ID of the line item to create or update its line item change.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostOrderEditsEditLineItemsLineItemReq`","description":"The creation or update of the line item change.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateLineItem"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrderEditsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order edit's details.","expandable":false,"children":[{"name":"AdminOrderEditsRes","type":"`AdminOrderEditsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateLineItem"/>
### removeLineItem
Create a line item change in the order edit that indicates deleting an item in the original order. The item in the original order will not be deleted until the order edit is
confirmed.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.removeLineItem(orderEditId, lineItemId)
.then(({ order_edit }) => {
console.log(order_edit.id)
})
```
#### Parameters
<TypeList types={[{"name":"orderEditId","type":"`string`","description":"The ID of the order edit that the line item change belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"itemId","type":"`string`","description":"The ID of the line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeLineItem"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrderEditsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order edit's details.","expandable":false,"children":[{"name":"AdminOrderEditsRes","type":"`AdminOrderEditsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeLineItem"/>

View File

@@ -1,724 +0,0 @@
---
slug: /references/js-client/AdminOrdersResource
---
import { TypeList } from "docs-ui"
# AdminOrdersResource
This class is used to send requests to [Admin Order API Routes](https://docs.medusajs.com/api/admin#orders). All its method
are available in the JS Client under the `medusa.admin.orders` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Orders are purchases made by customers, typically through a storefront using [CartsResource](../js_client.CartsResource/page.mdx). Draft orders created by the admin are also transformed to an Order once the payment is captured.
Managing orders include managing fulfillment, payment, claims, reservations, and more.
Related Guide: [How to manage orders](https://docs.medusajs.com/modules/orders/admin/manage-orders).
## Methods
### update
Update an order's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.update(orderId, {
email: "user@example.com"
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostOrdersOrderReq`","description":"The attributes to update in the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### retrieve
Retrieve an order's details.
#### Example
A simple example that retrieves an order by its ID:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.retrieve(orderId)
.then(({ order }) => {
console.log(order.id);
})
```
To specify relations that should be retrieved:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.retrieve(orderId, {
expand: "customer"
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`FindParams`","description":"Configurations to apply on the retrieved order.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of orders. The orders can be filtered by fields such as `status` or `display_id` passed in the `query` parameter. The order can also be paginated.
#### Example
To list orders:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.list()
.then(({ orders, limit, offset, count }) => {
console.log(orders.length);
})
```
To specify relations that should be retrieved within the orders:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.list({
expand: "customers"
})
.then(({ orders, limit, offset, count }) => {
console.log(orders.length);
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.list({
expand: "customers",
limit,
offset
})
.then(({ orders, limit, offset, count }) => {
console.log(orders.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetOrdersParams`","description":"Filters and pagination configurations applied on the retrieved orders.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of orders with pagination fields.","expandable":false,"children":[{"name":"AdminOrdersListRes","type":"`AdminOrdersListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### complete
Complete an order and change its status. A canceled order can't be completed.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.complete(orderId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="complete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="complete"/>
### capturePayment
Capture all the payments associated with an order. The payment of canceled orders can't be captured.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.capturePayment(orderId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order whose payments should be captured.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="capturePayment"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="capturePayment"/>
### refundPayment
Refund an amount for an order. The amount must be less than or equal the `refundable_amount` of the order.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.refundPayment(orderId, {
amount: 1000,
reason: "Do not like it"
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order whose customer should be refunded.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostOrdersOrderRefundsReq`","description":"The refund's details.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="refundPayment"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="refundPayment"/>
### createFulfillment
Create a Fulfillment of an Order using the fulfillment provider, and change the order's fulfillment status to either `partially_fulfilled` or `fulfilled`, depending on
whether all the items were fulfilled.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.createFulfillment(orderId, {
items: [
{
item_id,
quantity: 1
}
]
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order that the fulfillment belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostOrdersOrderFulfillmentsReq`","description":"The fulfillment to be created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createFulfillment"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createFulfillment"/>
### cancelFulfillment
Cancel an order's fulfillment and change its fulfillment status to `canceled`.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.cancelFulfillment(orderId, fulfillmentId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order that the fulfillment belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillmentId","type":"`string`","description":"The fulfillment's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancelFulfillment"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancelFulfillment"/>
### cancelSwapFulfillment
Cancel a swap's fulfillment and change its fulfillment status to `canceled`.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.cancelSwapFulfillment(orderId, swapId, fulfillmentId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order that the swap is associated with.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"swapId","type":"`string`","description":"The ID of the swap the fulfillment belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillmentId","type":"`string`","description":"The fulfillment's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancelSwapFulfillment"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancelSwapFulfillment"/>
### cancelClaimFulfillment
Cancel a claim's fulfillment and change its fulfillment status to `canceled`.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.cancelClaimFulfillment(orderId, claimId, fulfillmentId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order that the claim is associated with.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"claimId","type":"`string`","description":"The claim's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillmentId","type":"`string`","description":"The fulfillment's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancelClaimFulfillment"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancelClaimFulfillment"/>
### createShipment
Create a shipment and mark a fulfillment as shipped. This changes the order's fulfillment status to either `partially_shipped` or `shipped`, depending on
whether all the items were shipped.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.createShipment(order_id, {
fulfillment_id
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostOrdersOrderShipmentReq`","description":"The shipment to be created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createShipment"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createShipment"/>
### requestReturn
Request and create a return for items in an order. If the return shipping method is specified, it will be automatically fulfilled.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.requestReturn(orderId, {
items: [
{
item_id,
quantity: 1
}
]
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostOrdersOrderReturnsReq`","description":"The return to be created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="requestReturn"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details. You can access the return under the `returns` property.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="requestReturn"/>
### cancel
Cancel an order and change its status. This will also cancel any associated fulfillments and payments, and it may fail if the payment or fulfillment Provider
is unable to cancel the payment/fulfillment.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.cancel(orderId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancel"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancel"/>
### addShippingMethod
Add a shipping method to an order. If another shipping method exists with the same shipping profile, the previous shipping method will be replaced.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.addShippingMethod(orderId, {
price: 1000,
option_id
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostOrdersOrderShippingMethodsReq`","description":"The shipping method to be added.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addShippingMethod"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addShippingMethod"/>
### archive
Archive an order and change its status.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.archive(orderId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="archive"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="archive"/>
### createSwap
Create a swap for an order. This includes creating a return that is associated with the swap.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.createSwap(orderId, {
return_items: [
{
item_id,
quantity: 1
}
]
})
.then(({ order }) => {
console.log(order.swaps);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostOrdersOrderSwapsReq`","description":"The swap to be created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createSwap"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details. You can access the swap under the `swaps` property.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createSwap"/>
### cancelSwap
Cancel a swap and change its status.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.cancelSwap(orderId, swapId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order that the swap belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"swapId","type":"`string`","description":"The swap's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancelSwap"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details. You can access the swap under the `swaps` property.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancelSwap"/>
### fulfillSwap
Create a Fulfillment for a Swap and change its fulfillment status to `fulfilled`. If it requires any additional actions,
its fulfillment status may change to `requires_action`.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.fulfillSwap(orderId, swapId, {
no_notification: true,
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order that the swap belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"swapId","type":"`string`","description":"The swap's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostOrdersOrderSwapsSwapFulfillmentsReq`","description":"The fulfillment to be created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="fulfillSwap"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details. You can access the swap under the `swaps` property.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="fulfillSwap"/>
### createSwapShipment
Create a shipment for a swap and mark its fulfillment as shipped. This changes the swap's fulfillment status to either `shipped` or `partially_shipped`, depending on
whether all the items were shipped.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.createSwapShipment(orderId, swapId, {
fulfillment_id
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order that the swap belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"swapId","type":"`string`","description":"The swap's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostOrdersOrderSwapsSwapShipmentsReq`","description":"The shipment to be created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createSwapShipment"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details. You can access the swap under the `swaps` property.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createSwapShipment"/>
### processSwapPayment
Process a swap's payment either by refunding or issuing a payment. This depends on the `difference_due` of the swap. If `difference_due` is negative, the amount is refunded.
If `difference_due` is positive, the amount is captured.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.processSwapPayment(orderId, swapId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order that the swap belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"swapId","type":"`string`","description":"The swap's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="processSwapPayment"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details. You can access the swap under the `swaps` property.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="processSwapPayment"/>
### createClaim
Create a claim for an order. If a return shipping method is specified, a return will also be created and associated with the claim. If the claim's type is `refund`,
the refund is processed as well.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.createClaim(orderId, {
type: 'refund',
claim_items: [
{
item_id,
quantity: 1
}
]
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostOrdersOrderClaimsReq`","description":"The claim to be created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createClaim"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details. You can access the claim under the `claims` property.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createClaim"/>
### cancelClaim
Cancel a claim and change its status. A claim can't be canceled if it has a refund, if its fulfillments haven't been canceled, of if its associated return hasn't been canceled.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.cancelClaim(orderId, claimId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order that the claim belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"claimId","type":"`string`","description":"The claim's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancelClaim"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details. You can access the swap under the `claims` property.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancelClaim"/>
### updateClaim
Update a claim's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.updateClaim(orderId, claimId, {
no_notification: true
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order that the claim belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"claimId","type":"`string`","description":"The claim's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostOrdersOrderClaimsClaimReq`","description":"The attributes to update in the claim.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateClaim"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details. You can access the claims under the `claims` property.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateClaim"/>
### fulfillClaim
Create a Fulfillment for a Claim, and change its fulfillment status to `partially_fulfilled` or `fulfilled` depending on whether all the items were fulfilled.
It may also change the status to `requires_action` if any actions are required.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.fulfillClaim(orderId, claimId, {
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order that the claim belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"claimId","type":"`string`","description":"The claim's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostOrdersOrderClaimsClaimFulfillmentsReq`","description":"The fulfillment to be created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="fulfillClaim"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details. You can access the swap under the `claims` property.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="fulfillClaim"/>
### createClaimShipment
Create a shipment for the claim and mark its fulfillment as shipped. If the shipment is created successfully, this changes the claim's fulfillment status
to either `partially_shipped` or `shipped`, depending on whether all the items were shipped.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.createClaimShipment(orderId, claimId, {
fulfillment_id
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order that the claim belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"claimId","type":"`string`","description":"The claim's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostOrdersOrderClaimsClaimShipmentsReq`","description":"The shipment to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createClaimShipment"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order's details. You can access the swap under the `claims` property.","expandable":false,"children":[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createClaimShipment"/>

View File

@@ -1,130 +0,0 @@
---
slug: /references/js-client/AdminPaymentCollectionsResource
---
import { TypeList } from "docs-ui"
# AdminPaymentCollectionsResource
This class is used to send requests to [Admin Payment Collection API Routes](https://docs.medusajs.com/api/admin#payment-collections). All its method
are available in the JS Client under the `medusa.admin.paymentCollections` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A payment collection is useful for managing additional payments, such as for Order Edits, or installment payments.
## Methods
### retrieve
Retrieve a Payment Collection's details.
#### Example
A simple example that retrieves a payment collection by its ID:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.paymentCollections.retrieve(paymentCollectionId)
.then(({ payment_collection }) => {
console.log(payment_collection.id)
})
```
To specify relations that should be retrieved:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.paymentCollections.retrieve(paymentCollectionId, {
expand: "currency"
})
.then(({ payment_collection }) => {
console.log(payment_collection.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetPaymentCollectionsParams`","description":"Configurations to apply on the retrieved payment collection.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPaymentCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the payment collection's details.","expandable":false,"children":[{"name":"AdminPaymentCollectionsRes","type":"`AdminPaymentCollectionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### update
Update a payment collection's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.paymentCollections.update(paymentCollectionId, {
description
})
.then(({ payment_collection }) => {
console.log(payment_collection.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminUpdatePaymentCollectionsReq`","description":"The attributes to update in the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPaymentCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the payment collection's details.","expandable":false,"children":[{"name":"AdminPaymentCollectionsRes","type":"`AdminPaymentCollectionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete a payment collection. Only payment collections with the statuses `canceled` or `not_paid` can be deleted.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.paymentCollections.delete(paymentCollectionId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPaymentCollectionDeleteRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"AdminPaymentCollectionDeleteRes","type":"`AdminPaymentCollectionDeleteRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### markAsAuthorized
Set the status of a payment collection as `authorized`. This will also change the `authorized_amount` of the payment collection.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.paymentCollections.markAsAuthorized(paymentCollectionId)
.then(({ payment_collection }) => {
console.log(payment_collection.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="markAsAuthorized"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPaymentCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the payment collection's details.","expandable":false,"children":[{"name":"AdminPaymentCollectionsRes","type":"`AdminPaymentCollectionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="markAsAuthorized"/>

View File

@@ -1,93 +0,0 @@
---
slug: /references/js-client/AdminPaymentsResource
---
import { TypeList } from "docs-ui"
# AdminPaymentsResource
This class is used to send requests to [Admin Payment API Routes](https://docs.medusajs.com/api/admin#payments). All its method
are available in the JS Client under the `medusa.admin.payments` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A payment can be related to an order, swap, return, or more. It can be captured or refunded.
## Methods
### retrieve
Retrieve a payment's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.payments.retrieve(paymentId)
.then(({ payment }) => {
console.log(payment.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The payment's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`GetPaymentsParams`","description":"Configurations to apply on the retrieved payment.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPaymentRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the payment's details.","expandable":false,"children":[{"name":"AdminPaymentRes","type":"`AdminPaymentRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### capturePayment
Capture a payment.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.payments.capturePayment(paymentId)
.then(({ payment }) => {
console.log(payment.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The payment's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="capturePayment"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPaymentRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the payment's details.","expandable":false,"children":[{"name":"AdminPaymentRes","type":"`AdminPaymentRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="capturePayment"/>
### refundPayment
Refund a payment. The payment must be captured first.
#### Example
```ts
import { RefundReason } from "@medusajs/medusa";
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.payments.refundPayment(paymentId, {
amount: 1000,
reason: RefundReason.RETURN,
note: "Do not like it",
})
.then(({ refund }) => {
console.log(refund.amount);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The payment's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostPaymentRefundsReq`","description":"The refund to be created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="refundPayment"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminRefundRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the refund's details.","expandable":false,"children":[{"name":"AdminRefundRes","type":"`AdminRefundRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="refundPayment"/>

View File

@@ -1,373 +0,0 @@
---
slug: /references/js-client/AdminPriceListResource
---
import { TypeList } from "docs-ui"
# AdminPriceListResource
This class is used to send requests to [Admin Price List API Routes](https://docs.medusajs.com/api/admin#price-lists). All its method
are available in the JS Client under the `medusa.admin.priceLists` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A price list are special prices applied to products based on a set of conditions, such as customer group.
Related Guide: [How to manage price lists](https://docs.medusajs.com/modules/price-lists/admin/manage-price-lists).
## Methods
### create
Create a price list.
#### Example
```ts
medusa.admin.priceLists.create({
name: "New Price List",
description: "A new price list",
type: PriceListType.SALE,
prices: [
{
amount: 1000,
variant_id,
currency_code: "eur"
}
]
})
.then(({ price_list }) => {
console.log(price_list.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostPriceListsPriceListReq`","description":"The price list to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPriceListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the price list details.","expandable":false,"children":[{"name":"AdminPriceListRes","type":"`AdminPriceListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update a price list's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.update(priceListId, {
name: "New Price List"
})
.then(({ price_list }) => {
console.log(price_list.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the price list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostPriceListsPriceListPriceListReq`","description":"The attributes to update in the price list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPriceListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the price list details.","expandable":false,"children":[{"name":"AdminPriceListRes","type":"`AdminPriceListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete a price list and its associated prices.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.delete(priceListId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the price list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### retrieve
Retrieve a price list's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.retrieve(priceListId)
.then(({ price_list }) => {
console.log(price_list.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the price list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPriceListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the price list details.","expandable":false,"children":[{"name":"AdminPriceListRes","type":"`AdminPriceListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of price lists. The price lists can be filtered by fields such as `q` or `status` passed in the `query` parameter. The price lists can also be sorted or paginated.
#### Example
To list price lists:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.list()
.then(({ price_lists, limit, offset, count }) => {
console.log(price_lists.length);
})
```
To specify relations that should be retrieved within the price lists:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.list({
expand: "prices"
})
.then(({ price_lists, limit, offset, count }) => {
console.log(price_lists.length);
})
```
By default, only the first `10` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.list({
expand: "prices",
limit,
offset
})
.then(({ price_lists, limit, offset, count }) => {
console.log(price_lists.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetPriceListPaginationParams`","description":"Filters and pagination configurations to apply on the retrieved price lists.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPriceListsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of price lists with pagination fields.","expandable":false,"children":[{"name":"AdminPriceListsListRes","type":"`AdminPriceListsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### listProducts
Retrieve a price list's products. The products can be filtered by fields such as `q` or `status` passed in the `query` parameter. The products can also be sorted or paginated.
#### Example
To list products in a price list:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.listProducts(priceListId)
.then(({ products, limit, offset, count }) => {
console.log(products.length);
})
```
To specify relations that should be retrieved within the products:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.listProducts(priceListId, {
expand: "variants"
})
.then(({ products, limit, offset, count }) => {
console.log(products.length);
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.listProducts(priceListId, {
expand: "variants",
limit,
offset
})
.then(({ products, limit, offset, count }) => {
console.log(products.length);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the price list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetPriceListsPriceListProductsParams`","description":"Filters and pagination configurations applied on the retrieved products.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listProducts"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPriceListsProductsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of products with pagination fields.","expandable":false,"children":[{"name":"AdminPriceListsProductsListRes","type":"`AdminPriceListsProductsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listProducts"/>
### addPrices
Add or update a list of prices in a price list.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.addPrices(priceListId, {
prices: [
{
amount: 1000,
variant_id,
currency_code: "eur"
}
]
})
.then(({ price_list }) => {
console.log(price_list.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the price list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostPriceListPricesPricesReq`","description":"The details of prices to add or update.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addPrices"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPriceListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the price list's details.","expandable":false,"children":[{"name":"AdminPriceListRes","type":"`AdminPriceListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addPrices"/>
### deletePrices
Delete a list of prices in a price list
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.deletePrices(priceListId, {
price_ids: [
price_id
]
})
.then(({ ids, object, deleted }) => {
console.log(ids.length);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the price list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminDeletePriceListPricesPricesReq`","description":"The prices to delete.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deletePrices"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPriceListDeleteBatchRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"AdminPriceListDeleteBatchRes","type":"`AdminPriceListDeleteBatchRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deletePrices"/>
### deleteProductPrices
Delete all the prices related to a specific product in a price list.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.deleteProductPrices(priceListId, productId)
.then(({ ids, object, deleted }) => {
console.log(ids.length);
})
```
#### Parameters
<TypeList types={[{"name":"priceListId","type":"`string`","description":"The ID of the price list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"productId","type":"`string`","description":"The product's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteProductPrices"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPriceListDeleteBatchRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"AdminPriceListDeleteBatchRes","type":"`AdminPriceListDeleteBatchRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteProductPrices"/>
### deleteVariantPrices
Delete all the prices related to a specific product variant in a price list.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.deleteVariantPrices(priceListId, variantId)
.then(({ ids, object, deleted }) => {
console.log(ids);
})
```
#### Parameters
<TypeList types={[{"name":"priceListId","type":"`string`","description":"The ID of the price list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variantId","type":"`string`","description":"The ID of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteVariantPrices"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPriceListDeleteBatchRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"AdminPriceListDeleteBatchRes","type":"`AdminPriceListDeleteBatchRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteVariantPrices"/>
### deleteProductsPrices
Delete all the prices associated with multiple products in a price list.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.deleteProductsPrices(priceListId, {
product_ids: [
productId1,
productId2,
]
})
.then(({ ids, object, deleted }) => {
console.log(ids.length);
})
```
#### Parameters
<TypeList types={[{"name":"priceListId","type":"`string`","description":"The ID of the price list.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminDeletePriceListsPriceListProductsPricesBatchReq`","description":"The products whose prices should be deleted.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteProductsPrices"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPriceListDeleteBatchRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"AdminPriceListDeleteBatchRes","type":"`AdminPriceListDeleteBatchRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteProductsPrices"/>

View File

@@ -1,257 +0,0 @@
---
slug: /references/js-client/AdminProductCategoriesResource
---
import { TypeList } from "docs-ui"
# AdminProductCategoriesResource
:::note
To use this resource, make sure to [enable its feature flag: product_categories](https://docs.medusajs.com/development/feature-flags/toggle)
:::
This class is used to send requests to [Admin Product Category API Routes](https://docs.medusajs.com/api/admin#product-categories). All its method
are available in the JS Client under the `medusa.admin.productCategories` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Products can be categoriezed into categories. A product can be added into more than one category.
Related Guide: [How to manage product categories](https://docs.medusajs.com/modules/products/admin/manage-categories).
## Methods
### retrieve
Retrieve a product category's details.
#### Example
A simple example that retrieves an order by its ID:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productCategories.retrieve(productCategoryId)
.then(({ product_category }) => {
console.log(product_category.id);
})
```
To specify relations that should be retrieved:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productCategories.retrieve(productCategoryId, {
expand: "category_children"
})
.then(({ product_category }) => {
console.log(product_category.id);
})
```
#### Parameters
<TypeList types={[{"name":"productCategoryId","type":"`string`","description":"The ID of the product category.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetProductCategoryParams`","description":"Configurations to apply on the retrieved product category.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductCategoriesCategoryRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product category's details.","expandable":false,"children":[{"name":"AdminProductCategoriesCategoryRes","type":"`AdminProductCategoriesCategoryRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### create
Create a product category.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productCategories.create({
name: "Skinny Jeans",
})
.then(({ product_category }) => {
console.log(product_category.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostProductCategoriesReq`","description":"The product category's details.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductCategoriesCategoryRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product category's details.","expandable":false,"children":[{"name":"AdminProductCategoriesCategoryRes","type":"`AdminProductCategoriesCategoryRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Updates a product category.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productCategories.update(productCategoryId, {
name: "Skinny Jeans"
})
.then(({ product_category }) => {
console.log(product_category.id);
})
```
#### Parameters
<TypeList types={[{"name":"productCategoryId","type":"`string`","description":"The ID of the product category.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostProductCategoriesCategoryReq`","description":"The attributes to update in the product category.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductCategoriesCategoryRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product category's details.","expandable":false,"children":[{"name":"AdminProductCategoriesCategoryRes","type":"`AdminProductCategoriesCategoryRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### list
Retrieve a list of product categories. The product categories can be filtered by fields such as `q` or `handle` passed in the `query` parameter.
The product categories can also be paginated.
#### Example
To list product categories:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productCategories.list()
.then(({ product_categories, limit, offset, count }) => {
console.log(product_categories.length);
})
```
To specify relations that should be retrieved within the product category:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productCategories.list({
expand: "category_children"
})
.then(({ product_categories, limit, offset, count }) => {
console.log(product_categories.length);
})
```
By default, only the first `100` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productCategories.list({
expand: "category_children",
limit,
offset
})
.then(({ product_categories, limit, offset, count }) => {
console.log(product_categories.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetProductCategoriesParams`","description":"Filters and pagination configurations to apply on the retrieved product categories.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductCategoriesListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of product categories with pagination fields.","expandable":false,"children":[{"name":"AdminProductCategoriesListRes","type":"`AdminProductCategoriesListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### delete
Delete a product category. This does not delete associated products.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productCategories.delete(productCategoryId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"productCategoryId","type":"`string`","description":"The ID of the product category.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### removeProducts
Remove a list of products from a product category.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productCategories.removeProducts(productCategoryId, {
product_ids: [
{
id: productId
}
]
})
.then(({ product_category }) => {
console.log(product_category.id);
})
```
#### Parameters
<TypeList types={[{"name":"productCategoryId","type":"`string`","description":"The ID of the product category.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminDeleteProductCategoriesCategoryProductsBatchReq`","description":"The products to delete.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeProducts"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductCategoriesCategoryRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product category's details.","expandable":false,"children":[{"name":"AdminProductCategoriesCategoryRes","type":"`AdminProductCategoriesCategoryRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeProducts"/>
### addProducts
Add a list of products to a product category.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productCategories.addProducts(productCategoryId, {
product_ids: [
{
id: productId
}
]
})
.then(({ product_category }) => {
console.log(product_category.id);
})
```
#### Parameters
<TypeList types={[{"name":"productCategoryId","type":"`string`","description":"The ID of the product category.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostProductCategoriesCategoryProductsBatchReq`","description":"The products to add.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addProducts"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductCategoriesCategoryRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product category's details.","expandable":false,"children":[{"name":"AdminProductCategoriesCategoryRes","type":"`AdminProductCategoriesCategoryRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addProducts"/>

View File

@@ -1,58 +0,0 @@
---
slug: /references/js-client/AdminProductTagsResource
---
import { TypeList } from "docs-ui"
# AdminProductTagsResource
This class is used to send requests to [Admin Product Tag API Routes](https://docs.medusajs.com/api/admin#product-tags). All its method
are available in the JS Client under the `medusa.admin.productTags` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Product tags are string values created when you create or update a product with a new tag.
Products can have more than one tag, and products can share tags. This allows admins to associate products to similar tags that can be used to filter products.
## Methods
### list
Retrieve a list of product tags. The product tags can be filtered by fields such as `q` or `value` passed in the `query` parameter. The product tags can also be sorted or paginated.
#### Example
To list product tags:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productTags.list()
.then(({ product_tags }) => {
console.log(product_tags.length);
})
```
By default, only the first `10` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productTags.list({
limit,
offset
})
.then(({ product_tags }) => {
console.log(product_tags.length);
})
```
#### Parameters
<TypeList types={[{"name":"query","type":"`AdminGetProductTagsParams`","description":"Filters and pagination configurations to apply on the retrieved product tags.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductTagsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of product tags with pagination fields.","expandable":false,"children":[{"name":"AdminProductTagsListRes","type":"`AdminProductTagsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>

View File

@@ -1,59 +0,0 @@
---
slug: /references/js-client/AdminProductTypesResource
---
import { TypeList } from "docs-ui"
# AdminProductTypesResource
This class is used to send requests to [Admin Product Type API Routes](https://docs.medusajs.com/api/admin#product-types). All its method
are available in the JS Client under the `medusa.admin.productTypes` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Product types are string values created when you create or update a product with a new type.
Products can have one type, and products can share types. This allows admins to associate products with a type that can be used to filter products.
## Methods
### list
Retrieve a list of product types. The product types can be filtered by fields such as `q` or `value` passed in the `query` parameter.
The product types can also be sorted or paginated.
#### Example
To list product types:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productTypes.list()
.then(({ product_types }) => {
console.log(product_types.length);
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productTypes.list({
limit,
offset
})
.then(({ product_types }) => {
console.log(product_types.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetProductTypesParams`","description":"Filters and pagination configurations to apply on the retrieved product types.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductTypesListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of product types with pagination fields.","expandable":false,"children":[{"name":"AdminProductTypesListRes","type":"`AdminProductTypesListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>

View File

@@ -1,420 +0,0 @@
---
slug: /references/js-client/AdminProductsResource
---
import { TypeList } from "docs-ui"
# AdminProductsResource
This class is used to send requests to [Admin Product API Routes](https://docs.medusajs.com/api/admin#products). All its method
are available in the JS Client under the `medusa.admin.products` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Products are saleable items in a store. This also includes [saleable gift cards](https://docs.medusajs.com/modules/gift-cards/admin/manage-gift-cards#manage-gift-card-product) in a store.
Related Guide: [How to manage products](https://docs.medusajs.com/modules/products/admin/manage-products).
## Methods
### create
Create a new Product. This API Route can also be used to create a gift card if the `is_giftcard` field is set to `true`.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.create({
title: "Shirt",
is_giftcard: false,
discountable: true
})
.then(({ product }) => {
console.log(product.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostProductsReq`","description":"The product to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product's details.","expandable":false,"children":[{"name":"AdminProductsRes","type":"`AdminProductsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### retrieve
Retrieve a product's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.retrieve(productId)
.then(({ product }) => {
console.log(product.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The product's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product's details.","expandable":false,"children":[{"name":"AdminProductsRes","type":"`AdminProductsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### update
Update a Product's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.update(productId, {
title: "Shirt",
})
.then(({ product }) => {
console.log(product.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The product's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostProductsProductReq`","description":"The attributes to update in a product.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product's details.","expandable":false,"children":[{"name":"AdminProductsRes","type":"`AdminProductsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete a product and its associated product variants and options.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.delete(productId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The product's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsDeleteRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"AdminProductsDeleteRes","type":"`AdminProductsDeleteRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### list
Retrieve a list of products. The products can be filtered by fields such as `q` or `status` passed in the `query` parameter. The products can also be sorted or paginated.
#### Example
To list products:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.list()
.then(({ products, limit, offset, count }) => {
console.log(products.length);
})
```
To specify relations that should be retrieved within the products:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.list({
expand: "images"
})
.then(({ products, limit, offset, count }) => {
console.log(products.length);
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.list({
expand: "images",
limit,
offset
})
.then(({ products, limit, offset, count }) => {
console.log(products.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetProductsParams`","description":"Filters and pagination configurations to apply on the retrieved products.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of products with pagination fields.","expandable":false,"children":[{"name":"AdminProductsListRes","type":"`AdminProductsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### listTags
Retrieve a list of Product Tags with how many times each is used in products.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.listTags()
.then(({ tags }) => {
console.log(tags.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listTags"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsListTagsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of tags.","expandable":false,"children":[{"name":"AdminProductsListTagsRes","type":"`AdminProductsListTagsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listTags"/>
### setMetadata
Set the metadata of a product. It can be any key-value pair, which allows adding custom data to a product. Learn about how you can update and delete the metadata attribute
[here](https://docs.medusajs.com/development/entities/overview#metadata-attribute).
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.setMetadata(productId, {
key: "test",
value: "true"
})
.then(({ product }) => {
console.log(product.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The product's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostProductsProductMetadataReq`","description":"The metadata details to add, update, or delete.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="setMetadata"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product's details.","expandable":false,"children":[{"name":"AdminProductsRes","type":"`AdminProductsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="setMetadata"/>
### createVariant
Create a product variant associated with a product. Each product variant must have a unique combination of product option values.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.createVariant(productId, {
title: "Color",
prices: [
{
amount: 1000,
currency_code: "eur"
}
],
options: [
{
option_id,
value: "S"
}
],
inventory_quantity: 100
})
.then(({ product }) => {
console.log(product.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product that the variant belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostProductsProductVariantsReq`","description":"The product variant to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createVariant"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product's details. You can access the variant under the `variants` property.","expandable":false,"children":[{"name":"AdminProductsRes","type":"`AdminProductsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createVariant"/>
### updateVariant
Update a product variant's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.updateVariant(productId, variantId, {
title: "Color",
prices: [
{
amount: 1000,
currency_code: "eur"
}
],
options: [
{
option_id,
value: "S"
}
],
inventory_quantity: 100
})
.then(({ product }) => {
console.log(product.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product that the variant belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variantId","type":"`string`","description":"The ID of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostProductsProductVariantsVariantReq`","description":"The attributes to update in the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateVariant"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product's details. You can access the variant under the `variants` property.","expandable":false,"children":[{"name":"AdminProductsRes","type":"`AdminProductsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateVariant"/>
### deleteVariant
Delete a product variant.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.deleteVariant(productId, variantId)
.then(({ variant_id, object, deleted, product }) => {
console.log(product.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product that the variant belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"variantId","type":"`string`","description":"The ID of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteVariant"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsDeleteVariantRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"AdminProductsDeleteVariantRes","type":"`AdminProductsDeleteVariantRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteVariant"/>
### listVariants
List the product variants associated with a product. The product variants can be filtered by fields such as `q` or `manage_inventory` passed in the `query` parameter. The product variants can also be sorted or paginated.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.listVariants(productId, {
limit: 10,
})
.then(({ variants, limit, offset, count }) => {
console.log(variants.length);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product that the variants belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetProductsVariantsParams`","description":"Filters and pagination configurations to apply on the retrieved product variants. If undefined, the first 100 records are retrieved.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listVariants"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsListVariantsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of product variants with pagination fields.","expandable":false,"children":[{"name":"AdminProductsListVariantsRes","type":"`AdminProductsListVariantsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listVariants"/>
### addOption
Add a product option to a product.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.addOption(productId, {
title: "Size"
})
.then(({ product }) => {
console.log(product.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The product's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostProductsProductOptionsReq`","description":"The option to add.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addOption"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product's details. You can access the variant under the `options` property.","expandable":false,"children":[{"name":"AdminProductsRes","type":"`AdminProductsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addOption"/>
### updateOption
Update a product option's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.updateOption(productId, optionId, {
title: "Size"
})
.then(({ product }) => {
console.log(product.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product that the option belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"optionId","type":"`string`","description":"The ID of the product option.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostProductsProductOptionsOption`","description":"The attributes to update in the product option.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateOption"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product's details. You can access the variant under the `options` property.","expandable":false,"children":[{"name":"AdminProductsRes","type":"`AdminProductsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updateOption"/>
### deleteOption
Delete a product option. If there are product variants that use this product option, they must be deleted before deleting the product option.
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product that the option belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"optionId","type":"`string`","description":"The ID of the product option.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteOption"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminProductsDeleteOptionRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"AdminProductsDeleteOptionRes","type":"`AdminProductsDeleteOptionRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteOption"/>

View File

@@ -1,270 +0,0 @@
---
slug: /references/js-client/AdminPublishableApiKeyResource
---
import { TypeList } from "docs-ui"
# AdminPublishableApiKeyResource
This class is used to send requests to [Admin Publishable API Key API Routes](https://docs.medusajs.com/api/admin#publishable-api-keys). All its method
are available in the JS Client under the `medusa.admin.publishableApiKeys` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Publishable API Keys can be used to scope Store API calls with an API key, determining what resources are retrieved when querying the API.
For example, a publishable API key can be associated with one or more sales channels. When it is passed in the header of a request to the List Product store API Route,
the sales channels are inferred from the key and only products associated with those sales channels are retrieved.
Admins can manage publishable API keys and their associated resources. Currently, only Sales Channels are supported as a resource.
Related Guide: [How to manage publishable API keys](https://docs.medusajs.com/development/publishable-api-keys/admin/manage-publishable-api-keys).
## Methods
### retrieve
Retrieve a publishable API key's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.publishableApiKeys.retrieve(publishableApiKeyId)
.then(({ publishable_api_key }) => {
console.log(publishable_api_key.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the publishable API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPublishableApiKeysRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the publishable API key's details.","expandable":false,"children":[{"name":"AdminPublishableApiKeysRes","type":"`AdminPublishableApiKeysRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of publishable API keys. The publishable API keys can be filtered by fields such as `q` passed in `query`. The publishable API keys can also be paginated.
#### Example
To list publishable API keys:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.publishableApiKeys.list()
.then(({ publishable_api_keys, count, limit, offset }) => {
console.log(publishable_api_keys)
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.publishableApiKeys.list({
limit,
offset
})
.then(({ publishable_api_keys, count, limit, offset }) => {
console.log(publishable_api_keys)
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`GetPublishableApiKeysParams`","description":"Filters and pagination configurations to apply on the retrieved publishable API keys.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPublishableApiKeysListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of publishable API keys with pagination fields.","expandable":false,"children":[{"name":"AdminPublishableApiKeysListRes","type":"`AdminPublishableApiKeysListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### create
Create a publishable API key.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.publishableApiKeys.create({
title
})
.then(({ publishable_api_key }) => {
console.log(publishable_api_key.id)
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostPublishableApiKeysReq`","description":"The publishable API key to be created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPublishableApiKeysRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the publishbale API key's details.","expandable":false,"children":[{"name":"AdminPublishableApiKeysRes","type":"`AdminPublishableApiKeysRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update a publishable API key's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.publishableApiKeys.update(publishableApiKeyId, {
title: "new title"
})
.then(({ publishable_api_key }) => {
console.log(publishable_api_key.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the publishable API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostPublishableApiKeysPublishableApiKeyReq`","description":"The attributes to update in the publishable API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPublishableApiKeysRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the publishbale API key's details.","expandable":false,"children":[{"name":"AdminPublishableApiKeysRes","type":"`AdminPublishableApiKeysRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete a publishable API key. Associated resources, such as sales channels, are not deleted.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.publishableApiKeys.delete(publishableApiKeyId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the publishable API key","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the delete operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### revoke
Revoke a publishable API key. Revoking the publishable API Key can't be undone, and the key can't be used in future requests.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.publishableApiKeys.revoke(publishableApiKeyId)
.then(({ publishable_api_key }) => {
console.log(publishable_api_key.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the publishable API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="revoke"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPublishableApiKeysRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the publishbale API key's details.","expandable":false,"children":[{"name":"AdminPublishableApiKeysRes","type":"`AdminPublishableApiKeysRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="revoke"/>
### addSalesChannelsBatch
Add a list of sales channels to a publishable API key.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.publishableApiKeys.addSalesChannelsBatch(publishableApiKeyId, {
sales_channel_ids: [
{
id: channelId
}
]
})
.then(({ publishable_api_key }) => {
console.log(publishable_api_key.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the publishable API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostPublishableApiKeySalesChannelsBatchReq`","description":"The sales channels to add.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addSalesChannelsBatch"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPublishableApiKeysRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the publishbale API key's details.","expandable":false,"children":[{"name":"AdminPublishableApiKeysRes","type":"`AdminPublishableApiKeysRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addSalesChannelsBatch"/>
### deleteSalesChannelsBatch
Remove a list of sales channels from a publishable API key. This doesn't delete the sales channels and only removes the association between them and the publishable API key.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.publishableApiKeys.deleteSalesChannelsBatch(publishableApiKeyId, {
sales_channel_ids: [
{
id: channelId
}
]
})
.then(({ publishable_api_key }) => {
console.log(publishable_api_key.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the publishable API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminDeletePublishableApiKeySalesChannelsBatchReq`","description":"The sales channels to delete from the publishable API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteSalesChannelsBatch"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPublishableApiKeysRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the publishbale API key's details.","expandable":false,"children":[{"name":"AdminPublishableApiKeysRes","type":"`AdminPublishableApiKeysRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteSalesChannelsBatch"/>
### listSalesChannels
List the sales channels associated with a publishable API key. The sales channels can be filtered by fields such as `q` passed in the `query` parameter.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.publishableApiKeys.listSalesChannels()
.then(({ sales_channels }) => {
console.log(sales_channels.length)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the publishable API key.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`GetPublishableApiKeySalesChannelsParams`","description":"Filters to apply on the retrieved sales channels.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listSalesChannels"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPublishableApiKeysListSalesChannelsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of sales channels.","expandable":false,"children":[{"name":"AdminPublishableApiKeysListSalesChannelsRes","type":"`AdminPublishableApiKeysListSalesChannelsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listSalesChannels"/>

View File

@@ -1,345 +0,0 @@
---
slug: /references/js-client/AdminRegionsResource
---
import { TypeList } from "docs-ui"
# AdminRegionsResource
This class is used to send requests to [Admin Region API Routes](https://docs.medusajs.com/api/admin#regions). All its method
are available in the JS Client under the `medusa.admin.regions` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Regions are different countries or geographical regions that the commerce store serves customers in.
Admins can manage these regions, their providers, and more.
Related Guide: [How to manage regions](https://docs.medusajs.com/modules/regions-and-currencies/admin/manage-regions).
## Methods
### create
Create a region.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.create({
name: "Europe",
currency_code: "eur",
tax_rate: 0,
payment_providers: [
"manual"
],
fulfillment_providers: [
"manual"
],
countries: [
"DK"
]
})
.then(({ region }) => {
console.log(region.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostRegionsReq`","description":"The region to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminRegionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the region's details.","expandable":false,"children":[{"name":"AdminRegionsRes","type":"`AdminRegionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update a region's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.update(regionId, {
name: "Europe"
})
.then(({ region }) => {
console.log(region.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The region's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostRegionsRegionReq`","description":"The attributes to update in the region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminRegionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the region's details.","expandable":false,"children":[{"name":"AdminRegionsRes","type":"`AdminRegionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete a region. Associated resources, such as providers or currencies are not deleted. Associated tax rates are deleted.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.delete(regionId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The region's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### retrieve
Retrieve a region's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.retrieve(regionId)
.then(({ region }) => {
console.log(region.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The region's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetRegionsRegionParams`","description":"Query params","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminRegionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the region's details.","expandable":false,"children":[{"name":"AdminRegionsRes","type":"`AdminRegionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of Regions. The regions can be filtered by fields such as `created_at` passed in the `query` parameter. The regions can also be paginated.
#### Example
To list regions:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.list()
.then(({ regions, limit, offset, count }) => {
console.log(regions.length);
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.list({
limit,
offset
})
.then(({ regions, limit, offset, count }) => {
console.log(regions.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetRegionsParams`","description":"Filters and pagination configurations to apply on the retrieved regions.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminRegionsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of regions with pagination fields.","expandable":false,"children":[{"name":"AdminRegionsListRes","type":"`AdminRegionsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### addCountry
Add a country to the list of countries in a region.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.addCountry(regionId, {
country_code: "dk"
})
.then(({ region }) => {
console.log(region.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The region's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostRegionsRegionCountriesReq`","description":"The country to add.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addCountry"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminRegionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the region's details.","expandable":false,"children":[{"name":"AdminRegionsRes","type":"`AdminRegionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addCountry"/>
### deleteCountry
Delete a country from the list of countries in a region. The country will still be available in the system, and it can be used in other regions.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.deleteCountry(regionId, "dk")
.then(({ region }) => {
console.log(region.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The region's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"country_code","type":"`string`","description":"The code of the country to delete from the region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteCountry"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminRegionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the region's details.","expandable":false,"children":[{"name":"AdminRegionsRes","type":"`AdminRegionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteCountry"/>
### addFulfillmentProvider
Add a fulfillment provider to the list of fulfullment providers in a region.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.addFulfillmentProvider(regionId, {
provider_id: "manual"
})
.then(({ region }) => {
console.log(region.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The region's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostRegionsRegionFulfillmentProvidersReq`","description":"The fulfillment provider to add.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addFulfillmentProvider"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminRegionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the region's details.","expandable":false,"children":[{"name":"AdminRegionsRes","type":"`AdminRegionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addFulfillmentProvider"/>
### deleteFulfillmentProvider
Delete a fulfillment provider from a region. The fulfillment provider will still be available for usage in other regions.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.deleteFulfillmentProvider(regionId, "manual")
.then(({ region }) => {
console.log(region.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The region's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The ID of the fulfillment provider to delete from the region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteFulfillmentProvider"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminRegionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the region's details.","expandable":false,"children":[{"name":"AdminRegionsRes","type":"`AdminRegionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteFulfillmentProvider"/>
### retrieveFulfillmentOptions
Retrieve a list of fulfillment options available in a region.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.retrieveFulfillmentOptions(regionId)
.then(({ fulfillment_options }) => {
console.log(fulfillment_options.length);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The region's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieveFulfillmentOptions"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminGetRegionsRegionFulfillmentOptionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of fulfillment options.","expandable":false,"children":[{"name":"AdminGetRegionsRegionFulfillmentOptionsRes","type":"`AdminGetRegionsRegionFulfillmentOptionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieveFulfillmentOptions"/>
### addPaymentProvider
Add a payment provider to the list of payment providers in a region.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.addPaymentProvider(regionId, {
provider_id: "manual"
})
.then(({ region }) => {
console.log(region.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The region's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostRegionsRegionPaymentProvidersReq`","description":"The payment provider to add.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addPaymentProvider"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminRegionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the region's details.","expandable":false,"children":[{"name":"AdminRegionsRes","type":"`AdminRegionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addPaymentProvider"/>
### deletePaymentProvider
Delete a payment provider from a region. The payment provider will still be available for usage in other regions.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.deletePaymentProvider(regionId, "manual")
.then(({ region }) => {
console.log(region.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The region's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The ID of the payment provider to delete from the region.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deletePaymentProvider"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminRegionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the region's details.","expandable":false,"children":[{"name":"AdminRegionsRes","type":"`AdminRegionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deletePaymentProvider"/>

View File

@@ -1,179 +0,0 @@
---
slug: /references/js-client/AdminReservationsResource
---
import { TypeList } from "docs-ui"
# AdminReservationsResource
This class is used to send requests to [Admin Reservation API Routes](https://docs.medusajs.com/api/admin#reservations). To use these API Routes, make sure to install the
[@medusajs/inventory](https://docs.medusajs.com/modules/multiwarehouse/install-modules#inventory-module) module in your Medusa backend.
All methods in this class require [authentication](../../../modules/user/page.mdx). The methods
are available in the JS Client under the `medusa.admin.reservations` property.
Reservations, provided by the [Inventory Module](https://docs.medusajs.com/modules/multiwarehouse/inventory-module), are quantities of an item that are reserved, typically when an order is placed but not yet fulfilled.
Reservations can be associated with any resources, but commonly with line items of an order.
Related Guide: [How to manage item allocations in orders](https://docs.medusajs.com/modules/multiwarehouse/admin/manage-item-allocations-in-orders).
## Methods
### retrieve
Retrieve a reservation's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.reservations.retrieve(reservationId)
.then(({ reservation }) => {
console.log(reservation.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The reservation's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, unknown>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminReservationsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the reservation's details.","expandable":false,"children":[{"name":"AdminReservationsRes","type":"`AdminReservationsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of reservations. The reservations can be filtered by fields such as `location_id` or `quantity` passed in the `query` parameter. The reservations can also be paginated.
#### Example
To list reservations:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.reservations.list()
.then(({ reservations, count, limit, offset }) => {
console.log(reservations.length)
})
```
To specify relations that should be retrieved within the reservations:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.reservations.list({
expand: "location"
})
.then(({ reservations, count, limit, offset }) => {
console.log(reservations.length)
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.reservations.list({
expand: "location",
limit,
offset
})
.then(({ reservations, count, limit, offset }) => {
console.log(reservations.length)
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, unknown>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetReservationsParams`","description":"Filters and pagination parameters to apply on the retrieved reservations.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminReservationsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of reservations with pagination fields.","expandable":false,"children":[{"name":"AdminReservationsListRes","type":"`AdminReservationsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### create
Create a reservation which can be associated with any resource, such as an order's line item.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.reservations.create({
line_item_id: "item_123",
location_id: "loc_123",
inventory_item_id: "iitem_123",
quantity: 1
})
.then(({ reservation }) => {
console.log(reservation.id);
});
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostReservationsReq`","description":"The reservation to be created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, unknown>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminReservationsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the reservation's details.","expandable":false,"children":[{"name":"AdminReservationsRes","type":"`AdminReservationsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update a reservation's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.reservations.update(reservationId, {
quantity: 3
})
.then(({ reservation }) => {
console.log(reservation.id);
});
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the reservation.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostReservationsReservationReq`","description":"The attributes to update in the reservation.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, unknown>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminReservationsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the reservation's details.","expandable":false,"children":[{"name":"AdminReservationsRes","type":"`AdminReservationsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete a reservation. Associated resources, such as the line item, will not be deleted.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.reservations.delete(reservationId)
.then(({ id, object, deleted }) => {
console.log(id);
});
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the reservation.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, unknown>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>

View File

@@ -1,144 +0,0 @@
---
slug: /references/js-client/AdminReturnReasonsResource
---
import { TypeList } from "docs-ui"
# AdminReturnReasonsResource
This class is used to send requests to [Admin Return Reason API Routes](https://docs.medusajs.com/api/admin#return-reasons). All its method
are available in the JS Client under the `medusa.admin.returnReasons` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Return reasons are key-value pairs that are used to specify why an order return is being created.
Admins can manage available return reasons, and they can be used by both admins and customers when creating a return.
Related Guide: [How to manage return reasons](https://docs.medusajs.com/modules/orders/admin/manage-returns#manage-return-reasons).
## Methods
### create
Create a return reason.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.returnReasons.create({
label: "Damaged",
value: "damaged"
})
.then(({ return_reason }) => {
console.log(return_reason.id);
});
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostReturnReasonsReq`","description":"The return reason to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminReturnReasonsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the return reason's details.","expandable":false,"children":[{"name":"AdminReturnReasonsRes","type":"`AdminReturnReasonsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update a return reason's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.returnReasons.update(returnReasonId, {
label: "Damaged"
})
.then(({ return_reason }) => {
console.log(return_reason.id);
});
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The return reason's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostReturnReasonsReasonReq`","description":"The attributes to update in the return reason.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminReturnReasonsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the return reason's details.","expandable":false,"children":[{"name":"AdminReturnReasonsRes","type":"`AdminReturnReasonsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete a return reason.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.returnReasons.delete(returnReasonId)
.then(({ id, object, deleted }) => {
console.log(id);
});
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the return reason.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### retrieve
Retrieve a return reason's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.returnReasons.retrieve(returnReasonId)
.then(({ return_reason }) => {
console.log(return_reason.id);
});
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The return reason's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminReturnReasonsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the return reason's details.","expandable":false,"children":[{"name":"AdminReturnReasonsRes","type":"`AdminReturnReasonsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of return reasons.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.returnReasons.list()
.then(({ return_reasons }) => {
console.log(return_reasons.length);
});
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminReturnReasonsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of return reasons.","expandable":false,"children":[{"name":"AdminReturnReasonsListRes","type":"`AdminReturnReasonsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>

View File

@@ -1,115 +0,0 @@
---
slug: /references/js-client/AdminReturnsResource
---
import { TypeList } from "docs-ui"
# AdminReturnsResource
This class is used to send requests to [Admin Return API Routes](https://docs.medusajs.com/api/admin#returns). All its method
are available in the JS Client under the `medusa.admin.returns` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A return can be created by a customer or an admin to return items in an order.
Admins can manage these returns and change their state.
Related Guide: [How to manage returns](https://docs.medusajs.com/modules/orders/admin/manage-returns).
## Methods
### cancel
Register a return as canceled. The return can be associated with an order, claim, or swap.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.returns.cancel(returnId)
.then(({ order }) => {
console.log(order.id);
});
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The return's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancel"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminReturnsCancelRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the order associated with the return. If the return is associated with a claim or a swap, then it'll be the order\nthat the claim or swap belongs to.","expandable":false,"children":[{"name":"AdminReturnsCancelRes","type":"`AdminReturnsCancelRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="cancel"/>
### receive
Mark a return as received. This also updates the status of associated order, claim, or swap accordingly.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.returns.receive(returnId, {
items: [
{
item_id,
quantity: 1
}
]
})
.then((data) => {
console.log(data.return.id);
});
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The return's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostReturnsReturnReceiveReq`","description":"The received return.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="receive"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminReturnsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the return's details.","expandable":false,"children":[{"name":"AdminReturnsRes","type":"`AdminReturnsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="receive"/>
### list
Retrieve a list of Returns. The returns can be paginated.
#### Example
To list returns:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.returns.list()
.then(({ returns, limit, offset, count }) => {
console.log(returns.length)
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.returns.list({
limit,
offset
})
.then(({ returns, limit, offset, count }) => {
console.log(returns.length)
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetReturnsParams`","description":"Paignation configurations to be applied on the retrieved returns.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminReturnsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of returns with pagination fields.","expandable":false,"children":[{"name":"AdminReturnsListRes","type":"`AdminReturnsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>

View File

@@ -1,290 +0,0 @@
---
slug: /references/js-client/AdminSalesChannelsResource
---
import { TypeList } from "docs-ui"
# AdminSalesChannelsResource
This class is used to send requests to [Admin Sales Channel API Routes](https://docs.medusajs.com/api/admin#sales-channels). All its method
are available in the JS Client under the `medusa.admin.salesChannels` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A sales channel indicates a channel where products can be sold in. For example, a webshop or a mobile app.
Admins can manage sales channels and the products available in them.
Related Guide: [How to manage sales channels](https://docs.medusajs.com/modules/sales-channels/admin/manage).
## Methods
### retrieve
Retrieve a sales channel's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.salesChannels.retrieve(salesChannelId)
.then(({ sales_channel }) => {
console.log(sales_channel.id)
})
```
#### Parameters
<TypeList types={[{"name":"salesChannelId","type":"`string`","description":"The sales channel's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminSalesChannelsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the sales channel's details.","expandable":false,"children":[{"name":"AdminSalesChannelsRes","type":"`AdminSalesChannelsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### create
Create a sales channel.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.salesChannels.create({
name: "App",
description: "Mobile app"
})
.then(({ sales_channel }) => {
console.log(sales_channel.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostSalesChannelsReq`","description":"The sales channel to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminSalesChannelsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the sales channel's details.","expandable":false,"children":[{"name":"AdminSalesChannelsRes","type":"`AdminSalesChannelsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update a sales channel's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.salesChannels.update(salesChannelId, {
name: "App"
})
.then(({ sales_channel }) => {
console.log(sales_channel.id)
})
```
#### Parameters
<TypeList types={[{"name":"salesChannelId","type":"`string`","description":"The sales channel's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostSalesChannelsSalesChannelReq`","description":"The attributes to update in the sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminSalesChannelsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the sales channel's details.","expandable":false,"children":[{"name":"AdminSalesChannelsRes","type":"`AdminSalesChannelsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### list
Retrieve a list of sales channels. The sales channels can be filtered by fields such as `q` or `name` passed in the `query` parameter. The sales channels can also be sorted or paginated.
#### Example
To list sales channels:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.salesChannels.list()
.then(({ sales_channels, limit, offset, count }) => {
console.log(sales_channels.length)
})
```
To specify relations that should be retrieved within the sales channels:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.salesChannels.list({
expand: "locations"
})
.then(({ sales_channels, limit, offset, count }) => {
console.log(sales_channels.length)
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.salesChannels.list({
expand: "locations",
limit,
offset
})
.then(({ sales_channels, limit, offset, count }) => {
console.log(sales_channels.length)
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetSalesChannelsParams`","description":"Filters and pagination configurations applied on the retrieved sales channels.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminSalesChannelsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of sales channels with pagination fields.","expandable":false,"children":[{"name":"AdminSalesChannelsListRes","type":"`AdminSalesChannelsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### delete
Delete a sales channel. Associated products, stock locations, and other resources are not deleted.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.salesChannels.delete(salesChannelId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
#### Parameters
<TypeList types={[{"name":"salesChannelId","type":"`string`","description":"The sales channel's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### removeProducts
Remove a list of products from a sales channel. This doesn't delete the product. It only removes the association between the product and the sales channel.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.salesChannels.removeProducts(salesChannelId, {
product_ids: [
{
id: productId
}
]
})
.then(({ sales_channel }) => {
console.log(sales_channel.id)
})
```
#### Parameters
<TypeList types={[{"name":"salesChannelId","type":"`string`","description":"The sales channel's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminDeleteSalesChannelsChannelProductsBatchReq`","description":"The products to remove from the sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeProducts"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminSalesChannelsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the sales channel's details.","expandable":false,"children":[{"name":"AdminSalesChannelsRes","type":"`AdminSalesChannelsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeProducts"/>
### addProducts
Add a list of products to a sales channel.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.salesChannels.addProducts(salesChannelId, {
product_ids: [
{
id: productId
}
]
})
.then(({ sales_channel }) => {
console.log(sales_channel.id)
})
```
#### Parameters
<TypeList types={[{"name":"salesChannelId","type":"`string`","description":"The sales channel's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostSalesChannelsChannelProductsBatchReq`","description":"The products to add to the sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addProducts"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminSalesChannelsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the sales channel's details.","expandable":false,"children":[{"name":"AdminSalesChannelsRes","type":"`AdminSalesChannelsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addProducts"/>
### addLocation
Associate a stock location with a sales channel. It requires the
[@medusajs/stock-location](https://docs.medusajs.com/modules/multiwarehouse/install-modules#stock-location-module) module to be installed in
your Medusa backend.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.salesChannels.addLocation(salesChannelId, {
location_id: "loc_123"
})
.then(({ sales_channel }) => {
console.log(sales_channel.id)
})
```
#### Parameters
<TypeList types={[{"name":"salesChannelId","type":"`string`","description":"The sales channel's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostSalesChannelsChannelStockLocationsReq`","description":"The stock location to associate with the sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addLocation"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminSalesChannelsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the sales channel's details.","expandable":false,"children":[{"name":"AdminSalesChannelsRes","type":"`AdminSalesChannelsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addLocation"/>
### removeLocation
Remove a stock location from a sales channel. This only removes the association between the stock location and the sales channel. It does not delete the stock location.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.salesChannels.removeLocation(salesChannelId, {
location_id: "loc_id"
})
.then(({ sales_channel }) => {
console.log(sales_channel.id);
})
```
#### Parameters
<TypeList types={[{"name":"salesChannelId","type":"`string`","description":"The sales channel's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminDeleteSalesChannelsChannelStockLocationsReq`","description":"The stock location to remove from the sales channel.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeLocation"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminSalesChannelsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the sales channel's details.","expandable":false,"children":[{"name":"AdminSalesChannelsRes","type":"`AdminSalesChannelsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeLocation"/>

View File

@@ -1,155 +0,0 @@
---
slug: /references/js-client/AdminShippingOptionsResource
---
import { TypeList } from "docs-ui"
# AdminShippingOptionsResource
This class is used to send requests to [Admin Shipping Option API Routes](https://docs.medusajs.com/api/admin#shipping-options). All its method
are available in the JS Client under the `medusa.admin.shippingOptions` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A shipping option is used to define the available shipping methods during checkout or when creating a return.
Admins can create an unlimited number of shipping options, each associated with a shipping profile and fulfillment provider, among other resources.
Related Guide: [Shipping Option architecture](https://docs.medusajs.com/modules/carts-and-checkout/shipping#shipping-option).
## Methods
### create
Create a shipping option.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingOptions.create({
name: "PostFake",
region_id,
provider_id,
data: {
},
price_type: "flat_rate"
})
.then(({ shipping_option }) => {
console.log(shipping_option.id)
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostShippingOptionsReq`","description":"The shipping option to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminShippingOptionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the shipping option's details.","expandable":false,"children":[{"name":"AdminShippingOptionsRes","type":"`AdminShippingOptionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update a shipping option's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingOptions.update(optionId, {
name: "PostFake",
requirements: [
{
id,
type: "max_subtotal",
amount: 1000
}
]
})
.then(({ shipping_option }) => {
console.log(shipping_option.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The shipping option's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostShippingOptionsOptionReq`","description":"The attributes to update in the shipping option.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminShippingOptionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the shipping option's details.","expandable":false,"children":[{"name":"AdminShippingOptionsRes","type":"`AdminShippingOptionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete a shipping option. Once deleted, it can't be used when creating orders or returns.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingOptions.delete(optionId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The shipping option's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### retrieve
Retrieve a shipping option's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingOptions.retrieve(optionId)
.then(({ shipping_option }) => {
console.log(shipping_option.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The shipping option's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminShippingOptionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the shipping option's details.","expandable":false,"children":[{"name":"AdminShippingOptionsRes","type":"`AdminShippingOptionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of shipping options. The shipping options can be filtered by fields such as `region_id` or `is_return` passed in the `query` parameter.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingOptions.list()
.then(({ shipping_options, count }) => {
console.log(shipping_options.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetShippingOptionsParams`","description":"Filters to apply on the retrieved shipping options.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminShippingOptionsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of shipping options.","expandable":false,"children":[{"name":"AdminShippingOptionsListRes","type":"`AdminShippingOptionsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>

View File

@@ -1,145 +0,0 @@
---
slug: /references/js-client/AdminShippingProfilesResource
---
import { TypeList } from "docs-ui"
# AdminShippingProfilesResource
This class is used to send requests to [Admin Shipping Profile API Routes](https://docs.medusajs.com/api/admin#shipping-profiles). All its method
are available in the JS Client under the `medusa.admin.shippingProfiles` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A shipping profile is used to group products that can be shipped in the same manner.
They are created by the admin and they're not associated with a fulfillment provider.
Related Guide: [Shipping Profile architecture](https://docs.medusajs.com/modules/carts-and-checkout/shipping#shipping-profile).
## Methods
### create
Create a shipping profile.
#### Example
```ts
import { ShippingProfileType } from "@medusajs/medusa"
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingProfiles.create({
name: "Large Products",
type: ShippingProfileType.DEFAULT
})
.then(({ shipping_profile }) => {
console.log(shipping_profile.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostShippingProfilesReq`","description":"The shipping profile to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminShippingProfilesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the shipping profile's details.","expandable":false,"children":[{"name":"AdminShippingProfilesRes","type":"`AdminShippingProfilesRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update a shipping profile's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingProfiles.update(shippingProfileId, {
name: 'Large Products'
})
.then(({ shipping_profile }) => {
console.log(shipping_profile.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The shipping profile's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostShippingProfilesProfileReq`","description":"The attributes to update in the shipping profile.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminShippingProfilesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the shipping profile's details.","expandable":false,"children":[{"name":"AdminShippingProfilesRes","type":"`AdminShippingProfilesRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete a shipping profile. Associated shipping options are deleted as well.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingProfiles.delete(profileId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The shipping profile's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### retrieve
Retrieve a shipping profile's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingProfiles.retrieve(profileId)
.then(({ shipping_profile }) => {
console.log(shipping_profile.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The shipping profile's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminShippingProfilesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the shipping profile's details.","expandable":false,"children":[{"name":"AdminShippingProfilesRes","type":"`AdminShippingProfilesRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of shipping profiles.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingProfiles.list()
.then(({ shipping_profiles }) => {
console.log(shipping_profiles.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminShippingProfilesListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of shipping profiles.","expandable":false,"children":[{"name":"AdminShippingProfilesListRes","type":"`AdminShippingProfilesListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>

View File

@@ -1,177 +0,0 @@
---
slug: /references/js-client/AdminStockLocationsResource
---
import { TypeList } from "docs-ui"
# AdminStockLocationsResource
This class is used to send requests to [Admin Stock Location API Routes](https://docs.medusajs.com/api/admin#stock-locations). To use these API Routes, make sure to install the
[@medusajs/stock-location](https://docs.medusajs.com/modules/multiwarehouse/install-modules#stock-location-module) module in your Medusa backend.
All methods in this class require [authentication](../../../modules/user/page.mdx). The methods
are available in the JS Client under the `medusa.admin.stockLocations` property.
A stock location, provided by the [Stock Location module](https://docs.medusajs.com/modules/multiwarehouse/stock-location-module), indicates a physical address that stock-kept items, such as physical products, can be stored in.
An admin can create and manage available stock locations.
Related Guide: [How to manage stock locations](https://docs.medusajs.com/modules/multiwarehouse/admin/manage-stock-locations).
## Methods
### create
Create a stock location.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.stockLocations.create({
name: "Main Warehouse",
})
.then(({ stock_location }) => {
console.log(stock_location.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostStockLocationsReq`","description":"The stock location to be created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminStockLocationsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the stock location's details.","expandable":false,"children":[{"name":"AdminStockLocationsRes","type":"`AdminStockLocationsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### retrieve
Retrieve a stock location's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.stockLocations.retrieve(stockLocationId)
.then(({ stock_location }) => {
console.log(stock_location.id);
})
```
#### Parameters
<TypeList types={[{"name":"itemId","type":"`string`","description":"The stock location's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminStockLocationsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the stock location's details.","expandable":false,"children":[{"name":"AdminStockLocationsRes","type":"`AdminStockLocationsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### update
Update a stock location's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.stockLocations.update(stockLocationId, {
name: 'Main Warehouse'
})
.then(({ stock_location }) => {
console.log(stock_location.id);
})
```
#### Parameters
<TypeList types={[{"name":"stockLocationId","type":"`string`","description":"The stock location's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostStockLocationsLocationReq`","description":"The attributes to be updated in the stock location.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminStockLocationsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the stock location's details.","expandable":false,"children":[{"name":"AdminStockLocationsRes","type":"`AdminStockLocationsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete a stock location.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.stockLocations.delete(stockLocationId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The stock location's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminStockLocationsDeleteRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"AdminStockLocationsDeleteRes","type":"`AdminStockLocationsDeleteRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### list
Retrieve a list of stock locations. The stock locations can be filtered by fields such as `name` or `created_at` passed in the `query` parameter.
The stock locations can also be sorted or paginated.
#### Example
To list stock locations:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.stockLocations.list()
.then(({ stock_locations, limit, offset, count }) => {
console.log(stock_locations.length);
})
```
To specify relations that should be retrieved within the stock locations:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.stockLocations.list({
expand: "address"
})
.then(({ stock_locations, limit, offset, count }) => {
console.log(stock_locations.length);
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.stockLocations.list({
expand: "address",
limit,
offset
})
.then(({ stock_locations, limit, offset, count }) => {
console.log(stock_locations.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetStockLocationsParams`","description":"Filters and pagination configurations to apply on the retrieved stock locations.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminStockLocationsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of stock locations with pagination fields.","expandable":false,"children":[{"name":"AdminStockLocationsListRes","type":"`AdminStockLocationsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>

View File

@@ -1,164 +0,0 @@
---
slug: /references/js-client/AdminStoresResource
---
import { TypeList } from "docs-ui"
# AdminStoresResource
This class is used to send requests to [Admin Store API Routes](https://docs.medusajs.com/api/admin#store). All its method
are available in the JS Client under the `medusa.admin.store` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A store indicates the general configurations and details about the commerce store. By default, there's only one store in the Medusa backend.
Admins can manage the store and its details or configurations.
## Methods
### update
Update the store's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.store.update({
name: "Medusa Store"
})
.then(({ store }) => {
console.log(store.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostStoreReq`","description":"The attributes to update in the store.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminStoresRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the store's details.","expandable":false,"children":[{"name":"AdminStoresRes","type":"`AdminStoresRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### addCurrency
Add a currency code to the available currencies in a store. This doesn't create new currencies, as currencies are defined within the Medusa backend.
To create a currency, you can [create a migration](https://docs.medusajs.com/development/entities/migrations/create) that inserts the currency into the database.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.store.addCurrency("eur")
.then(({ store }) => {
console.log(store.currencies);
})
```
#### Parameters
<TypeList types={[{"name":"currency_code","type":"`string`","description":"The code of the currency to add to the store.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addCurrency"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminStoresRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the store's details.","expandable":false,"children":[{"name":"AdminStoresRes","type":"`AdminStoresRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addCurrency"/>
### deleteCurrency
Delete a currency code from the available currencies in a store. This doesn't completely delete the currency and it can be added again later to the store.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.store.deleteCurrency("eur")
.then(({ store }) => {
console.log(store.currencies);
})
```
#### Parameters
<TypeList types={[{"name":"currency_code","type":"`string`","description":"The code of the currency to delete from the store.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteCurrency"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminStoresRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the store's details.","expandable":false,"children":[{"name":"AdminStoresRes","type":"`AdminStoresRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteCurrency"/>
### retrieve
Retrieve the store's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.store.retrieve()
.then(({ store }) => {
console.log(store.id);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminExtendedStoresRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the store's details.","expandable":false,"children":[{"name":"AdminExtendedStoresRes","type":"`AdminExtendedStoresRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### listPaymentProviders
Retrieve a list of available payment providers in a store.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.store.listPaymentProviders()
.then(({ payment_providers }) => {
console.log(payment_providers.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listPaymentProviders"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminPaymentProvidersList&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of payment providers.","expandable":false,"children":[{"name":"AdminPaymentProvidersList","type":"`AdminPaymentProvidersList`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listPaymentProviders"/>
### listTaxProviders
Retrieve a list of available tax providers in a store.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.store.listTaxProviders()
.then(({ tax_providers }) => {
console.log(tax_providers.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listTaxProviders"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminTaxProvidersList&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of tax providers.","expandable":false,"children":[{"name":"AdminTaxProvidersList","type":"`AdminTaxProvidersList`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listTaxProviders"/>

View File

@@ -1,84 +0,0 @@
---
slug: /references/js-client/AdminSwapsResource
---
import { TypeList } from "docs-ui"
# AdminSwapsResource
This class is used to send requests to [Admin Swap API Routes](https://docs.medusajs.com/api/admin#swaps). All its method
are available in the JS Client under the `medusa.admin.swaps` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A swap is created by a customer or an admin to exchange an item with a new one.
Creating a swap implicitely includes creating a return for the item being exchanged.
Related Guide: [How to manage swaps](https://docs.medusajs.com/modules/orders/admin/manage-swaps)
## Methods
### retrieve
Retrieve a swap's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.swaps.retrieve(swapId)
.then(({ swap }) => {
console.log(swap.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The swap's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminSwapsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the swap's details.","expandable":false,"children":[{"name":"AdminSwapsRes","type":"`AdminSwapsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of swaps. The swaps can be paginated.
#### Example
To list swaps:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.swaps.list()
.then(({ swaps }) => {
console.log(swaps.length);
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.swaps.list({
limit,
offset
})
.then(({ swaps }) => {
console.log(swaps.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetSwapsParams`","description":"Pagination configurations to apply on the retrieved swaps.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminSwapsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of swaps with pagination fields.","expandable":false,"children":[{"name":"AdminSwapsListRes","type":"`AdminSwapsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>

View File

@@ -1,360 +0,0 @@
---
slug: /references/js-client/AdminTaxRatesResource
---
import { TypeList } from "docs-ui"
# AdminTaxRatesResource
This class is used to send requests to [Admin Tax Rate API Routes](https://docs.medusajs.com/api/admin#tax-rates). All its method
are available in the JS Client under the `medusa.admin.taxRates` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Each region has at least a default tax rate. Admins can create and manage additional tax rates that can be applied for certain conditions, such as for specific product types.
Related Guide: [How to manage tax rates](https://docs.medusajs.com/modules/taxes/admin/manage-tax-rates).
## Methods
### retrieve
Retrieve a tax rate's details.
#### Example
A simple example that retrieves a tax rate by its ID:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.retrieve(taxRateId)
.then(({ tax_rate }) => {
console.log(tax_rate.id);
})
```
To specify relations that should be retrieved:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.retrieve(taxRateId, {
expand: "shipping_options"
})
.then(({ tax_rate }) => {
console.log(tax_rate.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The tax rate's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetTaxRatesTaxRateParams`","description":"Configurations to apply on retrieved tax rates.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminTaxRatesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the tax rate's details.","expandable":false,"children":[{"name":"AdminTaxRatesRes","type":"`AdminTaxRatesRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of tax rates. The tax rates can be filtered by fields such as `name` or `rate` passed in the `query` parameter. The tax rates can also be paginated.
#### Example
To list tax rates:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.list()
.then(({ tax_rates, limit, offset, count }) => {
console.log(tax_rates.length);
})
```
To specify relations that should be retrieved within the tax rates:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.list({
expand: ["shipping_options"]
})
.then(({ tax_rates, limit, offset, count }) => {
console.log(tax_rates.length);
})
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.list({
expand: ["shipping_options"],
limit,
offset
})
.then(({ tax_rates, limit, offset, count }) => {
console.log(tax_rates.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetTaxRatesParams`","description":"Filters and pagination configurations applied to the retrieved tax rates.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminTaxRatesListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of tax rates with pagination fields.","expandable":false,"children":[{"name":"AdminTaxRatesListRes","type":"`AdminTaxRatesListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### create
Create a tax rate.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.create({
code: "TEST",
name: "New Tax Rate",
region_id
})
.then(({ tax_rate }) => {
console.log(tax_rate.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostTaxRatesReq`","description":"The tax rate to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminPostTaxRatesParams`","description":"Configurations to apply on the retrieved tax rate.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminTaxRatesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the tax rate's details.","expandable":false,"children":[{"name":"AdminTaxRatesRes","type":"`AdminTaxRatesRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update a tax rate's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.update(taxRateId, {
name: "New Tax Rate"
})
.then(({ tax_rate }) => {
console.log(tax_rate.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The tax rate's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostTaxRatesTaxRateReq`","description":"The attributes to update in the tax rate.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminPostTaxRatesTaxRateParams`","description":"Configurations to apply on the retrieved tax rate.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminTaxRatesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the tax rate's details.","expandable":false,"children":[{"name":"AdminTaxRatesRes","type":"`AdminTaxRatesRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### addProducts
Add products to a tax rate.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.addProducts(taxRateId, {
products: [
productId
]
})
.then(({ tax_rate }) => {
console.log(tax_rate.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The tax rate's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostTaxRatesTaxRateProductsReq`","description":"The products to add to the tax rate.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminPostTaxRatesTaxRateProductsParams`","description":"Configurations to apply on the retrieved tax rate.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addProducts"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminTaxRatesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the tax rate's details.","expandable":false,"children":[{"name":"AdminTaxRatesRes","type":"`AdminTaxRatesRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addProducts"/>
### addProductTypes
Add product types to a tax rate.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.addProductTypes(taxRateId, {
product_types: [
productTypeId
]
})
.then(({ tax_rate }) => {
console.log(tax_rate.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The tax rate's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostTaxRatesTaxRateProductTypesReq`","description":"The product types to add to the tax rate.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetTaxRatesTaxRateParams`","description":"Configurations to apply on the retrieved tax rate.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addProductTypes"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminTaxRatesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the tax rate's details.","expandable":false,"children":[{"name":"AdminTaxRatesRes","type":"`AdminTaxRatesRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addProductTypes"/>
### addShippingOptions
Add shipping options to a tax rate.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.addShippingOptions(taxRateId, {
shipping_options: [
shippingOptionId
]
})
.then(({ tax_rate }) => {
console.log(tax_rate.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The tax rate's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminPostTaxRatesTaxRateShippingOptionsReq`","description":"The shipping options to add to the tax rate.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminPostTaxRatesTaxRateShippingOptionsParams`","description":"Configurations to apply on the retrieved tax rate.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addShippingOptions"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminTaxRatesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the tax rate's details.","expandable":false,"children":[{"name":"AdminTaxRatesRes","type":"`AdminTaxRatesRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addShippingOptions"/>
### removeProducts
Remove products from a tax rate. This only removes the association between the products and the tax rate. It does not delete the products.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.removeProducts(taxRateId, {
products: [
productId
]
})
.then(({ tax_rate }) => {
console.log(tax_rate.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The tax rate's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminDeleteTaxRatesTaxRateProductsReq`","description":"The products to remove from the tax rate.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminDeleteTaxRatesTaxRateProductsParams`","description":"Configurations to apply on the retrieved tax rate.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeProducts"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminTaxRatesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the tax rate's details.","expandable":false,"children":[{"name":"AdminTaxRatesRes","type":"`AdminTaxRatesRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeProducts"/>
### removeProductTypes
Remove product types from a tax rate. This only removes the association between the product types and the tax rate. It does not delete the product types.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.removeProductTypes(taxRateId, {
product_types: [
productTypeId
]
})
.then(({ tax_rate }) => {
console.log(tax_rate.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The tax rate's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminDeleteTaxRatesTaxRateProductTypesReq`","description":"The product types to remove from the tax rate.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminDeleteTaxRatesTaxRateProductTypesParams`","description":"Configurations to apply on the retrieved tax rate.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeProductTypes"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminTaxRatesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the tax rate's details.","expandable":false,"children":[{"name":"AdminTaxRatesRes","type":"`AdminTaxRatesRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeProductTypes"/>
### removeShippingOptions
Remove shipping options from a tax rate. This only removes the association between the shipping options and the tax rate. It does not delete the shipping options.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.removeShippingOptions(taxRateId, {
shipping_options: [
shippingOptionId
]
})
.then(({ tax_rate }) => {
console.log(tax_rate.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The tax rate's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminDeleteTaxRatesTaxRateShippingOptionsReq`","description":"The shipping options to remove from the tax rate.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminDeleteTaxRatesTaxRateShippingOptionsParams`","description":"Configurations to apply on the retrieved tax rate.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeShippingOptions"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminTaxRatesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the tax rate's details.","expandable":false,"children":[{"name":"AdminTaxRatesRes","type":"`AdminTaxRatesRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="removeShippingOptions"/>
### delete
Delete a tax rate. Resources associated with the tax rate, such as products or product types, are not deleted.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.delete(taxRateId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The tax rate's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>

View File

@@ -1,128 +0,0 @@
---
slug: /references/js-client/AdminUploadsResource
---
import { TypeList } from "docs-ui"
# AdminUploadsResource
This class is used to send requests to [Admin Upload API Routes](https://docs.medusajs.com/api/admin#uploads). All its method
are available in the JS Client under the `medusa.admin.uploads` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
The methods in this class are used to upload any type of resources. For example, they can be used to upload CSV files that are used to import products into the store.
Related Guide: [How to upload CSV file when importing a product](https://docs.medusajs.com/modules/products/admin/import-products#1-upload-csv-file).
## Methods
### create
Upload a file or multiple files to a public bucket or storage. The file upload is handled by the file service installed on the Medusa backend.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.uploads.create(file)
.then(({ uploads }) => {
console.log(uploads.length);
})
```
#### Parameters
<TypeList types={[{"name":"file","type":"`AdminCreateUploadPayload`","description":"The file(s) to upload.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminUploadsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the uploaded file details.","expandable":false,"children":[{"name":"AdminUploadsRes","type":"`AdminUploadsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### createProtected
Upload a file to an ACL or a non-public bucket. The file upload is handled by the file service installed on the Medusa backend.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.uploads.createProtected(file)
.then(({ uploads }) => {
console.log(uploads.length);
})
```
#### Parameters
<TypeList types={[{"name":"file","type":"`AdminCreateUploadPayload`","description":"The file to upload.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createProtected"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminUploadsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the uploaded file details.","expandable":false,"children":[{"name":"AdminUploadsRes","type":"`AdminUploadsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createProtected"/>
### delete
Delete an uploaded file from storage. The file is deleted using the installed file service on the Medusa backend.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.uploads.delete({
file_key
})
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminDeleteUploadsReq`","description":"The uploaded file to delete.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### getPresignedDownloadUrl
Create and retrieve a presigned or public download URL for a file. The URL creation is handled by the file service installed on the Medusa backend.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.uploads.getPresignedDownloadUrl({
file_key
})
.then(({ download_url }) => {
console.log(download_url);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminPostUploadsDownloadUrlReq`","description":"The uploaded file to get a presigned download URL for.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getPresignedDownloadUrl"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminUploadsDownloadUrlRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the download URL details.","expandable":false,"children":[{"name":"AdminUploadsDownloadUrlRes","type":"`AdminUploadsDownloadUrlRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getPresignedDownloadUrl"/>
### \_createPayload
#### Parameters
<TypeList types={[{"name":"file","type":"`AdminCreateUploadPayload`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="_createPayload"/>
#### Returns
<TypeList types={[{"name":"FormData","type":"`FormData`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="_createPayload"/>

View File

@@ -1,219 +0,0 @@
---
slug: /references/js-client/AdminUsersResource
---
import { TypeList } from "docs-ui"
# AdminUsersResource
This class is used to send requests to [Admin User API Routes](https://docs.medusajs.com/api/admin#users). All its method
are available in the JS Client under the `medusa.admin.users` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
A store can have more than one user, each having the same privileges. Admins can manage users, their passwords, and more.
Related Guide: [How to manage users](https://docs.medusajs.com/modules/users/admin/manage-users).
## Methods
### sendResetPasswordToken
Generate a password token for an admin user with a given email. This also triggers the `user.password_reset` event. So, if you have a Notification Service installed
that can handle this event, a notification, such as an email, will be sent to the user. The token is triggered as part of the `user.password_reset` event's payload.
That token must be used later to reset the password using the [resetPassword](page.mdx#resetpassword) method.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.users.sendResetPasswordToken({
email: "user@example.com"
})
.then(() => {
// successful
})
.catch(() => {
// error occurred
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminResetPasswordTokenRequest`","description":"The user's reset details.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="sendResetPasswordToken"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;void&#62;","optional":false,"defaultValue":"","description":"Resolves when the token is generated successfully.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="sendResetPasswordToken"/>
### resetPassword
Reset the password of an admin user using their reset password token. You must generate a reset password token first for the user using the [sendResetPasswordToken](page.mdx#sendresetpasswordtoken) method,
then use that token to reset the password in this method.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.users.resetPassword({
token: "supersecrettoken",
password: "supersecret"
})
.then(({ user }) => {
console.log(user.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminResetPasswordRequest`","description":"The reset details.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="resetPassword"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminUserRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the user's details.","expandable":false,"children":[{"name":"AdminUserRes","type":"`AdminUserRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="resetPassword"/>
### retrieve
Retrieve an admin user's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.users.retrieve(userId)
.then(({ user }) => {
console.log(user.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The user's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminUserRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the user's details.","expandable":false,"children":[{"name":"AdminUserRes","type":"`AdminUserRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### create
Create an admin user. The user has the same privileges as all admin users, and will be able to authenticate and perform admin functionalities right after creation.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.users.create({
email: "user@example.com",
password: "supersecret"
})
.then(({ user }) => {
console.log(user.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`AdminCreateUserPayload`","description":"The user to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminUserRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the user's details.","expandable":false,"children":[{"name":"AdminUserRes","type":"`AdminUserRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update an admin user's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.users.update(userId, {
first_name: "Marcellus"
})
.then(({ user }) => {
console.log(user.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The user's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`AdminUpdateUserPayload`","description":"The attributes to update in the user.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminUserRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the user's details.","expandable":false,"children":[{"name":"AdminUserRes","type":"`AdminUserRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete a user. Once deleted, the user will not be able to authenticate or perform admin functionalities.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.users.delete(userId)
.then(({ id, object, deleted }) => {
console.log(id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The user's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;DeleteResponse&#62;","optional":false,"defaultValue":"","description":"Resolves to the deletion operation's details.","expandable":false,"children":[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
### list
Retrieve all admin users.
#### Example
To list users:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.users.list()
.then(({ users }) => {
console.log(users.length);
})
```
By default, only the first `20` users are returned. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.users.list({
limit,
offset
})
.then(({ users, limit, offset, count }) => {
console.log(users.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetUsersParams`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminUsersListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of users.","expandable":false,"children":[{"name":"AdminUsersListRes","type":"`AdminUsersListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>

View File

@@ -1,139 +0,0 @@
---
slug: /references/js-client/AdminVariantsResource
---
import { TypeList } from "docs-ui"
# AdminVariantsResource
This class is used to send requests to [Admin Product Variant API Routes](https://docs.medusajs.com/api/admin#product-variants). All its method
are available in the JS Client under the `medusa.admin.variants` property.
All methods in this class require [authentication](../../../modules/user/page.mdx).
Product variants are the actual salable item in your store. Each variant is a combination of the different option values available on the product.
Product variants can be managed through [AdminProductsResource](../js_client.AdminProductsResource/page.mdx).
Related Guide: [How to manage product variants](https://docs.medusajs.com/modules/products/admin/manage-products#manage-product-variants).
## Methods
### list
Retrieve a list of product variants. The product variant can be filtered by fields such as `id` or `title` passed in the `query` parameter. The product variant can also be paginated.
#### Example
To list product variants:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.variants.list()
.then(({ variants, limit, offset, count }) => {
console.log(variants.length);
})
```
To specify relations that should be retrieved within the product variants:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.variants.list({
expand: "options"
})
.then(({ variants, limit, offset, count }) => {
console.log(variants.length);
})
```
By default, only the first `100` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.variants.list({
expand: "options",
limit,
offset
})
.then(({ variants, limit, offset, count }) => {
console.log(variants.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetVariantsParams`","description":"Filters and pagination configurations to apply on the retrieved product variants.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminVariantsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of product variants with pagination fields.","expandable":false,"children":[{"name":"AdminVariantsListRes","type":"`AdminVariantsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### retrieve
Retrieve a product variant's details.
#### Example
A simple example that retrieves a product variant by its ID:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.variants.retrieve(variantId)
.then(({ variant }) => {
console.log(variant.id);
})
```
To specify relations that should be retrieved:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.variants.retrieve(variantId, {
expand: "options"
})
.then(({ variant }) => {
console.log(variant.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The product variant's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`AdminGetVariantParams`","description":"Configurations to apply on the retrieved product variant.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminVariantsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product variant's details.","expandable":false,"children":[{"name":"AdminVariantsRes","type":"`AdminVariantsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### getInventory
Retrieve the available inventory of a product variant.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.variants.getInventory(variantId)
.then(({ variant }) => {
console.log(variant.inventory, variant.sales_channel_availability)
})
```
#### Parameters
<TypeList types={[{"name":"variantId","type":"`string`","description":"The product variant's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getInventory"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;AdminGetVariantsVariantInventoryRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the inventory details of the product variant.","expandable":false,"children":[{"name":"AdminGetVariantsVariantInventoryRes","type":"`AdminGetVariantsVariantInventoryRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getInventory"/>

View File

@@ -1,139 +0,0 @@
---
slug: /references/js-client/AuthResource
---
import { TypeList } from "docs-ui"
# AuthResource
This class is used to send requests to [Store Auth API Routes](https://docs.medusajs.com/api/store#auth). All its method
are available in the JS Client under the `medusa.auth` property.
The methods in this class allows you to manage a customer's session, such as login or log out.
You can send authenticated requests for a customer either using the Cookie header or using the JWT Token.
When you log the customer in using the [authenticate](page.mdx#authenticate) method, the JS client will automatically attach the
cookie header in all subsequent requests.
Related Guide: [How to implement customer profiles in your storefront](https://docs.medusajs.com/modules/customers/storefront/implement-customer-profiles).
## Methods
### authenticate
Authenticate a customer using their email and password. If the customer is authenticated successfully, the cookie is automatically attached to subsequent requests sent with the JS Client.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.auth.authenticate({
email: "user@example.com",
password: "user@example.com"
})
.then(({ customer }) => {
console.log(customer.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`StorePostAuthReq`","description":"The credentials of the customer to authenticate.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="authenticate"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreAuthRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer's details.","expandable":false,"children":[{"name":"StoreAuthRes","type":"`StoreAuthRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="authenticate"/>
### deleteSession
Log out the customer and remove their authentication session. This method requires [authentication](../../../modules/customer/page.mdx).
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.auth.deleteSession()
.then(() => {
// customer logged out successfully
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteSession"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;void&#62;","optional":false,"defaultValue":"","description":"Resolves when customer is logged out successfully.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteSession"/>
### getSession
Retrieve the details of the logged-in customer. Can also be used to check if there is an authenticated customer.
This method requires [authentication](../../../modules/customer/page.mdx).
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged
medusa.auth.getSession()
.then(({ customer }) => {
console.log(customer.id);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getSession"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreAuthRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer's details.","expandable":false,"children":[{"name":"StoreAuthRes","type":"`StoreAuthRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getSession"/>
### exists
Check if the email is already used by another registered customer. Can be used to validate a new customer's email.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.auth.exists("user@example.com")
```
#### Parameters
<TypeList types={[{"name":"email","type":"`string`","description":"The email to check.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="exists"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreGetAuthEmailRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the result of the check.","expandable":false,"children":[{"name":"StoreGetAuthEmailRes","type":"`StoreGetAuthEmailRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="exists"/>
### getToken
Authenticate the customer and retrieve a JWT token to use for subsequent authenticated requests.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.auth.getToken({
email: 'user@example.com',
password: 'supersecret'
})
.then(({ access_token }) => {
console.log(access_token);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`StorePostAuthReq`","description":"The credentials of the customer to authenticate.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getToken"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreBearerAuthRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the access token of the customer, if they're authenticated successfully.","expandable":false,"children":[{"name":"StoreBearerAuthRes","type":"`StoreBearerAuthRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="getToken"/>

View File

@@ -1,296 +0,0 @@
---
slug: /references/js-client/CartsResource
---
import { TypeList } from "docs-ui"
# CartsResource
This class is used to send requests to [Store Cart API Routes](https://docs.medusajs.com/api/store#carts). All its method
are available in the JS Client under the `medusa.carts` property.
A cart is a virtual shopping bag that customers can use to add items they want to purchase.
A cart is then used to checkout and place an order.
Related Guide: [How to implement cart functionality in your storefront](https://docs.medusajs.com/modules/carts-and-checkout/storefront/implement-cart).
## Properties
<TypeList types={[{"name":"lineItems","type":"[LineItemsResource](../js_client.LineItemsResource/page.mdx)","description":"An instance of [LineItemsResource](../js_client.LineItemsResource/page.mdx) used to send requests to line-item-related routes part of the [Store Cart API Routes](https://docs.medusajs.com/api/store#carts).","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="CartsResource"/>
___
## Methods
### addShippingMethod
Add a shipping method to the cart. The validation of the `data` field is handled by the fulfillment provider of the chosen shipping option.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.addShippingMethod(cartId, {
option_id
})
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The ID of the cart to add the shipping method to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`StorePostCartsCartShippingMethodReq`","description":"The shipping method to add.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addShippingMethod"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"`StoreCartsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="addShippingMethod"/>
### complete
Complete a cart and place an order or create a swap, based on the cart's type. This includes attempting to authorize the cart's payment.
If authorizing the payment requires more action, the cart will not be completed and the order will not be placed or the swap will not be created.
An idempotency key will be generated if none is provided in the header `Idempotency-Key` and added to
the response. If an error occurs during cart completion or the request is interrupted for any reason, the cart completion can be retried by passing the idempotency
key in the `Idempotency-Key` header.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.complete(cartId)
.then(({ data, type }) => {
console.log(data.id, type);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The ID of the cart to complete.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="complete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCompleteCartRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the completion details.","expandable":false,"children":[{"name":"StoreCompleteCartRes","type":"`StoreCompleteCartRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="complete"/>
### create
Create a Cart. Although optional, specifying the cart's region and sales channel can affect the cart's pricing and
the products that can be added to the cart respectively. So, make sure to set those early on and change them if necessary, such as when the customer changes their region.
If a customer is logged in, make sure to pass its ID or email within the cart's details so that the cart is attached to the customer.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.create()
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"payload","type":"`StorePostCartReq`","description":"The cart to create.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the created cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"`StoreCartsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### createPaymentSessions
Create Payment Sessions for each of the available Payment Providers in the Cart's Region. If there's only one payment session created,
it will be selected by default. The creation of the payment session uses the payment provider and may require sending requests to third-party services.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.createPaymentSessions(cartId)
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The ID of the cart to create the payment sessions for.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createPaymentSessions"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"`StoreCartsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="createPaymentSessions"/>
### deleteDiscount
Remove a Discount from a Cart. This only removes the application of the discount, and not completely deletes it. The totals will be re-calculated and the payment sessions
will be refreshed after the removal.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.deleteDiscount(cartId, code)
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"the ID of the cart to remove the discount from.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"code","type":"`string`","description":"The code of the discount to remove from the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteDiscount"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"`StoreCartsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deleteDiscount"/>
### deletePaymentSession
Delete a Payment Session in a Cart. May be useful if a payment has failed. The totals will be recalculated.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.deletePaymentSession(cartId, "manual")
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The ID of the cart to delete the payment session from.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The ID of the payment provider that the session is associated with.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deletePaymentSession"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"`StoreCartsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="deletePaymentSession"/>
### refreshPaymentSession
Refresh a Payment Session to ensure that it is in sync with the Cart. This is usually not necessary, but is provided for edge cases.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.refreshPaymentSession(cartId, "manual")
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The ID of the cart to refresh its payment session.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The ID of the payment provider that's associated with the payment session.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="refreshPaymentSession"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"`StoreCartsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="refreshPaymentSession"/>
### retrieve
Retrieve a Cart's details. This includes recalculating its totals.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.retrieve(cartId)
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"`StoreCartsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### setPaymentSession
Select the Payment Session that will be used to complete the cart. This is typically used when the customer chooses their preferred payment method during checkout.
The totals of the cart will be recalculated.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.setPaymentSession(cartId, {
provider_id: "manual"
})
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`StorePostCartsCartPaymentSessionReq`","description":"The associated payment provider.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="setPaymentSession"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"`StoreCartsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="setPaymentSession"/>
### update
Update a Cart's details. If the cart has payment sessions and the region was not changed, the payment sessions are updated. The cart's totals are also recalculated.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.update(cartId, {
email: "user@example.com"
})
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`StorePostCartsCartReq`","description":"The attributes to update in the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"`StoreCartsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### updatePaymentSession
Update a Payment Session with additional data. This can be useful depending on the payment provider used.
All payment sessions are updated and cart totals are recalculated afterwards.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.updatePaymentSession(cartId, "manual", {
data: {
}
})
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"provider_id","type":"`string`","description":"The ID of the payment provider that the payment session is associated with.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`StorePostCartsCartPaymentSessionUpdateReq`","description":"The attributes to update in the payment session.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updatePaymentSession"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"`StoreCartsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="updatePaymentSession"/>

View File

@@ -1,78 +0,0 @@
---
slug: /references/js-client/CollectionsResource
---
import { TypeList } from "docs-ui"
# CollectionsResource
This class is used to send requests to [Store Product Collection API Routes](https://docs.medusajs.com/api/store#product-collections). All its method
are available in the JS Client under the `medusa.collections` property.
A product collection is used to organize products for different purposes such as marketing or discount purposes. For example, you can create a Summer Collection.
Using the methods in this class, you can list or retrieve a collection's details and products.
## Methods
### retrieve
Retrieve a product collection's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.collections.retrieve(collectionId)
.then(({ collection }) => {
console.log(collection.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the collection's details.","expandable":false,"children":[{"name":"StoreCollectionsRes","type":"`StoreCollectionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of product collections. The product collections can be filtered by fields such as `handle` or `created_at` passed in the `query` parameter.
The product collections can also be paginated.
#### Example
To list product collections:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.collections.list()
.then(({ collections, limit, offset, count }) => {
console.log(collections.length);
})
```
By default, only the first `10` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.collections.list({
limit,
offset
})
.then(({ collections, limit, offset, count }) => {
console.log(collections.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`StoreGetCollectionsParams`","description":"Filters and pagination configurations to apply on the retrieved product collections.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCollectionsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of product collections with pagination fields.","expandable":false,"children":[{"name":"StoreCollectionsListRes","type":"`StoreCollectionsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>

View File

@@ -1,183 +0,0 @@
---
slug: /references/js-client/CustomersResource
---
import { TypeList } from "docs-ui"
# CustomersResource
This class is used to send requests to [Store Customer API Routes](https://docs.medusajs.com/api/store#customers\_postcustomers). All its method
are available in the JS Client under the `medusa.customers` property.
A customer can register and manage their information such as addresses, orders, payment methods, and more.
Related Guide: [How to implement customer profiles in your storefront](https://docs.medusajs.com/modules/customers/storefront/implement-customer-profiles).
## Properties
<TypeList types={[{"name":"paymentMethods","type":"[PaymentMethodsResource](../js_client.PaymentMethodsResource/page.mdx)","description":"An instance of [PaymentMethodsResource](../js_client.PaymentMethodsResource/page.mdx) used to send requests to payment-related routes part of the [Store Customer API Routes](https://docs.medusajs.com/api/store#customers\\_postcustomers).","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"addresses","type":"[AddressesResource](../js_client.AddressesResource/page.mdx)","description":"An instance of [AddressesResource](../js_client.AddressesResource/page.mdx) used to send requests to address-related routes part of the [Store Customer API Routes](https://docs.medusajs.com/api/store#customers\\_postcustomers).","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="CustomersResource"/>
___
## Methods
### create
Register a new customer. This will also automatically authenticate the customer and set their login session in the response Cookie header.
Subsequent requests sent with the JS client are sent with the Cookie session automatically.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.customers.create({
first_name: "Alec",
last_name: "Reynolds",
email: "user@example.com",
password: "supersecret"
})
.then(({ customer }) => {
console.log(customer.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`StorePostCustomersReq`","description":"The details of the customer to be created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCustomersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the created customer's details.","expandable":false,"children":[{"name":"StoreCustomersRes","type":"`StoreCustomersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### retrieve
Retrieve the logged-in customer's details. This method requires [authentication](../../../modules/customer/page.mdx).
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged
medusa.customers.retrieve()
.then(({ customer }) => {
console.log(customer.id);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCustomersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the logged-in customer's details.","expandable":false,"children":[{"name":"StoreCustomersRes","type":"`StoreCustomersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### update
Update the logged-in customer's details. This method requires [authentication](../../../modules/customer/page.mdx).
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged
medusa.customers.update({
first_name: "Laury"
})
.then(({ customer }) => {
console.log(customer.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`StorePostCustomersCustomerReq`","description":"The attributes to update in the logged-in customer.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCustomersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the logged-in customer's details.","expandable":false,"children":[{"name":"StoreCustomersRes","type":"`StoreCustomersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### listOrders
Retrieve a list of the logged-in customer's orders. The orders can be filtered by fields such as `status` or `fulfillment_status`. The orders can also be paginated.
This method requires [authentication](../../../modules/customer/page.mdx).
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged
medusa.customers.listOrders()
.then(({ orders, limit, offset, count }) => {
console.log(orders);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"params","type":"`StoreGetCustomersCustomerOrdersParams`","description":"Filters and pagination configurations to apply on the retrieved orders.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listOrders"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCustomersListOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of orders with pagination fields.","expandable":false,"children":[{"name":"StoreCustomersListOrdersRes","type":"`StoreCustomersListOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listOrders"/>
### resetPassword
Reset a customer's password using a password token created by a previous request using the [generatePasswordToken](page.mdx#generatepasswordtoken) method. If the password token expired,
you must create a new one.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.customers.resetPassword({
email: "user@example.com",
password: "supersecret",
token: "supersecrettoken"
})
.then(({ customer }) => {
console.log(customer.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`StorePostCustomersResetPasswordReq`","description":"The necessary details to reset the password.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="resetPassword"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCustomersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer's details.","expandable":false,"children":[{"name":"StoreCustomersRes","type":"`StoreCustomersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="resetPassword"/>
### generatePasswordToken
Create a reset password token to be used when sending a request with the [resetPassword](page.mdx#resetpassword) method. This emits the event `customer.password_reset`. If a notification provider is
installed in the Medusa backend and is configured to handle this event, a notification to the customer, such as an email, may be sent with reset instructions.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.customers.generatePasswordToken({
email: "user@example.com"
})
.then(() => {
// successful
})
.catch(() => {
// failed
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`StorePostCustomersCustomerPasswordTokenReq`","description":"The necessary details to create the reset password token.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="generatePasswordToken"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"`ResponsePromise`","optional":false,"defaultValue":"","description":"Resolves when reset password token is created successfully.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="generatePasswordToken"/>

View File

@@ -1,40 +0,0 @@
---
slug: /references/js-client/GiftCardsResource
---
import { TypeList } from "docs-ui"
# GiftCardsResource
This class is used to send requests to [Store Gift Card API Routes](https://docs.medusajs.com/api/store#gift-cards). All its method
are available in the JS Client under the `medusa.giftCards` property.
Customers can use gift cards during checkout to deduct the gift card's balance from the checkout total.
The methods in this class allow retrieving a gift card's details by its code. A gift card can be applied to a cart using [CartsResource](../js_client.CartsResource/page.mdx).
Related Guide: [How to use gift cards in a storefront](https://docs.medusajs.com/modules/gift-cards/storefront/use-gift-cards).
## Methods
### retrieve
Retrieve a Gift Card's details by its associated unique code.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.giftCards.retrieve(code)
.then(({ gift_card }) => {
console.log(gift_card.id);
})
```
#### Parameters
<TypeList types={[{"name":"code","type":"`string`","description":"The code of the gift card.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreGiftCardsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the gift card.","expandable":false,"children":[{"name":"StoreGiftCardsRes","type":"`StoreGiftCardsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>

View File

@@ -1,86 +0,0 @@
---
slug: /references/js-client/LineItemsResource
---
import { TypeList } from "docs-ui"
# LineItemsResource
This class is used to send requests to Line Item API Routes part of the [Store Cart API Routes](https://docs.medusajs.com/api/store#carts). All its method
are available in the JS Client under the `medusa.carts.lineItems` property.
## Methods
### create
Generate a Line Item with a given Product Variant and adds it to the Cart
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.lineItems.create(cart_id, {
variant_id,
quantity: 1
})
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`StorePostCartsCartLineItemsReq`","description":"The line item to be created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the associated cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"`StoreCartsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### update
Update a line item's data.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.lineItems.update(cartId, lineId, {
quantity: 1
})
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The ID of the line item's cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"line_id","type":"`string`","description":"The ID of the line item to update.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`StorePostCartsCartLineItemsItemReq`","description":"The data to update in the line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the associated cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"`StoreCartsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="update"/>
### delete
Delete a line item from a cart. The payment sessions will be updated and the totals will be recalculated.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.lineItems.delete(cartId, lineId)
.then(({ cart }) => {
console.log(cart.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The ID of the line item's cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"line_id","type":"`string`","description":"The ID of the line item to delete.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCartsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the associated cart's details.","expandable":false,"children":[{"name":"StoreCartsRes","type":"`StoreCartsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="delete"/>

View File

@@ -1,86 +0,0 @@
---
slug: /references/js-client/OrderEditsResource
---
import { TypeList } from "docs-ui"
# OrderEditsResource
This class is used to send requests to [Store Order Edits API Routes](https://docs.medusajs.com/api/store#order-edits). All its method
are available in the JS Client under the `medusa.orderEdits` property.
Order edits are changes made to items in an order such as adding, updating their quantity, or deleting them. Order edits are created by the admin.
A customer can review order edit requests created by an admin and confirm or decline them.
Related Guide: [How to handle order edits in a storefront](https://docs.medusajs.com/modules/orders/storefront/handle-order-edits).
## Methods
### retrieve
Retrieve an Order Edit's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.orderEdits.retrieve(orderEditId)
.then(({ order_edit }) => {
console.log(order_edit.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order edit.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreOrderEditsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order edit's details.","expandable":false,"children":[{"name":"StoreOrderEditsRes","type":"`StoreOrderEditsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### decline
Decline an Order Edit. The changes are not reflected on the original order.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.orderEdits.decline(orderEditId)
.then(({ order_edit }) => {
console.log(order_edit.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order edit.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`StorePostOrderEditsOrderEditDecline`","description":"The decline details.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="decline"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreOrderEditsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order edit's details.","expandable":false,"children":[{"name":"StoreOrderEditsRes","type":"`StoreOrderEditsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="decline"/>
### complete
Complete and confirm an Order Edit and reflect its changes on the original order. Any additional payment required must be authorized first using the [PaymentCollectionsResource](../js_client.PaymentCollectionsResource/page.mdx) routes.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.orderEdits.complete(orderEditId)
.then(({ order_edit }) => {
console.log(order_edit.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the order edit.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="complete"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreOrderEditsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the order edit's details.","expandable":false,"children":[{"name":"StoreOrderEditsRes","type":"`StoreOrderEditsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="complete"/>

View File

@@ -1,149 +0,0 @@
---
slug: /references/js-client/OrdersResource
---
import { TypeList } from "docs-ui"
# OrdersResource
This class is used to send requests to [Store Order API Routes](https://docs.medusajs.com/api/store#orders). All its method
are available in the JS Client under the `medusa.orders` property.
Orders are purchases made by customers, typically through a storefront.
Orders are placed and created using [CartsResource](../js_client.CartsResource/page.mdx). The methods in this class allow retrieving and claiming orders.
Related Guide: [How to retrieve order details in a storefront](https://docs.medusajs.com/modules/orders/storefront/retrieve-order-details).
## Methods
### retrieve
Retrieve an Order's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.orders.retrieve(orderId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the order.","expandable":false,"children":[{"name":"StoreOrdersRes","type":"`StoreOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### retrieveByCartId
Retrieve an order's details by the ID of the cart that was used to create the order.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.orders.retrieveByCartId(cartId)
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieveByCartId"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the order.","expandable":false,"children":[{"name":"StoreOrdersRes","type":"`StoreOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieveByCartId"/>
### lookupOrder
Look up an order using filters. If the filters don't narrow down the results to a single order, a `404` response is returned with no orders.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.orders.lookupOrder({
display_id: 1,
email: "user@example.com"
})
.then(({ order }) => {
console.log(order.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`StoreGetOrdersParams`","description":"Filters used to retrieve the order.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="lookupOrder"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreOrdersRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the details of the order.","expandable":false,"children":[{"name":"StoreOrdersRes","type":"`StoreOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="lookupOrder"/>
### requestCustomerOrders
Allow the logged-in customer to claim ownership of one or more orders. This generates a token that can be used later on to verify the claim using the [confirmRequest](page.mdx#confirmrequest) method.
This also emits the event `order-update-token.created`. So, if you have a notification provider installed that handles this event and sends the customer a notification, such as an email,
the customer should receive instructions on how to finalize their claim ownership.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.orders.requestCustomerOrders({
order_ids,
})
.then(() => {
// successful
})
.catch(() => {
// an error occurred
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`StorePostCustomersCustomerOrderClaimReq`","description":"The orders to claim.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="requestCustomerOrders"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"`ResponsePromise`","optional":false,"defaultValue":"","description":"Resolves when the request is created successfully.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="requestCustomerOrders"/>
### confirmRequest
Verify the claim order token provided to the customer when they request ownership of an order.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.orders.confirmRequest(
token,
)
.then(() => {
// successful
})
.catch(() => {
// an error occurred
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`StorePostCustomersCustomerAcceptClaimReq`","description":"The claim order to verify.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="confirmRequest"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"`ResponsePromise`","optional":false,"defaultValue":"","description":"Resolves when the claim order is verified successfully.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="confirmRequest"/>

View File

@@ -1,207 +0,0 @@
---
slug: /references/js-client/PaymentCollectionsResource
---
import { TypeList } from "docs-ui"
# PaymentCollectionsResource
This class is used to send requests to [Store Payment Collection API Routes](https://docs.medusajs.com/api/store#payment-collections). All its method
are available in the JS Client under the `medusa.paymentCollections` property.
A payment collection is useful for managing additional payments, such as for Order Edits, or installment payments.
## Methods
### retrieve
Retrieve a Payment Collection's details.
#### Example
A simple example that retrieves a payment collection by its ID:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.paymentCollections.retrieve(paymentCollectionId)
.then(({ payment_collection }) => {
console.log(payment_collection.id)
})
```
To specify relations that should be retrieved:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.paymentCollections.retrieve(paymentCollectionId, {
expand: "region"
})
.then(({ payment_collection }) => {
console.log(payment_collection.id)
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`StoreGetPaymentCollectionsParams`","description":"Configurations to apply on the retrieved payment collection.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StorePaymentCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the payment collection's details.","expandable":false,"children":[{"name":"StorePaymentCollectionsRes","type":"`StorePaymentCollectionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### authorizePaymentSession
Authorize a Payment Session of a Payment Collection.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.paymentCollections.authorize(paymentId, sessionId)
.then(({ payment_collection }) => {
console.log(payment_collection.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"session_id","type":"`string`","description":"The ID of the payment session.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="authorizePaymentSession"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StorePaymentCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the payment collection's details.","expandable":false,"children":[{"name":"StorePaymentCollectionsRes","type":"`StorePaymentCollectionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="authorizePaymentSession"/>
### authorizePaymentSessionsBatch
Authorize the Payment Sessions of a Payment Collection.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.paymentCollections.authorizePaymentSessionsBatch(paymentCollectionId, {
session_ids: ["ps_123456"]
})
.then(({ payment_collection }) => {
console.log(payment_collection.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`StorePostPaymentCollectionsBatchSessionsAuthorizeReq`","description":"The list of payment session IDs to authorize.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="authorizePaymentSessionsBatch"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StorePaymentCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the payment collection's details.","expandable":false,"children":[{"name":"StorePaymentCollectionsRes","type":"`StorePaymentCollectionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="authorizePaymentSessionsBatch"/>
### managePaymentSessionsBatch
Create, update, or delete a list of payment sessions of a Payment Collections. If a payment session is not provided in the `sessions` array, it's deleted.
#### Example
To add two new payment sessions:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
// Total amount = 10000
medusa.paymentCollections.managePaymentSessionsBatch(paymentId, {
sessions: [
{
provider_id: "stripe",
amount: 5000,
},
{
provider_id: "manual",
amount: 5000,
},
]
})
.then(({ payment_collection }) => {
console.log(payment_collection.id);
})
```
To update a payment session and another one by not including it in the payload:
```ts
medusa.paymentCollections.managePaymentSessionsBatch(paymentId, {
sessions: [
{
provider_id: "stripe",
amount: 10000,
session_id: "ps_123456"
},
]
})
.then(({ payment_collection }) => {
console.log(payment_collection.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`StorePostPaymentCollectionsBatchSessionsReq`","description":"The attributes of each session to update.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="managePaymentSessionsBatch"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StorePaymentCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the payment collection's details.","expandable":false,"children":[{"name":"StorePaymentCollectionsRes","type":"`StorePaymentCollectionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="managePaymentSessionsBatch"/>
### managePaymentSession
Create a Payment Session for a payment provider in a Payment Collection.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.paymentCollections.managePaymentSession(payment_id, { provider_id: "stripe" })
.then(({ payment_collection }) => {
console.log(payment_collection.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"payload","type":"`StorePaymentCollectionSessionsReq`","description":"The payment session to create.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="managePaymentSession"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StorePaymentCollectionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the payment collection's details.","expandable":false,"children":[{"name":"StorePaymentCollectionsRes","type":"`StorePaymentCollectionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="managePaymentSession"/>
### refreshPaymentSession
Refresh a Payment Session's data to ensure that it is in sync with the Payment Collection.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.paymentCollections.refreshPaymentSession(paymentCollectionId, sessionId)
.then(({ payment_session }) => {
console.log(payment_session.status);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the payment collection.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"session_id","type":"`string`","description":"The ID of the payment session.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="refreshPaymentSession"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StorePaymentCollectionsSessionRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the refreshed payment session's details.","expandable":false,"children":[{"name":"StorePaymentCollectionsSessionRes","type":"`StorePaymentCollectionsSessionRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="refreshPaymentSession"/>

View File

@@ -1,39 +0,0 @@
---
slug: /references/js-client/PaymentMethodsResource
---
import { TypeList } from "docs-ui"
# PaymentMethodsResource
This class is used to send requests to Payment Method API Routes part of the [Store Customer API Routes](https://docs.medusajs.com/api/store#customers\_postcustomers). All its method
are available in the JS Client under the `medusa.customers.paymentMethods` property.
All methods in this class require [authentication](../../../modules/customer/page.mdx).
## Methods
### list
Retrieve the logged-in customer's saved payment methods. This method only works with payment providers created with the deprecated Payment Service interface.
The payment methods are saved using the Payment Service's third-party service, and not on the Medusa backend. So, they're retrieved from the third-party service.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged
medusa.customers.paymentMethods.list()
.then(({ payment_methods }) => {
console.log(payment_methods.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreCustomersListPaymentMethodsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the customer's payment methods.","expandable":false,"children":[{"name":"StoreCustomersListPaymentMethodsRes","type":"`StoreCustomersListPaymentMethodsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>

View File

@@ -1,133 +0,0 @@
---
slug: /references/js-client/ProductCategoriesResource
---
import { TypeList } from "docs-ui"
# ProductCategoriesResource
:::note
To use this resource, make sure to [enable its feature flag: product_categories](https://docs.medusajs.com/development/feature-flags/toggle)
:::
This class is used to send requests to [Store Product Category API Routes](https://docs.medusajs.com/api/store#product-categories\_getproductcategories). All its method
are available in the JS Client under the `medusa.productCategories` property.
Products can be categoriezed into categories. A product can be associated more than one category.
Using the methods in this class, you can list or retrieve a category's details and products.
Related Guide: [How to use product categories in a storefront](https://docs.medusajs.com/modules/products/storefront/use-categories).
## Methods
### retrieve
Retrieve a Product Category's details.
#### Example
A simple example that retrieves a product category by its ID:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.productCategories.retrieve(productCategoryId)
.then(({ product_category }) => {
console.log(product_category.id);
})
```
To specify relations that should be retrieved:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.productCategories.retrieve(productCategoryId, {
expand: "products"
})
.then(({ product_category }) => {
console.log(product_category.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product category.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`StoreGetProductCategoriesCategoryParams`","description":"Configurations to apply on the retrieved product categories.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreGetProductCategoriesCategoryRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product category's details.","expandable":false,"children":[{"name":"StoreGetProductCategoriesCategoryRes","type":"`StoreGetProductCategoriesCategoryRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of product categories. The product categories can be filtered by fields such as `handle` or `q` passed in the `query` parameter.
The product categories can also be paginated. This method can also be used to retrieve a product category by its handle.
#### Example
To list product categories:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.productCategories.list()
.then(({ product_categories, limit, offset, count }) => {
console.log(product_categories.length);
})
```
To retrieve a product category by its handle:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.productCategories.list({
handle: "women",
})
.then(({ product_categories, limit, offset, count }) => {
if (!product_categories.length) {
// category does not exist
}
const category = product_categories[0]
})
```
To specify relations that should be retrieved within the product categories:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.productCategories.list({
expand: "products"
})
.then(({ product_categories, limit, offset, count }) => {
console.log(product_categories.length);
})
```
By default, only the first `100` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.productCategories.list({
expand: "products",
limit,
offset
})
.then(({ product_categories, limit, offset, count }) => {
console.log(product_categories.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`StoreGetProductCategoriesParams`","description":"Filters and pagination configurations to apply on the retrieved product categories.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreGetProductCategoriesRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of product categories with pagination fields.","expandable":false,"children":[{"name":"StoreGetProductCategoriesRes","type":"`StoreGetProductCategoriesRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>

View File

@@ -1,54 +0,0 @@
---
slug: /references/js-client/ProductTagsResource
---
import { TypeList } from "docs-ui"
# ProductTagsResource
This class is used to send requests to [Store Product Tag API Routes](https://docs.medusajs.com/api/store#product-tags). All its method
are available in the JS Client under the `medusa.productTags` property.
Product tags are string values that can be used to filter products by.
Products can have more than one tag, and products can share tags.
## Methods
### list
Retrieve a list of product tags. The product tags can be filtered by fields such as `id` or `q` passed in the `query` parameter. The product tags can also be sorted or paginated.
#### Example
To list product tags:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.productTags.list()
.then(({ product_tags }) => {
console.log(product_tags.length);
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.productTags.list({
limit,
offset
})
.then(({ product_tags }) => {
console.log(product_tags.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`StoreGetProductTagsParams`","description":"Filters and pagination configurations to apply on the retrieved product tags.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreProductTagsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of product tags with pagination fields.","expandable":false,"children":[{"name":"StoreProductTagsListRes","type":"`StoreProductTagsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>

View File

@@ -1,56 +0,0 @@
---
slug: /references/js-client/ProductTypesResource
---
import { TypeList } from "docs-ui"
# ProductTypesResource
This class is used to send requests to [Store Product Type API Routes](https://docs.medusajs.com/api/store#product-types). All its method
are available in the JS Client under the `medusa.productTypes` property.
Product types are string values that can be used to filter products by.
Products can have more than one tag, and products can share types.
## Methods
### list
Retrieve a list of product types. The product types can be filtered by fields such as `value` or `q` passed in the `query` parameter. The product types can also be sorted or paginated.
#### Example
To list product types:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.productTypes.list()
.then(({ product_types }) => {
console.log(product_types.length);
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.productTypes.list({
limit,
offset
})
.then(({ product_types }) => {
console.log(product_types.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`StoreGetProductTypesParams`","description":"Filters and pagination configurations to apply on retrieved product types.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreProductTypesListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of product types with pagination fields.","expandable":false,"children":[{"name":"StoreProductTypesListRes","type":"`StoreProductTypesListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>

View File

@@ -1,104 +0,0 @@
---
slug: /references/js-client/ProductVariantsResource
---
import { TypeList } from "docs-ui"
# ProductVariantsResource
This class is used to send requests to [Store Product Variant API Routes](https://docs.medusajs.com/api/store#product-variants). All its method
are available in the JS Client under the `medusa.product.variants` property.
Product variants are the actual salable item in your store. Each variant is a combination of the different option values available on the product.
## Methods
### retrieve
Retrieve a Product Variant's details. For accurate and correct pricing of the product variant based on the customer's context, it's highly recommended to pass fields such as
`region_id`, `currency_code`, and `cart_id` when available.
Passing `sales_channel_id` ensures retrieving only variants of products available in the current sales channel.
You can alternatively use a publishable API key in the request header instead of passing a `sales_channel_id`.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.product.variants.retrieve(productVariantId)
.then(({ variant }) => {
console.log(variant.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the product variant.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreVariantsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product variant's details.","expandable":false,"children":[{"name":"StoreVariantsRes","type":"`StoreVariantsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieves a list of product variants. The product variants can be filtered by fields such as `id` or `title` passed in the `query` parameter. The product variants can also be paginated.
For accurate and correct pricing of the product variants based on the customer's context, it's highly recommended to pass fields such as
`region_id`, `currency_code`, and `cart_id` when available.
Passing `sales_channel_id` ensures retrieving only variants of products available in the specified sales channel.
You can alternatively use a publishable API key in the request header instead of passing a `sales_channel_id`.
#### Example
To list product variants:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.product.variants.list()
.then(({ variants }) => {
console.log(variants.length);
})
```
To specify relations that should be retrieved within the product variants:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.product.variants.list({
expand: "product"
})
.then(({ variants }) => {
console.log(variants.length);
})
```
By default, only the first `100` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.product.variants.list({
expand: "product",
limit,
offset
})
.then(({ variants }) => {
console.log(variants.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`StoreGetVariantsParams`","description":"Filters and pagination configurations applied on the retrieved product variants.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreVariantsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of product variants.","expandable":false,"children":[{"name":"StoreVariantsListRes","type":"`StoreVariantsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>

View File

@@ -1,136 +0,0 @@
---
slug: /references/js-client/ProductsResource
---
import { TypeList } from "docs-ui"
# ProductsResource
This class is used to send requests to [Store Product API Routes](https://docs.medusajs.com/api/store#products). All its method
are available in the JS Client under the `medusa.products` property.
Products are saleable items in a store. This also includes [saleable gift cards](https://docs.medusajs.com/modules/gift-cards/storefront/use-gift-cards) in a store.
Using the methods in this class, you can filter products by categories, collections, sales channels, and more.
Related Guide: [How to show products in a storefront](https://docs.medusajs.com/modules/products/storefront/show-products).
## Properties
<TypeList types={[{"name":"variants","type":"[ProductVariantsResource](../js_client.ProductVariantsResource/page.mdx)","description":"An instance of [ProductVariantsResource](../js_client.ProductVariantsResource/page.mdx) used to send requests to [Store Product Variant API Routes](https://docs.medusajs.com/api/store#product-variants\\_getvariants).","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="ProductsResource"/>
___
## Methods
### retrieve
Retrieve a Product's details. For accurate and correct pricing of the product based on the customer's context, it's highly recommended to pass fields such as
`region_id`, `currency_code`, and `cart_id` when available.
Passing `sales_channel_id` ensures retrieving only products available in the current sales channel.
You can alternatively use a publishable API key in the request header instead of passing a `sales_channel_id`.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.products.retrieve(productId)
.then(({ product }) => {
console.log(product.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The product's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreProductsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the product's details.","expandable":false,"children":[{"name":"StoreProductsRes","type":"`StoreProductsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### search
Run a search query on products using the search service installed on the Medusa backend. The searching is handled through the search service, so the returned data's
format depends on the search service you're using.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.products.search({
q: "Shirt"
})
.then(({ hits }) => {
console.log(hits.length);
})
```
#### Parameters
<TypeList types={[{"name":"searchOptions","type":"`StorePostSearchReq`","description":"Fields to search products.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="search"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StorePostSearchRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of search results. The format of the items depends on the search engine installed on the Medusa backend.","expandable":false,"children":[{"name":"StorePostSearchRes","type":"`StorePostSearchRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="search"/>
### list
Retrieve a list of products. The products can be filtered by fields such as `id` or `q` passed in the `query` parameter. The products can also be sorted or paginated.
This method can also be used to retrieve a product by its handle.
For accurate and correct pricing of the products based on the customer's context, it's highly recommended to pass fields such as
`region_id`, `currency_code`, and `cart_id` when available.
Passing `sales_channel_id` ensures retrieving only products available in the specified sales channel.
You can alternatively use a publishable API key in the request header instead of passing a `sales_channel_id`.
#### Example
To list products:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.products.list()
.then(({ products, limit, offset, count }) => {
console.log(products.length);
})
```
To specify relations that should be retrieved within the products:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.products.list({
expand: "variants"
})
.then(({ products, limit, offset, count }) => {
console.log(products.length);
})
```
By default, only the first `100` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.products.list({
expand: "variants",
limit,
offset
})
.then(({ products, limit, offset, count }) => {
console.log(products.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`StoreGetProductsParams`","description":"Filters and pagination configurations to apply on the retrieved products.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreProductsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of products with pagination fields.","expandable":false,"children":[{"name":"StoreProductsListRes","type":"`StoreProductsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>

View File

@@ -1,63 +0,0 @@
---
slug: /references/js-client/RegionsResource
---
import { TypeList } from "docs-ui"
# RegionsResource
This class is used to send requests to [Store Region API Routes](https://docs.medusajs.com/api/store#regions\_getregions). All its method
are available in the JS Client under the `medusa.regions` property.
Regions are different countries or geographical regions that the commerce store serves customers in.
Customers can choose what region they're in, which can be used to change the prices shown based on the region and its currency.
Related Guide: [How to use regions in a storefront](https://docs.medusajs.com/modules/regions-and-currencies/storefront/use-regions).
## Methods
### list
Retrieve a list of regions. This method is useful to show the customer all available regions to choose from.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.regions.list()
.then(({ regions, count, limit, offset }) => {
console.log(regions.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreRegionsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of regions with pagination fields.","expandable":false,"children":[{"name":"StoreRegionsListRes","type":"`StoreRegionsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
### retrieve
Retrieve a Region's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.regions.retrieve(regionId)
.then(({ region }) => {
console.log(region.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The region's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreRegionsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the region's details.","expandable":false,"children":[{"name":"StoreRegionsRes","type":"`StoreRegionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>

View File

@@ -1,60 +0,0 @@
---
slug: /references/js-client/ReturnReasonsResource
---
import { TypeList } from "docs-ui"
# ReturnReasonsResource
This class is used to send requests to [Store Return Reason API Routes](https://docs.medusajs.com/api/store#return-reasons). All its method
are available in the JS Client under the `medusa.returnReasons` property.
Return reasons are key-value pairs that are used to specify why an order return is being created.
## Methods
### retrieve
Retrieve a Return Reason's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.returnReasons.retrieve(reasonId)
.then(({ return_reason }) => {
console.log(return_reason.id);
})
```
#### Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the return reason.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreReturnReasonsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the return reason's details.","expandable":false,"children":[{"name":"StoreReturnReasonsRes","type":"`StoreReturnReasonsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieve"/>
### list
Retrieve a list of Return Reasons. This is useful when implementing a Create Return flow in the storefront.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.returnReasons.list()
.then(({ return_reasons }) => {
console.log(return_reasons.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreReturnReasonsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of return reasons.","expandable":false,"children":[{"name":"StoreReturnReasonsListRes","type":"`StoreReturnReasonsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>

View File

@@ -1,47 +0,0 @@
---
slug: /references/js-client/ReturnsResource
---
import { TypeList } from "docs-ui"
# ReturnsResource
This class is used to send requests to [Store Return API Routes](https://docs.medusajs.com/api/store#returns). All its method
are available in the JS Client under the `medusa.returns` property.
A return can be created by a customer to return items in an order.
Related Guide: [How to create a return in a storefront](https://docs.medusajs.com/modules/orders/storefront/create-return).
## Methods
### create
Create a return for an order. If a return shipping method is specified, the return is automatically fulfilled.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.returns.create({
order_id,
items: [
{
item_id,
quantity: 1
}
]
})
.then((data) => {
console.log(data.return.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`StorePostReturnsReq`","description":"The data of the return to be created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreReturnsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the return's details.","expandable":false,"children":[{"name":"StoreReturnsRes","type":"`StoreReturnsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>

View File

@@ -1,62 +0,0 @@
---
slug: /references/js-client/ShippingOptionsResource
---
import { TypeList } from "docs-ui"
# ShippingOptionsResource
This class is used to send requests to [Store Shipping Option API Routes](https://docs.medusajs.com/api/store#shipping-options). All its method
are available in the JS Client under the `medusa.shippingOptions` property.
A shipping option is used to define the available shipping methods during checkout or when creating a return.
Related Guide: [Shipping Option architecture](https://docs.medusajs.com/modules/carts-and-checkout/shipping#shipping-option).
## Methods
### listCartOptions
Retrieve a list of shipping options available for a cart.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.shippingOptions.listCartOptions(cartId)
.then(({ shipping_options }) => {
console.log(shipping_options.length);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listCartOptions"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreShippingOptionsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of shipping options.","expandable":false,"children":[{"name":"StoreShippingOptionsListRes","type":"`StoreShippingOptionsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="listCartOptions"/>
### list
Retrieve a list of shipping options. The shipping options can be filtered using the `query` parameter.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.shippingOptions.list()
.then(({ shipping_options }) => {
console.log(shipping_options.length);
})
```
#### Parameters
<TypeList types={[{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"query","type":"`StoreGetShippingOptionsParams`","description":"The filters to apply on the shipping options.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreShippingOptionsListRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the list of shipping options.","expandable":false,"children":[{"name":"StoreShippingOptionsListRes","type":"`StoreShippingOptionsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="list"/>

View File

@@ -1,82 +0,0 @@
---
slug: /references/js-client/SwapsResource
---
import { TypeList } from "docs-ui"
# SwapsResource
This class is used to send requests to [Store Swap API Routes](https://docs.medusajs.com/api/store#swaps). All its method
are available in the JS Client under the `medusa.swaps` property.
A swap is created by a customer or an admin to exchange an item with a new one.
Creating a swap implicitely includes creating a return for the item being exchanged.
Related Guide: [How to create a swap in a storefront](https://docs.medusajs.com/modules/orders/storefront/create-swap)
## Methods
### create
Create a Swap for an Order. This will also create a return and associate it with the swap. If a return shipping option is specified, the return will automatically be fulfilled.
To complete the swap, you must use the [CartsResource.complete](../js_client.CartsResource/page.mdx#complete) method passing it the ID of the swap's cart.
An idempotency key will be generated if none is provided in the header `Idempotency-Key` and added to
the response. If an error occurs during swap creation or the request is interrupted for any reason, the swap creation can be retried by passing the idempotency
key in the `Idempotency-Key` header.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.swaps.create({
order_id,
return_items: [
{
item_id,
quantity: 1
}
],
additional_items: [
{
variant_id,
quantity: 1
}
]
})
.then(({ swap }) => {
console.log(swap.id);
})
```
#### Parameters
<TypeList types={[{"name":"payload","type":"`StorePostSwapsReq`","description":"The data of the swap to be created.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreSwapsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the swap's details.","expandable":false,"children":[{"name":"StoreSwapsRes","type":"`StoreSwapsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="create"/>
### retrieveByCartId
Retrieve a Swap's details by the ID of its cart.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.swaps.retrieveByCartId(cartId)
.then(({ swap }) => {
console.log(swap.id);
})
```
#### Parameters
<TypeList types={[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customHeaders","type":"`Record<string, any>`","description":"Custom headers to attach to the request.","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieveByCartId"/>
#### Returns
<TypeList types={[{"name":"ResponsePromise","type":"ResponsePromise&#60;StoreSwapsRes&#62;","optional":false,"defaultValue":"","description":"Resolves to the swap's details.","expandable":false,"children":[{"name":"StoreSwapsRes","type":"`StoreSwapsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields" sectionTitle="retrieveByCartId"/>

View File

@@ -1,123 +0,0 @@
---
slug: /references/medusa-react/hooks/admin/auth
---
import { TypeList } from "docs-ui"
# Auth
Queries and mutations listed here are used to send requests to the [Admin Auth API Routes](https://docs.medusajs.com/api/admin#auth\_getauth).
They allow admin users to manage their session, such as login or log out.
You can send authenticated requests for an admin user either using the Cookie header, their API token, or the JWT Token.
When you log the admin user in using the [authentication](../../../../modules/user/page.mdx) hook, Medusa React will automatically attach the
cookie header in all subsequent requests.
Related Guide: [How to implement user profiles](https://docs.medusajs.com/modules/users/admin/manage-profile).
## Mutations
### useAdminLogin
This hook is used to log a User in using their credentials. If the user is authenticated successfully,
the cookie is automatically attached to subsequent requests sent with other hooks.
#### Example
```ts
import React from "react"
import { useAdminLogin } from "medusa-react"
const Login = () => {
const adminLogin = useAdminLogin()
// ...
const handleLogin = () => {
adminLogin.mutate({
email: "user@example.com",
password: "supersecret",
}, {
onSuccess: ({ user }) => {
console.log(user)
}
})
}
// ...
}
export default Login
```
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostAuthReq","type":"`AdminPostAuthReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminLogin"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminAuthRes","type":"`AdminAuthRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminLogin"/>
### useAdminDeleteSession
This hook is used to Log out the user and remove their authentication session. This will only work if you're using Cookie session for authentication. If the API token is still passed in the header,
the user is still authorized to perform admin functionalities in other API Routes.
This hook requires [authentication](../../../../modules/user/page.mdx).
#### Example
```ts
import React from "react"
import { useAdminDeleteSession } from "medusa-react"
const Logout = () => {
const adminLogout = useAdminDeleteSession()
// ...
const handleLogout = () => {
adminLogout.mutate(undefined, {
onSuccess: () => {
// user logged out.
}
})
}
// ...
}
export default Logout
```
___
## Queries
### useAdminGetSession
This hook is used to get the currently logged in user's details. Can also be used to check if there is an authenticated user.
This hook requires [authentication](../../../../modules/user/page.mdx).
#### Example
```ts
import React from "react"
import { useAdminGetSession } from "medusa-react"
const Profile = () => {
const { user, isLoading } = useAdminGetSession()
return (
<div>
{isLoading && <span>Loading...</span>}
{user && <span>{user.email}</span>}
</div>
)
}
export default Profile
```
#### Query Returned Data
<TypeList types={[{"name":"AdminAuthRes","type":"`AdminAuthRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminGetSession"/>

View File

@@ -1,263 +0,0 @@
---
slug: /references/medusa-react/hooks/admin/batch_jobs
---
import { TypeList } from "docs-ui"
# Batch Jobs
Queries and mutations listed here are used to send requests to the [Admin Batch Job API Routes](https://docs.medusajs.com/api/admin#batch-jobs).
All hooks listed require [authentication](../../../../modules/user/page.mdx).
A batch job is a task that is performed by the Medusa backend asynchronusly. For example, the Import Product feature is implemented using batch jobs.
The methods in this class allow admins to manage the batch jobs and their state.
Related Guide: [How to import products](https://docs.medusajs.com/modules/products/admin/import-products).
## Mutations
### useAdminCreateBatchJob
This hook creates a Batch Job to be executed asynchronously in the Medusa backend. If `dry_run` is set to `true`, the batch job will not be executed until the it is confirmed,
which can be done using the [useAdminConfirmBatchJob](../../../../modules/medusa_react/page.mdx#useadminconfirmbatchjob) hook.
#### Example
```ts
import React from "react"
import { useAdminCreateBatchJob } from "medusa-react"
const CreateBatchJob = () => {
const createBatchJob = useAdminCreateBatchJob()
// ...
const handleCreateBatchJob = () => {
createBatchJob.mutate({
type: "publish-products",
context: {},
dry_run: true
}, {
onSuccess: ({ batch_job }) => {
console.log(batch_job)
}
})
}
// ...
}
export default CreateBatchJob
```
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostBatchesReq","type":"`AdminPostBatchesReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateBatchJob"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminBatchJobRes","type":"`AdminBatchJobRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateBatchJob"/>
### useAdminCancelBatchJob
This hook marks a batch job as canceled. When a batch job is canceled, the processing of the batch job doesnt automatically stop.
#### Example
```ts
import React from "react"
import { useAdminCancelBatchJob } from "medusa-react"
type Props = {
batchJobId: string
}
const BatchJob = ({ batchJobId }: Props) => {
const cancelBatchJob = useAdminCancelBatchJob(batchJobId)
// ...
const handleCancel = () => {
cancelBatchJob.mutate(undefined, {
onSuccess: ({ batch_job }) => {
console.log(batch_job)
}
})
}
// ...
}
export default BatchJob
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the batch job.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCancelBatchJob"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminBatchJobRes","type":"`AdminBatchJobRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCancelBatchJob"/>
___
## Queries
### useAdminBatchJobs
This hook retrieves a list of Batch Jobs. The batch jobs can be filtered by fields such as `type` or `confirmed_at`. The batch jobs can also be sorted or paginated.
#### Example
To list batch jobs:
```ts
import React from "react"
import { useAdminBatchJobs } from "medusa-react"
const BatchJobs = () => {
const {
batch_jobs,
limit,
offset,
count,
isLoading
} = useAdminBatchJobs()
return (
<div>
{isLoading && <span>Loading...</span>}
{batch_jobs?.length && (
<ul>
{batch_jobs.map((batchJob) => (
<li key={batchJob.id}>
{batchJob.id}
</li>
))}
</ul>
)}
</div>
)
}
export default BatchJobs
```
To specify relations that should be retrieved within the batch jobs:
```ts
import React from "react"
import { useAdminBatchJobs } from "medusa-react"
const BatchJobs = () => {
const {
batch_jobs,
limit,
offset,
count,
isLoading
} = useAdminBatchJobs({
expand: "created_by_user",
limit: 10,
offset: 0
})
return (
<div>
{isLoading && <span>Loading...</span>}
{batch_jobs?.length && (
<ul>
{batch_jobs.map((batchJob) => (
<li key={batchJob.id}>
{batchJob.id}
</li>
))}
</ul>
)}
</div>
)
}
export default BatchJobs
```
By default, only the first `10` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import React from "react"
import { useAdminBatchJobs } from "medusa-react"
const BatchJobs = () => {
const {
batch_jobs,
limit,
offset,
count,
isLoading
} = useAdminBatchJobs({
expand: "created_by_user",
limit: 20,
offset: 0
})
return (
<div>
{isLoading && <span>Loading...</span>}
{batch_jobs?.length && (
<ul>
{batch_jobs.map((batchJob) => (
<li key={batchJob.id}>
{batchJob.id}
</li>
))}
</ul>
)}
</div>
)
}
export default BatchJobs
```
#### Hook Parameters
<TypeList types={[{"name":"query","type":"`AdminGetBatchParams`","description":"Filters and pagination configurations to apply on the retrieved batch jobs.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminBatchJobs"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminBatchJobListRes","type":"`AdminBatchJobListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminBatchJobs"/>
### useAdminBatchJob
This hook retrieves the details of a batch job.
#### Example
```ts
import React from "react"
import { useAdminBatchJob } from "medusa-react"
type Props = {
batchJobId: string
}
const BatchJob = ({ batchJobId }: Props) => {
const { batch_job, isLoading } = useAdminBatchJob(batchJobId)
return (
<div>
{isLoading && <span>Loading...</span>}
{batch_job && <span>{batch_job.created_by}</span>}
</div>
)
}
export default BatchJob
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the batch job.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminBatchJob"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminBatchJobRes","type":"`AdminBatchJobRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminBatchJob"/>

View File

@@ -1,308 +0,0 @@
---
slug: /references/medusa-react/hooks/admin/claims
---
import { TypeList } from "docs-ui"
# Claims
Mutations listed here are used to send requests to the [Admin Order API Routes related to claims](https://docs.medusajs.com/api/admin#orders).
All hooks listed require [authentication](../../../../modules/user/page.mdx).
A claim represents a return or replacement request of order items. It allows refunding the customer or replacing some or all of its
order items with new items.
Related Guide: [How to manage claims](https://docs.medusajs.com/modules/orders/admin/manage-claims).
## Mutations
### useAdminCreateClaim
This hook creates a claim for an order. If a return shipping method is specified, a return will also be created and associated with the claim. If the claim's type is `refund`,
the refund is processed as well.
#### Example
```ts
import React from "react"
import { useAdminCreateClaim } from "medusa-react"
type Props = {
orderId: string
}
const CreateClaim = ({ orderId }: Props) => {
const createClaim = useAdminCreateClaim(orderId)
// ...
const handleCreate = (itemId: string) => {
createClaim.mutate({
type: "refund",
claim_items: [
{
item_id: itemId,
quantity: 1,
},
],
}, {
onSuccess: ({ order }) => {
console.log(order.claims)
}
})
}
// ...
}
export default CreateClaim
```
#### Hook Parameters
<TypeList types={[{"name":"orderId","type":"`string`","description":"The ID of the order the claim is associated with.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateClaim"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostOrdersOrderClaimsReq","type":"`AdminPostOrdersOrderClaimsReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateClaim"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateClaim"/>
### useAdminUpdateClaim
This hook updates a claim's details.
#### Example
```ts
import React from "react"
import { useAdminUpdateClaim } from "medusa-react"
type Props = {
orderId: string
claimId: string
}
const Claim = ({ orderId, claimId }: Props) => {
const updateClaim = useAdminUpdateClaim(orderId)
// ...
const handleUpdate = () => {
updateClaim.mutate({
claim_id: claimId,
no_notification: false
}, {
onSuccess: ({ order }) => {
console.log(order.claims)
}
})
}
// ...
}
export default Claim
```
#### Hook Parameters
<TypeList types={[{"name":"orderId","type":"`string`","description":"The ID of the order the claim is associated with.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateClaim"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminUpdateClaimReq","type":"[AdminUpdateClaimReq](../../../types/medusa_react.AdminUpdateClaimReq/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"claim_id","type":"`string`","description":"The claim's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateClaim"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateClaim"/>
### useAdminCancelClaim
This hook cancels a claim and change its status. A claim can't be canceled if it has a refund, if its fulfillments haven't been canceled,
of if its associated return hasn't been canceled.
#### Example
```ts
import React from "react"
import { useAdminCancelClaim } from "medusa-react"
type Props = {
orderId: string
claimId: string
}
const Claim = ({ orderId, claimId }: Props) => {
const cancelClaim = useAdminCancelClaim(orderId)
// ...
const handleCancel = () => {
cancelClaim.mutate(claimId)
}
// ...
}
export default Claim
```
#### Hook Parameters
<TypeList types={[{"name":"orderId","type":"`string`","description":"The ID of the order the claim is associated with.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCancelClaim"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"string","type":"`string`","optional":false,"defaultValue":"","description":"The claim's ID.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCancelClaim"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCancelClaim"/>
### useAdminFulfillClaim
This hook creates a Fulfillment for a Claim, and change its fulfillment status to `partially_fulfilled` or `fulfilled` depending on whether all the items were fulfilled.
It may also change the status to `requires_action` if any actions are required.
#### Example
```ts
import React from "react"
import { useAdminFulfillClaim } from "medusa-react"
type Props = {
orderId: string
claimId: string
}
const Claim = ({ orderId, claimId }: Props) => {
const fulfillClaim = useAdminFulfillClaim(orderId)
// ...
const handleFulfill = () => {
fulfillClaim.mutate({
claim_id: claimId,
}, {
onSuccess: ({ order }) => {
console.log(order.claims)
}
})
}
// ...
}
export default Claim
```
#### Hook Parameters
<TypeList types={[{"name":"orderId","type":"`string`","description":"The ID of the order the claim is associated with.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminFulfillClaim"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminFulfillClaimReq","type":"[AdminFulfillClaimReq](../../../types/medusa_react.AdminFulfillClaimReq/page.mdx)","optional":false,"defaultValue":"","description":"The details of the claim's fulfillment.","expandable":false,"children":[{"name":"claim_id","type":"`string`","description":"The claim's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminFulfillClaim"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminFulfillClaim"/>
### useAdminCancelClaimFulfillment
This hook cancels a claim's fulfillment and change its fulfillment status to `canceled`.
#### Example
```ts
import React from "react"
import { useAdminCancelClaimFulfillment } from "medusa-react"
type Props = {
orderId: string
claimId: string
}
const Claim = ({ orderId, claimId }: Props) => {
const cancelFulfillment = useAdminCancelClaimFulfillment(
orderId
)
// ...
const handleCancel = (fulfillmentId: string) => {
cancelFulfillment.mutate({
claim_id: claimId,
fulfillment_id: fulfillmentId,
}, {
onSuccess: ({ order }) => {
console.log(order.claims)
}
})
}
// ...
}
export default Claim
```
#### Hook Parameters
<TypeList types={[{"name":"orderId","type":"`string`","description":"The ID of the order the claim is associated with.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCancelClaimFulfillment"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminCancelClaimFulfillmentReq","type":"[AdminCancelClaimFulfillmentReq](../../../types/medusa_react.AdminCancelClaimFulfillmentReq/page.mdx)","optional":false,"defaultValue":"","description":"The cancelation details.","expandable":false,"children":[{"name":"claim_id","type":"`string`","description":"The claim's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillment_id","type":"`string`","description":"The fulfillment's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCancelClaimFulfillment"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCancelClaimFulfillment"/>
### useAdminCreateClaimShipment
This hook creates a shipment for the claim and mark its fulfillment as shipped. If the shipment is created successfully, this changes the claim's fulfillment status
to either `partially_shipped` or `shipped`, depending on whether all the items were shipped.
#### Example
```ts
import React from "react"
import { useAdminCreateClaimShipment } from "medusa-react"
type Props = {
orderId: string
claimId: string
}
const Claim = ({ orderId, claimId }: Props) => {
const createShipment = useAdminCreateClaimShipment(orderId)
// ...
const handleCreateShipment = (fulfillmentId: string) => {
createShipment.mutate({
claim_id: claimId,
fulfillment_id: fulfillmentId,
}, {
onSuccess: ({ order }) => {
console.log(order.claims)
}
})
}
// ...
}
export default Claim
```
#### Hook Parameters
<TypeList types={[{"name":"orderId","type":"`string`","description":"The ID of the order the claim is associated with.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateClaimShipment"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostOrdersOrderClaimsClaimShipmentsReq","type":"`AdminPostOrdersOrderClaimsClaimShipmentsReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]},{"name":"claim_id","type":"`string`","description":"The claim's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateClaimShipment"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateClaimShipment"/>

View File

@@ -1,144 +0,0 @@
---
slug: /references/medusa-react/hooks/admin/currencies
---
import { TypeList } from "docs-ui"
# Currencies
Queries and Mutations listed here are used to send requests to the [Admin Currency API Routes](https://docs.medusajs.com/api/admin#currencies).
All hooks listed require [authentication](../../../../modules/user/page.mdx).
A store can use unlimited currencies, and each region must be associated with at least one currency.
Currencies are defined within the Medusa backend. The methods in this class allow admins to list and update currencies.
Related Guide: [How to manage currencies](https://docs.medusajs.com/modules/regions-and-currencies/admin/manage-currencies).
## Mutations
### useAdminUpdateCurrency
This hook updates a currency's details.
#### Example
```ts
import React from "react"
import { useAdminUpdateCurrency } from "medusa-react"
type Props = {
currencyCode: string
}
const Currency = ({ currencyCode }: Props) => {
const updateCurrency = useAdminUpdateCurrency(currencyCode)
// ...
const handleUpdate = (includes_tax: boolean) => {
updateCurrency.mutate({
includes_tax,
}, {
onSuccess: ({ currency }) => {
console.log(currency)
}
})
}
// ...
}
export default Currency
```
#### Hook Parameters
<TypeList types={[{"name":"code","type":"`string`","description":"The currency's code.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateCurrency"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostCurrenciesCurrencyReq","type":"`AdminPostCurrenciesCurrencyReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateCurrency"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminCurrenciesRes","type":"`AdminCurrenciesRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateCurrency"/>
___
## Queries
### useAdminCurrencies
This hook retrieves a list of currencies. The currencies can be filtered by fields such as `code`.
The currencies can also be sorted or paginated.
#### Example
To list currencies:
```ts
import React from "react"
import { useAdminCurrencies } from "medusa-react"
const Currencies = () => {
const { currencies, isLoading } = useAdminCurrencies()
return (
<div>
{isLoading && <span>Loading...</span>}
{currencies && !currencies.length && (
<span>No Currencies</span>
)}
{currencies && currencies.length > 0 && (
<ul>
{currencies.map((currency) => (
<li key={currency.code}>{currency.name}</li>
))}
</ul>
)}
</div>
)
}
export default Currencies
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
import React from "react"
import { useAdminCurrencies } from "medusa-react"
const Currencies = () => {
const { currencies, limit, offset, isLoading } = useAdminCurrencies({
limit: 10,
offset: 0
})
return (
<div>
{isLoading && <span>Loading...</span>}
{currencies && !currencies.length && (
<span>No Currencies</span>
)}
{currencies && currencies.length > 0 && (
<ul>
{currencies.map((currency) => (
<li key={currency.code}>{currency.name}</li>
))}
</ul>
)}
</div>
)
}
export default Currencies
```
#### Hook Parameters
<TypeList types={[{"name":"query","type":"`AdminGetCurrenciesParams`","description":"Filters and pagination configurations to apply on retrieved currencies.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCurrencies"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminCurrenciesListRes","type":"`AdminCurrenciesListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCurrencies"/>

View File

@@ -1,180 +0,0 @@
---
slug: /references/medusa-react/hooks/admin/custom
---
import { TypeList } from "docs-ui"
# Custom
This class is used to send requests custom API Routes. All its method
are available in the JS Client under the `medusa.admin.custom` property.
## Mutations
### useAdminCustomDelete
This hook sends a `DELETE` request to a custom API Route.
#### Example
```ts
import React from "react"
import { useAdminCustomDelete } from "medusa-react"
type Props = {
customId: string
}
const Custom = ({ customId }: Props) => {
const customDelete = useAdminCustomDelete(
`/blog/posts/${customId}`,
["posts"]
)
// ...
const handleAction = (title: string) => {
customDelete.mutate(void 0, {
onSuccess: () => {
// Delete action successful
}
})
}
// ...
}
export default Custom
```
#### Type Parameters
<TypeList types={[{"name":"TResponse","type":"`object`","description":"The response's type which defaults to `any`.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCustomDelete"/>
#### Hook Parameters
<TypeList types={[{"name":"path","type":"`string`","description":"The path to the custom endpoint.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"queryKey","type":"`QueryKey`","description":"A list of query keys, used to invalidate data.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"relatedDomains","type":"`RelatedDomains`","description":"A list of related domains that should be invalidated and refetch when the mutation\nfunction is invoked.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCustomDelete"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"TResponse","type":"TResponse","optional":false,"defaultValue":"","description":"The response based on the type provided for ","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCustomDelete"/>
### useAdminCustomPost
This hook sends a `POST` request to a custom API Route.
#### Example
```ts
import React from "react"
import { useAdminCustomPost } from "medusa-react"
import Post from "./models/Post"
type PostRequest = {
title: string
}
type PostResponse = {
post: Post
}
const Custom = () => {
const customPost = useAdminCustomPost
<PostRequest, PostResponse>(
"/blog/posts",
["posts"]
)
// ...
const handleAction = (title: string) => {
customPost.mutate({
title
}, {
onSuccess: ({ post }) => {
console.log(post)
}
})
}
// ...
}
export default Custom
```
#### Type Parameters
<TypeList types={[{"name":"TPayload","type":"`Record<string, any>`","description":"The type of accepted body parameters which defaults to `Record<string, any>`.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"TResponse","type":"`object`","description":"The type of response, which defaults to `any`.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCustomPost"/>
#### Hook Parameters
<TypeList types={[{"name":"path","type":"`string`","description":"The path to the custom endpoint.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"queryKey","type":"`QueryKey`","description":"A list of query keys, used to invalidate data.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"relatedDomains","type":"`RelatedDomains`","description":"A list of related domains that should be invalidated and refetch when the mutation\nfunction is invoked.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCustomPost"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"TPayload","type":"TPayload","optional":false,"defaultValue":"","description":"The payload based on the specified type for ","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCustomPost"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"TResponse","type":"TResponse","optional":false,"defaultValue":"","description":"The response based on the specified type for ","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCustomPost"/>
### useAdminCustomQuery
This hook sends a `GET` request to a custom API Route.
#### Example
```ts
import React from "react"
import { useAdminCustomQuery } from "medusa-react"
import Post from "./models/Post"
type RequestQuery = {
title: string
}
type ResponseData = {
posts: Post
}
const Custom = () => {
const { data, isLoading } = useAdminCustomQuery
<RequestQuery, ResponseData>(
"/blog/posts",
["posts"],
{
title: "My post"
}
)
return (
<div>
{isLoading && <span>Loading...</span>}
{data?.posts && !data.posts.length && (
<span>No Post</span>
)}
{data?.posts && data.posts?.length > 0 && (
<ul>
{data.posts.map((post) => (
<li key={post.id}>{post.title}</li>
))}
</ul>
)}
</div>
)
}
export default Custom
```
#### Type Parameters
<TypeList types={[{"name":"TQuery","type":"`Record<string, any>`","description":"The type of accepted query parameters which defaults to `Record<string, any>`.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"TResponse","type":"`object`","description":"The type of response which defaults to `any`.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCustomQuery"/>
#### Hook Parameters
<TypeList types={[{"name":"path","type":"`string`","description":"The path to the custom endpoint.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"queryKey","type":"`QueryKey`","description":"A list of query keys, used to invalidate data.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"TQuery","description":"Query parameters to pass to the request.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCustomQuery"/>
#### Query Returned Data
<TypeList types={[{"name":"TResponse","type":"TResponse","optional":false,"defaultValue":"","description":"The response based on the type specified for ","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCustomQuery"/>

View File

@@ -1,461 +0,0 @@
---
slug: /references/medusa-react/hooks/admin/customer_groups
---
import { TypeList } from "docs-ui"
# Customer Groups
Queries and Mutations listed here are used to send requests to the [Admin Customer Group API Routes](https://docs.medusajs.com/api/admin#customer-groups).
All hooks listed require [authentication](../../../../modules/user/page.mdx).
Customer Groups can be used to organize customers that share similar data or attributes into dedicated groups.
This can be useful for different purposes such as setting a different price for a specific customer group.
Related Guide: [How to manage customer groups](https://docs.medusajs.com/modules/customers/admin/manage-customer-groups).
## Mutations
### useAdminCreateCustomerGroup
This hook creates a customer group.
#### Example
```ts
import React from "react"
import { useAdminCreateCustomerGroup } from "medusa-react"
const CreateCustomerGroup = () => {
const createCustomerGroup = useAdminCreateCustomerGroup()
// ...
const handleCreate = (name: string) => {
createCustomerGroup.mutate({
name,
})
}
// ...
}
export default CreateCustomerGroup
```
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostCustomerGroupsReq","type":"`AdminPostCustomerGroupsReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateCustomerGroup"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminCustomerGroupsRes","type":"`AdminCustomerGroupsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateCustomerGroup"/>
### useAdminUpdateCustomerGroup
This hook updates a customer group's details.
#### Example
```ts
import React from "react"
import { useAdminUpdateCustomerGroup } from "medusa-react"
type Props = {
customerGroupId: string
}
const CustomerGroup = ({ customerGroupId }: Props) => {
const updateCustomerGroup = useAdminUpdateCustomerGroup(
customerGroupId
)
// ..
const handleUpdate = (name: string) => {
updateCustomerGroup.mutate({
name,
})
}
// ...
}
export default CustomerGroup
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The customer group's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateCustomerGroup"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostCustomerGroupsGroupReq","type":"`AdminPostCustomerGroupsGroupReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateCustomerGroup"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminCustomerGroupsRes","type":"`AdminCustomerGroupsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateCustomerGroup"/>
### useAdminDeleteCustomerGroup
This hook deletes a customer group. This doesn't delete the customers associated with the customer group.
#### Example
```ts
import React from "react"
import { useAdminDeleteCustomerGroup } from "medusa-react"
type Props = {
customerGroupId: string
}
const CustomerGroup = ({ customerGroupId }: Props) => {
const deleteCustomerGroup = useAdminDeleteCustomerGroup(
customerGroupId
)
// ...
const handleDeleteCustomerGroup = () => {
deleteCustomerGroup.mutate()
}
// ...
}
export default CustomerGroup
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The customer group's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteCustomerGroup"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteCustomerGroup"/>
### useAdminAddCustomersToCustomerGroup
The hook adds a list of customers to a customer group.
#### Example
```ts
import React from "react"
import {
useAdminAddCustomersToCustomerGroup,
} from "medusa-react"
type Props = {
customerGroupId: string
}
const CustomerGroup = ({ customerGroupId }: Props) => {
const addCustomers = useAdminAddCustomersToCustomerGroup(
customerGroupId
)
// ...
const handleAddCustomers= (customerId: string) => {
addCustomers.mutate({
customer_ids: [
{
id: customerId,
},
],
})
}
// ...
}
export default CustomerGroup
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The customer group's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminAddCustomersToCustomerGroup"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostCustomerGroupsGroupCustomersBatchReq","type":"`AdminPostCustomerGroupsGroupCustomersBatchReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminAddCustomersToCustomerGroup"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminCustomerGroupsRes","type":"`AdminCustomerGroupsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminAddCustomersToCustomerGroup"/>
### useAdminRemoveCustomersFromCustomerGroup
This hook removes a list of customers from a customer group. This doesn't delete the customer,
only the association between the customer and the customer group.
#### Example
```ts
import React from "react"
import {
useAdminRemoveCustomersFromCustomerGroup,
} from "medusa-react"
type Props = {
customerGroupId: string
}
const CustomerGroup = ({ customerGroupId }: Props) => {
const removeCustomers =
useAdminRemoveCustomersFromCustomerGroup(
customerGroupId
)
// ...
const handleRemoveCustomer = (customerId: string) => {
removeCustomers.mutate({
customer_ids: [
{
id: customerId,
},
],
})
}
// ...
}
export default CustomerGroup
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The customer group's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminRemoveCustomersFromCustomerGroup"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminDeleteCustomerGroupsGroupCustomerBatchReq","type":"`AdminDeleteCustomerGroupsGroupCustomerBatchReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminRemoveCustomersFromCustomerGroup"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminCustomerGroupsRes","type":"`AdminCustomerGroupsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminRemoveCustomersFromCustomerGroup"/>
___
## Queries
### useAdminCustomerGroup
This hook retrieves a customer group by its ID. You can expand the customer group's relations or
select the fields that should be returned.
#### Example
```ts
import React from "react"
import { useAdminCustomerGroup } from "medusa-react"
type Props = {
customerGroupId: string
}
const CustomerGroup = ({ customerGroupId }: Props) => {
const { customer_group, isLoading } = useAdminCustomerGroup(
customerGroupId
)
return (
<div>
{isLoading && <span>Loading...</span>}
{customer_group && <span>{customer_group.name}</span>}
</div>
)
}
export default CustomerGroup
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The customer group's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"`AdminGetCustomerGroupsGroupParams`","description":"Configurations to apply on the retrieved customer group.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCustomerGroup"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminCustomerGroupsRes","type":"`AdminCustomerGroupsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCustomerGroup"/>
### useAdminCustomerGroups
This hook retrieves a list of customer groups. The customer groups can be filtered by fields such as `name` or `id`.
The customer groups can also be sorted or paginated.
#### Example
To list customer groups:
```tsx
import React from "react"
import { useAdminCustomerGroups } from "medusa-react"
const CustomerGroups = () => {
const {
customer_groups,
isLoading,
} = useAdminCustomerGroups()
return (
<div>
{isLoading && <span>Loading...</span>}
{customer_groups && !customer_groups.length && (
<span>No Customer Groups</span>
)}
{customer_groups && customer_groups.length > 0 && (
<ul>
{customer_groups.map(
(customerGroup) => (
<li key={customerGroup.id}>
{customerGroup.name}
</li>
)
)}
</ul>
)}
</div>
)
}
export default CustomerGroups
```
To specify relations that should be retrieved within the customer groups:
```tsx
import React from "react"
import { useAdminCustomerGroups } from "medusa-react"
const CustomerGroups = () => {
const {
customer_groups,
isLoading,
} = useAdminCustomerGroups({
expand: "customers"
})
return (
<div>
{isLoading && <span>Loading...</span>}
{customer_groups && !customer_groups.length && (
<span>No Customer Groups</span>
)}
{customer_groups && customer_groups.length > 0 && (
<ul>
{customer_groups.map(
(customerGroup) => (
<li key={customerGroup.id}>
{customerGroup.name}
</li>
)
)}
</ul>
)}
</div>
)
}
export default CustomerGroups
```
By default, only the first `10` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```tsx
import React from "react"
import { useAdminCustomerGroups } from "medusa-react"
const CustomerGroups = () => {
const {
customer_groups,
limit,
offset,
isLoading,
} = useAdminCustomerGroups({
expand: "customers",
limit: 15,
offset: 0
})
return (
<div>
{isLoading && <span>Loading...</span>}
{customer_groups && !customer_groups.length && (
<span>No Customer Groups</span>
)}
{customer_groups && customer_groups.length > 0 && (
<ul>
{customer_groups.map(
(customerGroup) => (
<li key={customerGroup.id}>
{customerGroup.name}
</li>
)
)}
</ul>
)}
</div>
)
}
export default CustomerGroups
```
#### Hook Parameters
<TypeList types={[{"name":"query","type":"`AdminGetCustomerGroupsParams`","description":"Filters and pagination configurations to apply on the retrieved customer groups.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCustomerGroups"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminCustomerGroupsListRes","type":"`AdminCustomerGroupsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCustomerGroups"/>
### useAdminCustomerGroupCustomers
This hook retrieves a list of customers in a customer group. The customers can be filtered
by the `query` field. The customers can also be paginated.
#### Example
```ts
import React from "react"
import { useAdminCustomerGroupCustomers } from "medusa-react"
type Props = {
customerGroupId: string
}
const CustomerGroup = ({ customerGroupId }: Props) => {
const {
customers,
isLoading,
} = useAdminCustomerGroupCustomers(
customerGroupId
)
return (
<div>
{isLoading && <span>Loading...</span>}
{customers && !customers.length && (
<span>No customers</span>
)}
{customers && customers.length > 0 && (
<ul>
{customers.map((customer) => (
<li key={customer.id}>{customer.first_name}</li>
))}
</ul>
)}
</div>
)
}
export default CustomerGroup
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The customer group's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"`AdminGetCustomersParams`","description":"Filters and pagination configurations to apply on the retrieved customers.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCustomerGroupCustomers"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminCustomersListRes","type":"`AdminCustomersListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCustomerGroupCustomers"/>

View File

@@ -1,230 +0,0 @@
---
slug: /references/medusa-react/hooks/admin/customers
---
import { TypeList } from "docs-ui"
# Customers
Queries and Mutations listed here are used to send requests to the [Admin Customer API Routes](https://docs.medusajs.com/api/admin#customers).
All hooks listed require [authentication](../../../../modules/user/page.mdx).
Related Guide: [How to manage customers](https://docs.medusajs.com/modules/customers/admin/manage-customers).
## Mutations
### useAdminCreateCustomer
This hook creates a customer as an admin.
#### Example
```ts
import React from "react"
import { useAdminCreateCustomer } from "medusa-react"
type CustomerData = {
first_name: string
last_name: string
email: string
password: string
}
const CreateCustomer = () => {
const createCustomer = useAdminCreateCustomer()
// ...
const handleCreate = (customerData: CustomerData) => {
createCustomer.mutate(customerData, {
onSuccess: ({ customer }) => {
console.log(customer.id)
}
})
}
// ...
}
export default CreateCustomer
```
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostCustomersReq","type":"`AdminPostCustomersReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateCustomer"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminCustomersRes","type":"`AdminCustomersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateCustomer"/>
### useAdminUpdateCustomer
This hook updates a customer's details.
#### Example
```ts
import React from "react"
import { useAdminUpdateCustomer } from "medusa-react"
type CustomerData = {
first_name: string
last_name: string
email: string
password: string
}
type Props = {
customerId: string
}
const Customer = ({ customerId }: Props) => {
const updateCustomer = useAdminUpdateCustomer(customerId)
// ...
const handleUpdate = (customerData: CustomerData) => {
updateCustomer.mutate(customerData)
}
// ...
}
export default Customer
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The customer's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateCustomer"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostCustomersCustomerReq","type":"`AdminPostCustomersCustomerReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateCustomer"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminCustomersRes","type":"`AdminCustomersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateCustomer"/>
___
## Queries
### useAdminCustomers
This hook retrieves a list of Customers. The customers can be filtered by fields such as
`q` or `groups`. The customers can also be paginated.
#### Example
To list customers:
```tsx
import React from "react"
import { useAdminCustomers } from "medusa-react"
const Customers = () => {
const { customers, isLoading } = useAdminCustomers()
return (
<div>
{isLoading && <span>Loading...</span>}
{customers && !customers.length && (
<span>No customers</span>
)}
{customers && customers.length > 0 && (
<ul>
{customers.map((customer) => (
<li key={customer.id}>{customer.first_name}</li>
))}
</ul>
)}
</div>
)
}
export default Customers
```
You can specify relations to be retrieved within each customer. In addition, by default, only the first `50` records are retrieved.
You can control pagination by specifying the `limit` and `offset` properties:
```tsx
import React from "react"
import { useAdminCustomers } from "medusa-react"
const Customers = () => {
const {
customers,
limit,
offset,
isLoading
} = useAdminCustomers({
expand: "billing_address",
limit: 20,
offset: 0
})
return (
<div>
{isLoading && <span>Loading...</span>}
{customers && !customers.length && (
<span>No customers</span>
)}
{customers && customers.length > 0 && (
<ul>
{customers.map((customer) => (
<li key={customer.id}>{customer.first_name}</li>
))}
</ul>
)}
</div>
)
}
export default Customers
```
#### Hook Parameters
<TypeList types={[{"name":"query","type":"`AdminGetCustomersParams`","description":"Filters and pagination configurations to apply on the retrieved customers.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCustomers"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminCustomersListRes","type":"`AdminCustomersListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCustomers"/>
### useAdminCustomer
This hook retrieves the details of a customer.
#### Example
```ts
import React from "react"
import { useAdminCustomer } from "medusa-react"
type Props = {
customerId: string
}
const Customer = ({ customerId }: Props) => {
const { customer, isLoading } = useAdminCustomer(
customerId
)
return (
<div>
{isLoading && <span>Loading...</span>}
{customer && <span>{customer.first_name}</span>}
</div>
)
}
export default Customer
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The customer's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCustomer"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminCustomersRes","type":"`AdminCustomersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCustomer"/>

View File

@@ -1,898 +0,0 @@
---
slug: /references/medusa-react/hooks/admin/discounts
---
import { TypeList } from "docs-ui"
# Discounts
Queries and Mutations listed here are used to send requests to the [Admin Discount API Routes](https://docs.medusajs.com/api/admin#discounts).
All hooks listed require [authentication](../../../../modules/user/page.mdx).
Admins can create discounts with conditions and rules, providing them with advanced settings for variety of cases.
The methods in this class can be used to manage discounts, their conditions, resources, and more.
Related Guide: [How to manage discounts](https://docs.medusajs.com/modules/discounts/admin/manage-discounts).
## Mutations
### useAdminAddDiscountConditionResourceBatch
This hook adds a batch of resources to a discount condition. The type of resource depends on the type of discount condition.
For example, if the discount condition's type is `products`, the resources being added should be products.
#### Example
To add resources to a discount condition:
```tsx
import React from "react"
import {
useAdminAddDiscountConditionResourceBatch
} from "medusa-react"
type Props = {
discountId: string
conditionId: string
}
const DiscountCondition = ({
discountId,
conditionId
}: Props) => {
const addConditionResources = useAdminAddDiscountConditionResourceBatch(
discountId,
conditionId
)
// ...
const handleAdd = (itemId: string) => {
addConditionResources.mutate({
resources: [
{
id: itemId
}
]
}, {
onSuccess: ({ discount }) => {
console.log(discount.id)
}
})
}
// ...
}
export default DiscountCondition
```
To specify relations to include in the returned discount:
```tsx
import React from "react"
import {
useAdminAddDiscountConditionResourceBatch
} from "medusa-react"
type Props = {
discountId: string
conditionId: string
}
const DiscountCondition = ({
discountId,
conditionId
}: Props) => {
const addConditionResources = useAdminAddDiscountConditionResourceBatch(
discountId,
conditionId,
{
expand: "rule"
}
)
// ...
const handleAdd = (itemId: string) => {
addConditionResources.mutate({
resources: [
{
id: itemId
}
]
}, {
onSuccess: ({ discount }) => {
console.log(discount.id)
}
})
}
// ...
}
export default DiscountCondition
```
#### Hook Parameters
<TypeList types={[{"name":"discountId","type":"`string`","description":"The ID of the discount the condition belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"conditionId","type":"`string`","description":"The discount condition's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"`AdminPostDiscountsDiscountConditionsConditionBatchParams`","description":"Configurations to apply on the retrieved discount.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminAddDiscountConditionResourceBatch"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostDiscountsDiscountConditionsConditionBatchReq","type":"`AdminPostDiscountsDiscountConditionsConditionBatchReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminAddDiscountConditionResourceBatch"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminDiscountsRes","type":"`AdminDiscountsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminAddDiscountConditionResourceBatch"/>
### useAdminDeleteDiscountConditionResourceBatch
This hook remove a batch of resources from a discount condition. This will only remove the association between the resource and
the discount condition, not the resource itself.
#### Example
```ts
import React from "react"
import {
useAdminDeleteDiscountConditionResourceBatch
} from "medusa-react"
type Props = {
discountId: string
conditionId: string
}
const DiscountCondition = ({
discountId,
conditionId
}: Props) => {
const deleteConditionResource = useAdminDeleteDiscountConditionResourceBatch(
discountId,
conditionId,
)
// ...
const handleDelete = (itemId: string) => {
deleteConditionResource.mutate({
resources: [
{
id: itemId
}
]
}, {
onSuccess: ({ discount }) => {
console.log(discount.id)
}
})
}
// ...
}
export default DiscountCondition
```
#### Hook Parameters
<TypeList types={[{"name":"discountId","type":"`string`","description":"The ID of the discount the condition belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"conditionId","type":"`string`","description":"The discount condition's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteDiscountConditionResourceBatch"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminDeleteDiscountsDiscountConditionsConditionBatchReq","type":"`AdminDeleteDiscountsDiscountConditionsConditionBatchReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteDiscountConditionResourceBatch"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminDiscountsRes","type":"`AdminDiscountsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteDiscountConditionResourceBatch"/>
### useAdminCreateDiscount
This hook creates a discount with a given set of rules that defines how the discount is applied.
#### Example
```ts
import React from "react"
import {
useAdminCreateDiscount,
} from "medusa-react"
import {
AllocationType,
DiscountRuleType,
} from "@medusajs/medusa"
const CreateDiscount = () => {
const createDiscount = useAdminCreateDiscount()
// ...
const handleCreate = (
currencyCode: string,
regionId: string
) => {
// ...
createDiscount.mutate({
code: currencyCode,
rule: {
type: DiscountRuleType.FIXED,
value: 10,
allocation: AllocationType.ITEM,
},
regions: [
regionId,
],
is_dynamic: false,
is_disabled: false,
})
}
// ...
}
export default CreateDiscount
```
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostDiscountsReq","type":"`AdminPostDiscountsReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateDiscount"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminDiscountsRes","type":"`AdminDiscountsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateDiscount"/>
### useAdminUpdateDiscount
This hook updates a discount with a given set of rules that define how the discount is applied.
#### Example
```ts
import React from "react"
import { useAdminUpdateDiscount } from "medusa-react"
type Props = {
discountId: string
}
const Discount = ({ discountId }: Props) => {
const updateDiscount = useAdminUpdateDiscount(discountId)
// ...
const handleUpdate = (isDisabled: boolean) => {
updateDiscount.mutate({
is_disabled: isDisabled,
})
}
// ...
}
export default Discount
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateDiscount"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostDiscountsDiscountReq","type":"`AdminPostDiscountsDiscountReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateDiscount"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminDiscountsRes","type":"`AdminDiscountsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateDiscount"/>
### useAdminDeleteDiscount
This hook deletes a discount. Deleting the discount will make it unavailable for customers to use.
#### Example
```ts
import React from "react"
import { useAdminDeleteDiscount } from "medusa-react"
const Discount = () => {
const deleteDiscount = useAdminDeleteDiscount(discount_id)
// ...
const handleDelete = () => {
deleteDiscount.mutate()
}
// ...
}
export default Discount
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteDiscount"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteDiscount"/>
### useAdminDiscountAddRegion
This hook adds a Region to the list of Regions a Discount can be used in.
#### Example
```ts
import React from "react"
import { useAdminDiscountAddRegion } from "medusa-react"
type Props = {
discountId: string
}
const Discount = ({ discountId }: Props) => {
const addRegion = useAdminDiscountAddRegion(discountId)
// ...
const handleAdd = (regionId: string) => {
addRegion.mutate(regionId, {
onSuccess: ({ discount }) => {
console.log(discount.regions)
}
})
}
// ...
}
export default Discount
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDiscountAddRegion"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"string","type":"`string`","optional":false,"defaultValue":"","description":"The ID of the region to add.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDiscountAddRegion"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminDiscountsRes","type":"`AdminDiscountsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDiscountAddRegion"/>
### useAdminDiscountRemoveRegion
This hook removes a Region from the list of Regions that a Discount can be used in.
This does not delete a region, only the association between it and the discount.
#### Example
```ts
import React from "react"
import { useAdminDiscountRemoveRegion } from "medusa-react"
type Props = {
discountId: string
}
const Discount = ({ discountId }: Props) => {
const deleteRegion = useAdminDiscountRemoveRegion(discountId)
// ...
const handleDelete = (regionId: string) => {
deleteRegion.mutate(regionId, {
onSuccess: ({ discount }) => {
console.log(discount.regions)
}
})
}
// ...
}
export default Discount
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDiscountRemoveRegion"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"string","type":"`string`","optional":false,"defaultValue":"","description":"The ID of the region to remove.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDiscountRemoveRegion"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminDiscountsRes","type":"`AdminDiscountsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDiscountRemoveRegion"/>
### useAdminCreateDynamicDiscountCode
This hook creates a dynamic unique code that can map to a parent discount. This is useful if you want to
automatically generate codes with the same rules and conditions.
#### Example
```ts
import React from "react"
import { useAdminCreateDynamicDiscountCode } from "medusa-react"
type Props = {
discountId: string
}
const Discount = ({ discountId }: Props) => {
const createDynamicDiscount = useAdminCreateDynamicDiscountCode(discountId)
// ...
const handleCreate = (
code: string,
usageLimit: number
) => {
createDynamicDiscount.mutate({
code,
usage_limit: usageLimit
}, {
onSuccess: ({ discount }) => {
console.log(discount.is_dynamic)
}
})
}
// ...
}
export default Discount
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateDynamicDiscountCode"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostDiscountsDiscountDynamicCodesReq","type":"`AdminPostDiscountsDiscountDynamicCodesReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateDynamicDiscountCode"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminDiscountsRes","type":"`AdminDiscountsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateDynamicDiscountCode"/>
### useAdminDeleteDynamicDiscountCode
This hook deletes a dynamic code from a discount.
#### Example
```ts
import React from "react"
import { useAdminDeleteDynamicDiscountCode } from "medusa-react"
type Props = {
discountId: string
}
const Discount = ({ discountId }: Props) => {
const deleteDynamicDiscount = useAdminDeleteDynamicDiscountCode(discountId)
// ...
const handleDelete = (code: string) => {
deleteDynamicDiscount.mutate(code, {
onSuccess: ({ discount }) => {
console.log(discount.is_dynamic)
}
})
}
// ...
}
export default Discount
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteDynamicDiscountCode"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"string","type":"`string`","optional":false,"defaultValue":"","description":"The code of the dynamic discount to delete.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteDynamicDiscountCode"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminDiscountsRes","type":"`AdminDiscountsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteDynamicDiscountCode"/>
### useAdminDiscountCreateCondition
This hook creates a discount condition. Only one of `products`, `product_types`, `product_collections`, `product_tags`, and `customer_groups`
should be provided in the `payload` parameter, based on the type of discount condition. For example, if the discount condition's type is `products`,
the `products` field should be provided in the `payload` parameter.
#### Example
```ts
import React from "react"
import { DiscountConditionOperator } from "@medusajs/medusa"
import { useAdminDiscountCreateCondition } from "medusa-react"
type Props = {
discountId: string
}
const Discount = ({ discountId }: Props) => {
const createCondition = useAdminDiscountCreateCondition(discountId)
// ...
const handleCreateCondition = (
operator: DiscountConditionOperator,
products: string[]
) => {
createCondition.mutate({
operator,
products
}, {
onSuccess: ({ discount }) => {
console.log(discount.id)
}
})
}
// ...
}
export default Discount
```
#### Hook Parameters
<TypeList types={[{"name":"discountId","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDiscountCreateCondition"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostDiscountsDiscountConditions","type":"`AdminPostDiscountsDiscountConditions`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDiscountCreateCondition"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminDiscountsRes","type":"`AdminDiscountsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDiscountCreateCondition"/>
### useAdminDiscountUpdateCondition
Update a discount condition. Only one of `products`, `product_types`, `product_collections`, `product_tags`, and `customer_groups`
should be provided in the `payload` parameter, based on the type of discount condition. For example, if the discount condition's
type is `products`, the `products` field should be provided in the `payload` parameter.
#### Example
```ts
import React from "react"
import { useAdminDiscountUpdateCondition } from "medusa-react"
type Props = {
discountId: string
conditionId: string
}
const DiscountCondition = ({
discountId,
conditionId
}: Props) => {
const update = useAdminDiscountUpdateCondition(
discountId,
conditionId
)
// ...
const handleUpdate = (
products: string[]
) => {
update.mutate({
products
}, {
onSuccess: ({ discount }) => {
console.log(discount.id)
}
})
}
// ...
}
export default DiscountCondition
```
#### Hook Parameters
<TypeList types={[{"name":"discountId","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"conditionId","type":"`string`","description":"The discount condition's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDiscountUpdateCondition"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostDiscountsDiscountConditionsCondition","type":"`AdminPostDiscountsDiscountConditionsCondition`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDiscountUpdateCondition"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminDiscountsRes","type":"`AdminDiscountsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDiscountUpdateCondition"/>
### useAdminDiscountRemoveCondition
This hook deletes a discount condition. This doesn't delete resources associated to the discount condition.
#### Example
```ts
import React from "react"
import { useAdminDiscountRemoveCondition } from "medusa-react"
type Props = {
discountId: string
}
const Discount = ({ discountId }: Props) => {
const deleteCondition = useAdminDiscountRemoveCondition(
discountId
)
// ...
const handleDelete = (
conditionId: string
) => {
deleteCondition.mutate(conditionId, {
onSuccess: ({ id, object, deleted }) => {
console.log(deleted)
}
})
}
// ...
}
export default Discount
```
#### Hook Parameters
<TypeList types={[{"name":"discountId","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDiscountRemoveCondition"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"string","type":"`string`","optional":false,"defaultValue":"","description":"The ID of the condition to delete.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDiscountRemoveCondition"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDiscountRemoveCondition"/>
___
## Queries
### useAdminDiscounts
This hook retrieves a list of Discounts. The discounts can be filtered by fields such as `rule` or `is_dynamic`.
The discounts can also be paginated.
#### Example
To list discounts:
```tsx
import React from "react"
import { useAdminDiscounts } from "medusa-react"
const Discounts = () => {
const { discounts, isLoading } = useAdminDiscounts()
return (
<div>
{isLoading && <span>Loading...</span>}
{discounts && !discounts.length && (
<span>No customers</span>
)}
{discounts && discounts.length > 0 && (
<ul>
{discounts.map((discount) => (
<li key={discount.id}>{discount.code}</li>
))}
</ul>
)}
</div>
)
}
export default Discounts
```
To specify relations that should be retrieved within the discounts:
```tsx
import React from "react"
import { useAdminDiscounts } from "medusa-react"
const Discounts = () => {
const { discounts, isLoading } = useAdminDiscounts({
expand: "rule"
})
return (
<div>
{isLoading && <span>Loading...</span>}
{discounts && !discounts.length && (
<span>No customers</span>
)}
{discounts && discounts.length > 0 && (
<ul>
{discounts.map((discount) => (
<li key={discount.id}>{discount.code}</li>
))}
</ul>
)}
</div>
)
}
export default Discounts
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```tsx
import React from "react"
import { useAdminDiscounts } from "medusa-react"
const Discounts = () => {
const {
discounts,
limit,
offset,
isLoading
} = useAdminDiscounts({
expand: "rule",
limit: 10,
offset: 0
})
return (
<div>
{isLoading && <span>Loading...</span>}
{discounts && !discounts.length && (
<span>No customers</span>
)}
{discounts && discounts.length > 0 && (
<ul>
{discounts.map((discount) => (
<li key={discount.id}>{discount.code}</li>
))}
</ul>
)}
</div>
)
}
export default Discounts
```
#### Hook Parameters
<TypeList types={[{"name":"query","type":"`AdminGetDiscountsParams`","description":"Filters and pagination configurations to apply on the retrieved discounts.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDiscounts"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminDiscountsListRes","type":"`AdminDiscountsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDiscounts"/>
### useAdminDiscount
This hook retrieves a discount.
#### Example
```ts
import React from "react"
import { useAdminDiscount } from "medusa-react"
type Props = {
discountId: string
}
const Discount = ({ discountId }: Props) => {
const { discount, isLoading } = useAdminDiscount(
discountId
)
return (
<div>
{isLoading && <span>Loading...</span>}
{discount && <span>{discount.code}</span>}
</div>
)
}
export default Discount
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The discount's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"`AdminGetDiscountParams`","description":"Configurations to apply on the retrieved discount.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDiscount"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminDiscountsRes","type":"`AdminDiscountsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDiscount"/>
### useAdminGetDiscountByCode
This hook adds a batch of resources to a discount condition. The type of resource depends on the type of discount condition. For example, if the discount condition's type is `products`,
the resources being added should be products.
#### Example
```ts
import React from "react"
import { useAdminGetDiscountByCode } from "medusa-react"
type Props = {
discountCode: string
}
const Discount = ({ discountCode }: Props) => {
const { discount, isLoading } = useAdminGetDiscountByCode(
discountCode
)
return (
<div>
{isLoading && <span>Loading...</span>}
{discount && <span>{discount.code}</span>}
</div>
)
}
export default Discount
```
#### Hook Parameters
<TypeList types={[{"name":"code","type":"`string`","description":"The code of the discount.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminGetDiscountByCode"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminDiscountsRes","type":"`AdminDiscountsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminGetDiscountByCode"/>
### useAdminGetDiscountCondition
This hook retries a Discount Condition's details.
#### Example
```ts
import React from "react"
import { useAdminGetDiscountCondition } from "medusa-react"
type Props = {
discountId: string
discountConditionId: string
}
const DiscountCondition = ({
discountId,
discountConditionId
}: Props) => {
const {
discount_condition,
isLoading
} = useAdminGetDiscountCondition(
discountId,
discountConditionId
)
return (
<div>
{isLoading && <span>Loading...</span>}
{discount_condition && (
<span>{discount_condition.type}</span>
)}
</div>
)
}
export default DiscountCondition
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the discount the condition belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"conditionId","type":"`string`","description":"The discount condition's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"`AdminGetDiscountsDiscountConditionsConditionParams`","description":"Configurations to apply on the retrieved discount condition.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminGetDiscountCondition"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminDiscountConditionsRes","type":"`AdminDiscountConditionsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminGetDiscountCondition"/>

View File

@@ -1,465 +0,0 @@
---
slug: /references/medusa-react/hooks/admin/draft_orders
---
import { TypeList } from "docs-ui"
# Draft Orders
Queries and Mutations listed here are used to send requests to the [Admin Draft Order API Routes](https://docs.medusajs.com/api/admin#draft-orders).
All hooks listed require [authentication](../../../../modules/user/page.mdx).
A draft order is an order created manually by the admin. It allows admins to create orders without direct involvement from the customer.
Related Guide: [How to manage draft orders](https://docs.medusajs.com/modules/orders/admin/manage-draft-orders).
## Mutations
### useAdminCreateDraftOrder
This hook creates a Draft Order. A draft order is not transformed into an order until payment is captured.
#### Example
```ts
import React from "react"
import { useAdminCreateDraftOrder } from "medusa-react"
type DraftOrderData = {
email: string
region_id: string
items: {
quantity: number,
variant_id: string
}[]
shipping_methods: {
option_id: string
price: number
}[]
}
const CreateDraftOrder = () => {
const createDraftOrder = useAdminCreateDraftOrder()
// ...
const handleCreate = (data: DraftOrderData) => {
createDraftOrder.mutate(data, {
onSuccess: ({ draft_order }) => {
console.log(draft_order.id)
}
})
}
// ...
}
export default CreateDraftOrder
```
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostDraftOrdersReq","type":"`AdminPostDraftOrdersReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateDraftOrder"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminDraftOrdersRes","type":"`AdminDraftOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateDraftOrder"/>
### useAdminUpdateDraftOrder
This hook updates a Draft Order's details.
#### Example
```ts
import React from "react"
import { useAdminUpdateDraftOrder } from "medusa-react"
type Props = {
draftOrderId: string
}
const DraftOrder = ({ draftOrderId }: Props) => {
const updateDraftOrder = useAdminUpdateDraftOrder(
draftOrderId
)
// ...
const handleUpdate = (email: string) => {
updateDraftOrder.mutate({
email,
}, {
onSuccess: ({ draft_order }) => {
console.log(draft_order.id)
}
})
}
// ...
}
export default DraftOrder
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The draft order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateDraftOrder"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostDraftOrdersDraftOrderReq","type":"`AdminPostDraftOrdersDraftOrderReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateDraftOrder"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminDraftOrdersRes","type":"`AdminDraftOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateDraftOrder"/>
### useAdminDeleteDraftOrder
This hook deletes a Draft Order.
#### Example
```ts
import React from "react"
import { useAdminDeleteDraftOrder } from "medusa-react"
type Props = {
draftOrderId: string
}
const DraftOrder = ({ draftOrderId }: Props) => {
const deleteDraftOrder = useAdminDeleteDraftOrder(
draftOrderId
)
// ...
const handleDelete = () => {
deleteDraftOrder.mutate(void 0, {
onSuccess: ({ id, object, deleted }) => {
console.log(id)
}
})
}
// ...
}
export default DraftOrder
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The draft order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteDraftOrder"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteDraftOrder"/>
### useAdminDraftOrderRegisterPayment
This hook capture the draft order's payment. This will also set the draft order's status to `completed` and create an order from the draft order. The payment is captured through Medusa's system payment,
which is manual payment that isn't integrated with any third-party payment provider. It is assumed that the payment capturing is handled manually by the admin.
#### Example
```ts
import React from "react"
import { useAdminDraftOrderRegisterPayment } from "medusa-react"
type Props = {
draftOrderId: string
}
const DraftOrder = ({ draftOrderId }: Props) => {
const registerPayment = useAdminDraftOrderRegisterPayment(
draftOrderId
)
// ...
const handlePayment = () => {
registerPayment.mutate(void 0, {
onSuccess: ({ order }) => {
console.log(order.id)
}
})
}
// ...
}
export default DraftOrder
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The draft order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDraftOrderRegisterPayment"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminPostDraftOrdersDraftOrderRegisterPaymentRes","type":"`AdminPostDraftOrdersDraftOrderRegisterPaymentRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDraftOrderRegisterPayment"/>
### useAdminDraftOrderAddLineItem
This hook creates a Line Item in the Draft Order.
#### Example
```ts
import React from "react"
import { useAdminDraftOrderAddLineItem } from "medusa-react"
type Props = {
draftOrderId: string
}
const DraftOrder = ({ draftOrderId }: Props) => {
const addLineItem = useAdminDraftOrderAddLineItem(
draftOrderId
)
// ...
const handleAdd = (quantity: number) => {
addLineItem.mutate({
quantity,
}, {
onSuccess: ({ draft_order }) => {
console.log(draft_order.cart)
}
})
}
// ...
}
export default DraftOrder
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The draft order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDraftOrderAddLineItem"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostDraftOrdersDraftOrderLineItemsReq","type":"`AdminPostDraftOrdersDraftOrderLineItemsReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDraftOrderAddLineItem"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminDraftOrdersRes","type":"`AdminDraftOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDraftOrderAddLineItem"/>
### useAdminDraftOrderRemoveLineItem
This hook deletes a Line Item from a Draft Order.
#### Example
```ts
import React from "react"
import { useAdminDraftOrderRemoveLineItem } from "medusa-react"
type Props = {
draftOrderId: string
}
const DraftOrder = ({ draftOrderId }: Props) => {
const deleteLineItem = useAdminDraftOrderRemoveLineItem(
draftOrderId
)
// ...
const handleDelete = (itemId: string) => {
deleteLineItem.mutate(itemId, {
onSuccess: ({ draft_order }) => {
console.log(draft_order.cart)
}
})
}
// ...
}
export default DraftOrder
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The draft order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDraftOrderRemoveLineItem"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"string","type":"`string`","optional":false,"defaultValue":"","description":"The ID of the line item to remove.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDraftOrderRemoveLineItem"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminDraftOrdersRes","type":"`AdminDraftOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDraftOrderRemoveLineItem"/>
### useAdminDraftOrderUpdateLineItem
This hook updates a Line Item in a Draft Order.
#### Example
```ts
import React from "react"
import { useAdminDraftOrderUpdateLineItem } from "medusa-react"
type Props = {
draftOrderId: string
}
const DraftOrder = ({ draftOrderId }: Props) => {
const updateLineItem = useAdminDraftOrderUpdateLineItem(
draftOrderId
)
// ...
const handleUpdate = (
itemId: string,
quantity: number
) => {
updateLineItem.mutate({
item_id: itemId,
quantity,
})
}
// ...
}
export default DraftOrder
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The draft order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDraftOrderUpdateLineItem"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminDraftOrderUpdateLineItemReq","type":"[AdminDraftOrderUpdateLineItemReq](../../../types/medusa_react.AdminDraftOrderUpdateLineItemReq/page.mdx)","optional":false,"defaultValue":"","description":"The details to update of the line item.","expandable":false,"children":[{"name":"item_id","type":"`string`","description":"The line item's ID to update.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDraftOrderUpdateLineItem"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminDraftOrdersRes","type":"`AdminDraftOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDraftOrderUpdateLineItem"/>
___
## Queries
### useAdminDraftOrders
This hook retrieves an list of Draft Orders. The draft orders can be filtered by parameters such as `query`. The draft orders can also paginated.
#### Example
To list draft orders:
```tsx
import React from "react"
import { useAdminDraftOrders } from "medusa-react"
const DraftOrders = () => {
const { draft_orders, isLoading } = useAdminDraftOrders()
return (
<div>
{isLoading && <span>Loading...</span>}
{draft_orders && !draft_orders.length && (
<span>No Draft Orders</span>
)}
{draft_orders && draft_orders.length > 0 && (
<ul>
{draft_orders.map((order) => (
<li key={order.id}>{order.display_id}</li>
))}
</ul>
)}
</div>
)
}
export default DraftOrders
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```tsx
import React from "react"
import { useAdminDraftOrders } from "medusa-react"
const DraftOrders = () => {
const {
draft_orders,
limit,
offset,
isLoading
} = useAdminDraftOrders({
limit: 20,
offset: 0
})
return (
<div>
{isLoading && <span>Loading...</span>}
{draft_orders && !draft_orders.length && (
<span>No Draft Orders</span>
)}
{draft_orders && draft_orders.length > 0 && (
<ul>
{draft_orders.map((order) => (
<li key={order.id}>{order.display_id}</li>
))}
</ul>
)}
</div>
)
}
export default DraftOrders
```
#### Hook Parameters
<TypeList types={[{"name":"query","type":"`AdminGetDraftOrdersParams`","description":"Filters and pagination configurations to apply on the retrieved draft orders.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDraftOrders"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminDraftOrdersListRes","type":"`AdminDraftOrdersListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDraftOrders"/>
### useAdminDraftOrder
This hook retrieves a Draft Order's details.
#### Example
```ts
import React from "react"
import { useAdminDraftOrder } from "medusa-react"
type Props = {
draftOrderId: string
}
const DraftOrder = ({ draftOrderId }: Props) => {
const {
draft_order,
isLoading,
} = useAdminDraftOrder(draftOrderId)
return (
<div>
{isLoading && <span>Loading...</span>}
{draft_order && <span>{draft_order.display_id}</span>}
</div>
)
}
export default DraftOrder
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The draft order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDraftOrder"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminDraftOrdersRes","type":"`AdminDraftOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDraftOrder"/>

View File

@@ -1,271 +0,0 @@
---
slug: /references/medusa-react/hooks/admin/gift_cards
---
import { TypeList } from "docs-ui"
# Gift Cards
Queries and Mutations listed here are used to send requests to the [Admin Gift Card API Routes](https://docs.medusajs.com/api/admin#gift-cards).
All hooks listed require [authentication](../../../../modules/user/page.mdx).
Admins can create gift cards and send them directly to customers, specifying options like their balance, region, and more.
These gift cards are different than the saleable gift cards in a store, which are created and managed through [useAdminCreateProduct](../medusa_react.Hooks.Admin.Products/page.mdx#useadmincreateproduct).
Related Guide: [How to manage gift cards](https://docs.medusajs.com/modules/gift-cards/admin/manage-gift-cards#manage-custom-gift-cards).
## Mutations
### useAdminCreateGiftCard
This hook creates a gift card that can redeemed by its unique code. The Gift Card is only valid within one region.
#### Example
```ts
import React from "react"
import { useAdminCreateGiftCard } from "medusa-react"
const CreateCustomGiftCards = () => {
const createGiftCard = useAdminCreateGiftCard()
// ...
const handleCreate = (
regionId: string,
value: number
) => {
createGiftCard.mutate({
region_id: regionId,
value,
}, {
onSuccess: ({ gift_card }) => {
console.log(gift_card.id)
}
})
}
// ...
}
export default CreateCustomGiftCards
```
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostGiftCardsReq","type":"`AdminPostGiftCardsReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateGiftCard"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminGiftCardsRes","type":"`AdminGiftCardsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateGiftCard"/>
### useAdminUpdateGiftCard
This hook updates a gift card's details.
#### Example
```ts
import React from "react"
import { useAdminUpdateGiftCard } from "medusa-react"
type Props = {
customGiftCardId: string
}
const CustomGiftCard = ({ customGiftCardId }: Props) => {
const updateGiftCard = useAdminUpdateGiftCard(
customGiftCardId
)
// ...
const handleUpdate = (regionId: string) => {
updateGiftCard.mutate({
region_id: regionId,
}, {
onSuccess: ({ gift_card }) => {
console.log(gift_card.id)
}
})
}
// ...
}
export default CustomGiftCard
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The gift card's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateGiftCard"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostGiftCardsGiftCardReq","type":"`AdminPostGiftCardsGiftCardReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateGiftCard"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminGiftCardsRes","type":"`AdminGiftCardsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateGiftCard"/>
### useAdminDeleteGiftCard
This hook deletes a gift card. Once deleted, it can't be used by customers.
#### Example
```ts
import React from "react"
import { useAdminDeleteGiftCard } from "medusa-react"
type Props = {
customGiftCardId: string
}
const CustomGiftCard = ({ customGiftCardId }: Props) => {
const deleteGiftCard = useAdminDeleteGiftCard(
customGiftCardId
)
// ...
const handleDelete = () => {
deleteGiftCard.mutate(void 0, {
onSuccess: ({ id, object, deleted}) => {
console.log(id)
}
})
}
// ...
}
export default CustomGiftCard
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The gift card's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteGiftCard"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteGiftCard"/>
___
## Queries
### useAdminGiftCards
This hook retrieves a list of gift cards. The gift cards can be filtered by fields such as `q` passed in the `query`
parameter. The gift cards can also paginated.
#### Example
To list gift cards:
```tsx
import React from "react"
import { useAdminGiftCards } from "medusa-react"
const CustomGiftCards = () => {
const { gift_cards, isLoading } = useAdminGiftCards()
return (
<div>
{isLoading && <span>Loading...</span>}
{gift_cards && !gift_cards.length && (
<span>No custom gift cards...</span>
)}
{gift_cards && gift_cards.length > 0 && (
<ul>
{gift_cards.map((giftCard) => (
<li key={giftCard.id}>{giftCard.code}</li>
))}
</ul>
)}
</div>
)
}
export default CustomGiftCards
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```tsx
import React from "react"
import { useAdminGiftCards } from "medusa-react"
const CustomGiftCards = () => {
const {
gift_cards,
limit,
offset,
isLoading
} = useAdminGiftCards({
limit: 20,
offset: 0
})
return (
<div>
{isLoading && <span>Loading...</span>}
{gift_cards && !gift_cards.length && (
<span>No custom gift cards...</span>
)}
{gift_cards && gift_cards.length > 0 && (
<ul>
{gift_cards.map((giftCard) => (
<li key={giftCard.id}>{giftCard.code}</li>
))}
</ul>
)}
</div>
)
}
export default CustomGiftCards
```
#### Hook Parameters
<TypeList types={[{"name":"query","type":"`AdminGetGiftCardsParams`","description":"Filters and pagination configurations to apply on the retrieved gift cards.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminGiftCards"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminGiftCardsListRes","type":"`AdminGiftCardsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminGiftCards"/>
### useAdminGiftCard
This hook retrieves a gift card's details.
#### Example
```ts
import React from "react"
import { useAdminGiftCard } from "medusa-react"
type Props = {
giftCardId: string
}
const CustomGiftCard = ({ giftCardId }: Props) => {
const { gift_card, isLoading } = useAdminGiftCard(giftCardId)
return (
<div>
{isLoading && <span>Loading...</span>}
{gift_card && <span>{gift_card.code}</span>}
</div>
)
}
export default CustomGiftCard
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The gift card's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminGiftCard"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminGiftCardsRes","type":"`AdminGiftCardsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminGiftCard"/>

View File

@@ -1,473 +0,0 @@
---
slug: /references/medusa-react/hooks/admin/inventory_items
---
import { TypeList } from "docs-ui"
# Inventory Items
Queries and Mutations listed here are used to send requests to the [Admin Inventory Item API Routes](https://docs.medusajs.com/api/admin#inventory-items).
To use these hooks, make sure to install the
[@medusajs/inventory](https://docs.medusajs.com/modules/multiwarehouse/install-modules#inventory-module) module in your Medusa backend.
All hooks listed require [authentication](../../../../modules/user/page.mdx).
Inventory items, provided by the [Inventory Module](https://docs.medusajs.com/modules/multiwarehouse/inventory-module), can be
used to manage the inventory of saleable items in your store.
Related Guide: [How to manage inventory items](https://docs.medusajs.com/modules/multiwarehouse/admin/manage-inventory-items).
## Mutations
### useAdminCreateInventoryItem
This hook creates an Inventory Item for a product variant.
#### Example
```ts
import React from "react"
import { useAdminCreateInventoryItem } from "medusa-react"
const CreateInventoryItem = () => {
const createInventoryItem = useAdminCreateInventoryItem()
// ...
const handleCreate = (variantId: string) => {
createInventoryItem.mutate({
variant_id: variantId,
}, {
onSuccess: ({ inventory_item }) => {
console.log(inventory_item.id)
}
})
}
// ...
}
export default CreateInventoryItem
```
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostInventoryItemsReq","type":"`AdminPostInventoryItemsReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateInventoryItem"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminInventoryItemsRes","type":"`AdminInventoryItemsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateInventoryItem"/>
### useAdminUpdateInventoryItem
This hook updates an Inventory Item's details.
#### Example
```ts
import React from "react"
import { useAdminUpdateInventoryItem } from "medusa-react"
type Props = {
inventoryItemId: string
}
const InventoryItem = ({ inventoryItemId }: Props) => {
const updateInventoryItem = useAdminUpdateInventoryItem(
inventoryItemId
)
// ...
const handleUpdate = (origin_country: string) => {
updateInventoryItem.mutate({
origin_country,
}, {
onSuccess: ({ inventory_item }) => {
console.log(inventory_item.origin_country)
}
})
}
// ...
}
export default InventoryItem
```
#### Hook Parameters
<TypeList types={[{"name":"inventoryItemId","type":"`string`","description":"The inventory item's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateInventoryItem"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostInventoryItemsInventoryItemReq","type":"`AdminPostInventoryItemsInventoryItemReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateInventoryItem"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminInventoryItemsRes","type":"`AdminInventoryItemsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateInventoryItem"/>
### useAdminDeleteInventoryItem
This hook deletes an Inventory Item. This does not delete the associated product variant.
#### Example
```ts
import React from "react"
import { useAdminDeleteInventoryItem } from "medusa-react"
type Props = {
inventoryItemId: string
}
const InventoryItem = ({ inventoryItemId }: Props) => {
const deleteInventoryItem = useAdminDeleteInventoryItem(
inventoryItemId
)
// ...
const handleDelete = () => {
deleteInventoryItem.mutate()
}
// ...
}
export default InventoryItem
```
#### Hook Parameters
<TypeList types={[{"name":"inventoryItemId","type":"`string`","description":"The inventory item's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteInventoryItem"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteInventoryItem"/>
### useAdminUpdateLocationLevel
This hook updates a location level's details for a given inventory item.
#### Example
```ts
import React from "react"
import { useAdminUpdateLocationLevel } from "medusa-react"
type Props = {
inventoryItemId: string
}
const InventoryItem = ({ inventoryItemId }: Props) => {
const updateLocationLevel = useAdminUpdateLocationLevel(
inventoryItemId
)
// ...
const handleUpdate = (
stockLocationId: string,
stockedQuantity: number
) => {
updateLocationLevel.mutate({
stockLocationId,
stocked_quantity: stockedQuantity,
}, {
onSuccess: ({ inventory_item }) => {
console.log(inventory_item.id)
}
})
}
// ...
}
export default InventoryItem
```
#### Hook Parameters
<TypeList types={[{"name":"inventoryItemId","type":"`string`","description":"The inventory item's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateLocationLevel"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminUpdateLocationLevelReq","type":"[AdminUpdateLocationLevelReq](../../../types/medusa_react.AdminUpdateLocationLevelReq/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"stockLocationId","type":"`string`","description":"The ID of the location level to update.","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateLocationLevel"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminInventoryItemsRes","type":"`AdminInventoryItemsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateLocationLevel"/>
### useAdminDeleteLocationLevel
This hook deletes a location level of an Inventory Item.
#### Example
```ts
import React from "react"
import { useAdminDeleteLocationLevel } from "medusa-react"
type Props = {
inventoryItemId: string
}
const InventoryItem = ({ inventoryItemId }: Props) => {
const deleteLocationLevel = useAdminDeleteLocationLevel(
inventoryItemId
)
// ...
const handleDelete = (
locationId: string
) => {
deleteLocationLevel.mutate(locationId)
}
// ...
}
export default InventoryItem
```
#### Hook Parameters
<TypeList types={[{"name":"inventoryItemId","type":"`string`","description":"The inventory item's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteLocationLevel"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"string","type":"`string`","optional":false,"defaultValue":"","description":"The ID of the location level to delete.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteLocationLevel"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminInventoryItemsRes","type":"`AdminInventoryItemsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteLocationLevel"/>
### useAdminCreateLocationLevel
This hook creates a Location Level for a given Inventory Item.
#### Example
```ts
import React from "react"
import { useAdminCreateLocationLevel } from "medusa-react"
type Props = {
inventoryItemId: string
}
const InventoryItem = ({ inventoryItemId }: Props) => {
const createLocationLevel = useAdminCreateLocationLevel(
inventoryItemId
)
// ...
const handleCreateLocationLevel = (
locationId: string,
stockedQuantity: number
) => {
createLocationLevel.mutate({
location_id: locationId,
stocked_quantity: stockedQuantity,
}, {
onSuccess: ({ inventory_item }) => {
console.log(inventory_item.id)
}
})
}
// ...
}
export default InventoryItem
```
#### Hook Parameters
<TypeList types={[{"name":"inventoryItemId","type":"`string`","description":"The inventory item's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateLocationLevel"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostInventoryItemsItemLocationLevelsReq","type":"`AdminPostInventoryItemsItemLocationLevelsReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateLocationLevel"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminInventoryItemsRes","type":"`AdminInventoryItemsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateLocationLevel"/>
___
## Queries
### useAdminInventoryItems
This hook retrieves a list of inventory items. The inventory items can be filtered by fields such as `q` or `location_id` passed in the `query` parameter.
The inventory items can also be paginated.
#### Example
To list inventory items:
```tsx
import React from "react"
import { useAdminInventoryItems } from "medusa-react"
function InventoryItems() {
const {
inventory_items,
isLoading
} = useAdminInventoryItems()
return (
<div>
{isLoading && <span>Loading...</span>}
{inventory_items && !inventory_items.length && (
<span>No Items</span>
)}
{inventory_items && inventory_items.length > 0 && (
<ul>
{inventory_items.map(
(item) => (
<li key={item.id}>{item.id}</li>
)
)}
</ul>
)}
</div>
)
}
export default InventoryItems
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```tsx
import React from "react"
import { useAdminInventoryItems } from "medusa-react"
function InventoryItems() {
const {
inventory_items,
limit,
offset,
isLoading
} = useAdminInventoryItems({
limit: 10,
offset: 0
})
return (
<div>
{isLoading && <span>Loading...</span>}
{inventory_items && !inventory_items.length && (
<span>No Items</span>
)}
{inventory_items && inventory_items.length > 0 && (
<ul>
{inventory_items.map(
(item) => (
<li key={item.id}>{item.id}</li>
)
)}
</ul>
)}
</div>
)
}
export default InventoryItems
```
#### Hook Parameters
<TypeList types={[{"name":"query","type":"`AdminGetInventoryItemsParams`","description":"Filters and pagination configurations applied on the retrieved inventory items.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminInventoryItems"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminInventoryItemsListWithVariantsAndLocationLevelsRes","type":"`AdminInventoryItemsListWithVariantsAndLocationLevelsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminInventoryItems"/>
### useAdminInventoryItem
This hook retrieves an Inventory Item's details.
#### Example
```ts
import React from "react"
import { useAdminInventoryItem } from "medusa-react"
type Props = {
inventoryItemId: string
}
const InventoryItem = ({ inventoryItemId }: Props) => {
const {
inventory_item,
isLoading
} = useAdminInventoryItem(inventoryItemId)
return (
<div>
{isLoading && <span>Loading...</span>}
{inventory_item && (
<span>{inventory_item.sku}</span>
)}
</div>
)
}
export default InventoryItem
```
#### Hook Parameters
<TypeList types={[{"name":"inventoryItemId","type":"`string`","description":"The inventory item's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"`AdminGetStockLocationsParams`","description":"Configurations applied on the retrieved inventory item.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminInventoryItem"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminInventoryItemsRes","type":"`AdminInventoryItemsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminInventoryItem"/>
### useAdminInventoryItemLocationLevels
This hook retrieves a list of inventory levels of an inventory item. The inventory levels can be filtered by fields
such as `location_id` passed in the `query` parameter.
#### Example
```ts
import React from "react"
import {
useAdminInventoryItemLocationLevels,
} from "medusa-react"
type Props = {
inventoryItemId: string
}
const InventoryItem = ({ inventoryItemId }: Props) => {
const {
inventory_item,
isLoading,
} = useAdminInventoryItemLocationLevels(inventoryItemId)
return (
<div>
{isLoading && <span>Loading...</span>}
{inventory_item && (
<ul>
{inventory_item.location_levels.map((level) => (
<span key={level.id}>{level.stocked_quantity}</span>
))}
</ul>
)}
</div>
)
}
export default InventoryItem
```
#### Hook Parameters
<TypeList types={[{"name":"inventoryItemId","type":"`string`","description":"The ID of the inventory item that the location levels belong to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"`AdminGetInventoryItemsItemLocationLevelsParams`","description":"Filters to apply on the retrieved location levels.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminInventoryItemLocationLevels"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminInventoryItemsLocationLevelsRes","type":"`AdminInventoryItemsLocationLevelsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminInventoryItemLocationLevels"/>

View File

@@ -1,181 +0,0 @@
---
slug: /references/medusa-react/hooks/admin/invites
---
import { TypeList } from "docs-ui"
# Invites
Queries and Mutations listed here are used to send requests to the [Admin Invite API Routes](https://docs.medusajs.com/api/admin#invites).
All hooks listed require [authentication](../../../../modules/user/page.mdx).
An admin can invite new users to manage their team. This would allow new users to authenticate as admins and perform admin functionalities.
Related Guide: [How to manage invites](https://docs.medusajs.com/modules/users/admin/manage-invites).
## Mutations
### useAdminAcceptInvite
This hook accepts an Invite. This will also delete the invite and create a new user that can log in and perform admin functionalities.
The user will have the email associated with the invite, and the password provided in the mutation function's parameter.
#### Example
```ts
import React from "react"
import { useAdminAcceptInvite } from "medusa-react"
const AcceptInvite = () => {
const acceptInvite = useAdminAcceptInvite()
// ...
const handleAccept = (
token: string,
firstName: string,
lastName: string,
password: string
) => {
acceptInvite.mutate({
token,
user: {
first_name: firstName,
last_name: lastName,
password,
},
}, {
onSuccess: () => {
// invite accepted successfully.
}
})
}
// ...
}
export default AcceptInvite
```
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostInvitesInviteAcceptReq","type":"`AdminPostInvitesInviteAcceptReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminAcceptInvite"/>
### useAdminResendInvite
This hook resends an invite. This renews the expiry date by seven days and generates a new token for the invite. It also triggers the `invite.created` event,
so if you have a Notification Provider installed that handles this event, a notification should be sent to the email associated with the
invite to allow them to accept the invite.
#### Example
```ts
import React from "react"
import { useAdminResendInvite } from "medusa-react"
type Props = {
inviteId: string
}
const ResendInvite = ({ inviteId }: Props) => {
const resendInvite = useAdminResendInvite(inviteId)
// ...
const handleResend = () => {
resendInvite.mutate(void 0, {
onSuccess: () => {
// invite resent successfully
}
})
}
// ...
}
export default ResendInvite
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The invite's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminResendInvite"/>
### useAdminDeleteInvite
This hook deletes an invite. Only invites that weren't accepted can be deleted.
#### Example
```ts
import React from "react"
import { useAdminDeleteInvite } from "medusa-react"
type Props = {
inviteId: string
}
const DeleteInvite = ({ inviteId }: Props) => {
const deleteInvite = useAdminDeleteInvite(inviteId)
// ...
const handleDelete = () => {
deleteInvite.mutate(void 0, {
onSuccess: ({ id, object, deleted }) => {
console.log(id)
}
})
}
// ...
}
export default Invite
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The invite's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteInvite"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteInvite"/>
___
## Queries
### useAdminInvites
This hook retrieves a list of invites.
#### Example
```ts
import React from "react"
import { useAdminInvites } from "medusa-react"
const Invites = () => {
const { invites, isLoading } = useAdminInvites()
return (
<div>
{isLoading && <span>Loading...</span>}
{invites && !invites.length && (
<span>No Invites</span>)
}
{invites && invites.length > 0 && (
<ul>
{invites.map((invite) => (
<li key={invite.id}>{invite.user_email}</li>
))}
</ul>
)}
</div>
)
}
export default Invites
```
#### Query Returned Data
<TypeList types={[{"name":"AdminListInvitesRes","type":"`AdminListInvitesRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminInvites"/>

View File

@@ -1,256 +0,0 @@
---
slug: /references/medusa-react/hooks/admin/notes
---
import { TypeList } from "docs-ui"
# Notes
Queries and Mutations listed here are used to send requests to the [Admin Note API Routes](https://docs.medusajs.com/api/admin#notes).
All hooks listed require [authentication](../../../../modules/user/page.mdx).
Notes are created by admins and can be associated with any resource. For example, an admin can add a note to an order for additional details or remarks.
## Mutations
### useAdminCreateNote
This hook creates a Note which can be associated with any resource.
#### Example
```ts
import React from "react"
import { useAdminCreateNote } from "medusa-react"
const CreateNote = () => {
const createNote = useAdminCreateNote()
// ...
const handleCreate = () => {
createNote.mutate({
resource_id: "order_123",
resource_type: "order",
value: "We delivered this order"
}, {
onSuccess: ({ note }) => {
console.log(note.id)
}
})
}
// ...
}
export default CreateNote
```
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostNotesReq","type":"`AdminPostNotesReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateNote"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminNotesRes","type":"`AdminNotesRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateNote"/>
### useAdminUpdateNote
This hook updates a Note's details.
#### Example
```ts
import React from "react"
import { useAdminUpdateNote } from "medusa-react"
type Props = {
noteId: string
}
const Note = ({ noteId }: Props) => {
const updateNote = useAdminUpdateNote(noteId)
// ...
const handleUpdate = (
value: string
) => {
updateNote.mutate({
value
}, {
onSuccess: ({ note }) => {
console.log(note.value)
}
})
}
// ...
}
export default Note
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The note's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateNote"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostNotesNoteReq","type":"`AdminPostNotesNoteReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateNote"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminNotesRes","type":"`AdminNotesRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateNote"/>
### useAdminDeleteNote
This hook deletes a Note.
#### Example
```ts
import React from "react"
import { useAdminDeleteNote } from "medusa-react"
type Props = {
noteId: string
}
const Note = ({ noteId }: Props) => {
const deleteNote = useAdminDeleteNote(noteId)
// ...
const handleDelete = () => {
deleteNote.mutate()
}
// ...
}
export default Note
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The note's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteNote"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteNote"/>
___
## Queries
### useAdminNotes
This hook retrieves a list of notes. The notes can be filtered by fields such as `resource_id` passed in
the `query` parameter. The notes can also be paginated.
#### Example
To list notes:
```tsx
import React from "react"
import { useAdminNotes } from "medusa-react"
const Notes = () => {
const { notes, isLoading } = useAdminNotes()
return (
<div>
{isLoading && <span>Loading...</span>}
{notes && !notes.length && <span>No Notes</span>}
{notes && notes.length > 0 && (
<ul>
{notes.map((note) => (
<li key={note.id}>{note.resource_type}</li>
))}
</ul>
)}
</div>
)
}
export default Notes
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```tsx
import React from "react"
import { useAdminNotes } from "medusa-react"
const Notes = () => {
const {
notes,
limit,
offset,
isLoading
} = useAdminNotes({
limit: 40,
offset: 0
})
return (
<div>
{isLoading && <span>Loading...</span>}
{notes && !notes.length && <span>No Notes</span>}
{notes && notes.length > 0 && (
<ul>
{notes.map((note) => (
<li key={note.id}>{note.resource_type}</li>
))}
</ul>
)}
</div>
)
}
export default Notes
```
#### Hook Parameters
<TypeList types={[{"name":"query","type":"`AdminGetNotesParams`","description":"Filters and pagination configurations applied on retrieved notes.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminNotes"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminNotesListRes","type":"`AdminNotesListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminNotes"/>
### useAdminNote
This hook retrieves a note's details.
#### Example
```ts
import React from "react"
import { useAdminNote } from "medusa-react"
type Props = {
noteId: string
}
const Note = ({ noteId }: Props) => {
const { note, isLoading } = useAdminNote(noteId)
return (
<div>
{isLoading && <span>Loading...</span>}
{note && <span>{note.resource_type}</span>}
</div>
)
}
export default Note
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The note's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminNote"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminNotesRes","type":"`AdminNotesRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminNote"/>

View File

@@ -1,179 +0,0 @@
---
slug: /references/medusa-react/hooks/admin/notifications
---
import { TypeList } from "docs-ui"
# Notifications
Queries and Mutations listed here are used to send requests to the [Admin Notification API Routes](https://docs.medusajs.com/api/admin#notifications).
All hooks listed require [authentication](../../../../modules/user/page.mdx).
Notifications are sent to customers to inform them of new updates. For example, a notification can be sent to the customer when their order is place or its state is updated.
The notification's type, such as an email or SMS, is determined by the notification provider installed on the Medusa backend.
## Mutations
### useAdminResendNotification
This hook resends a previously sent notifications, with the same data but optionally to a different address.
#### Example
```ts
import React from "react"
import { useAdminResendNotification } from "medusa-react"
type Props = {
notificationId: string
}
const Notification = ({ notificationId }: Props) => {
const resendNotification = useAdminResendNotification(
notificationId
)
// ...
const handleResend = () => {
resendNotification.mutate({}, {
onSuccess: ({ notification }) => {
console.log(notification.id)
}
})
}
// ...
}
export default Notification
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The ID of the notification.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminResendNotification"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostNotificationsNotificationResendReq","type":"`AdminPostNotificationsNotificationResendReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminResendNotification"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminNotificationsRes","type":"`AdminNotificationsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminResendNotification"/>
___
## Queries
### useAdminNotifications
This hook retrieves a list of notifications. The notifications can be filtered by fields such as `event_name` or `resource_type` passed in the `query` parameter.
The notifications can also be paginated.
#### Example
To list notifications:
```tsx
import React from "react"
import { useAdminNotifications } from "medusa-react"
const Notifications = () => {
const { notifications, isLoading } = useAdminNotifications()
return (
<div>
{isLoading && <span>Loading...</span>}
{notifications && !notifications.length && (
<span>No Notifications</span>
)}
{notifications && notifications.length > 0 && (
<ul>
{notifications.map((notification) => (
<li key={notification.id}>{notification.to}</li>
))}
</ul>
)}
</div>
)
}
export default Notifications
```
To specify relations that should be retrieved within the notifications:
```tsx
import React from "react"
import { useAdminNotifications } from "medusa-react"
const Notifications = () => {
const { notifications, isLoading } = useAdminNotifications({
expand: "provider"
})
return (
<div>
{isLoading && <span>Loading...</span>}
{notifications && !notifications.length && (
<span>No Notifications</span>
)}
{notifications && notifications.length > 0 && (
<ul>
{notifications.map((notification) => (
<li key={notification.id}>{notification.to}</li>
))}
</ul>
)}
</div>
)
}
export default Notifications
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```tsx
import React from "react"
import { useAdminNotifications } from "medusa-react"
const Notifications = () => {
const {
notifications,
limit,
offset,
isLoading
} = useAdminNotifications({
expand: "provider",
limit: 20,
offset: 0
})
return (
<div>
{isLoading && <span>Loading...</span>}
{notifications && !notifications.length && (
<span>No Notifications</span>
)}
{notifications && notifications.length > 0 && (
<ul>
{notifications.map((notification) => (
<li key={notification.id}>{notification.to}</li>
))}
</ul>
)}
</div>
)
}
export default Notifications
```
#### Hook Parameters
<TypeList types={[{"name":"query","type":"`AdminGetNotificationsParams`","description":"Filters and pagination configurations applied to the retrieved notifications.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminNotifications"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminNotificationsListRes","type":"`AdminNotificationsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminNotifications"/>

View File

@@ -1,674 +0,0 @@
---
slug: /references/medusa-react/hooks/admin/order_edits
---
import { TypeList } from "docs-ui"
# Order Edits
Queries and Mutations listed here are used to send requests to the [Admin Order Edit API Routes](https://docs.medusajs.com/api/admin#order-edits).
All hooks listed require [authentication](../../../../modules/user/page.mdx).
An admin can edit an order to remove, add, or update an item's quantity. When an admin edits an order, they're stored as an `OrderEdit`.
Related Guide: [How to edit an order](https://docs.medusajs.com/modules/orders/admin/edit-order).
## Mutations
### useAdminCreateOrderEdit
This hook creates an order edit.
#### Example
```ts
import React from "react"
import { useAdminCreateOrderEdit } from "medusa-react"
const CreateOrderEdit = () => {
const createOrderEdit = useAdminCreateOrderEdit()
const handleCreateOrderEdit = (orderId: string) => {
createOrderEdit.mutate({
order_id: orderId,
}, {
onSuccess: ({ order_edit }) => {
console.log(order_edit.id)
}
})
}
// ...
}
export default CreateOrderEdit
```
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostOrderEditsReq","type":"`AdminPostOrderEditsReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateOrderEdit"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrderEditsRes","type":"`AdminOrderEditsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateOrderEdit"/>
### useAdminDeleteOrderEdit
This hook deletes an order edit. Only order edits that have the status `created` can be deleted.
#### Example
```ts
import React from "react"
import { useAdminDeleteOrderEdit } from "medusa-react"
type Props = {
orderEditId: string
}
const OrderEdit = ({ orderEditId }: Props) => {
const deleteOrderEdit = useAdminDeleteOrderEdit(
orderEditId
)
const handleDelete = () => {
deleteOrderEdit.mutate(void 0, {
onSuccess: ({ id, object, deleted }) => {
console.log(id)
}
})
}
// ...
}
export default OrderEdit
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"Order Edit's ID","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteOrderEdit"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"DeleteResponse","type":"`DeleteResponse`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteOrderEdit"/>
### useAdminDeleteOrderEditItemChange
This hook deletes a line item change that indicates the addition, deletion, or update of a line item in the original order.
#### Example
```ts
import React from "react"
import { useAdminDeleteOrderEditItemChange } from "medusa-react"
type Props = {
orderEditId: string
itemChangeId: string
}
const OrderEditItemChange = ({
orderEditId,
itemChangeId
}: Props) => {
const deleteItemChange = useAdminDeleteOrderEditItemChange(
orderEditId,
itemChangeId
)
const handleDeleteItemChange = () => {
deleteItemChange.mutate(void 0, {
onSuccess: ({ id, object, deleted }) => {
console.log(id)
}
})
}
// ...
}
export default OrderEditItemChange
```
#### Hook Parameters
<TypeList types={[{"name":"orderEditId","type":"`string`","description":"The order edit's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"itemChangeId","type":"`string`","description":"The line item change's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteOrderEditItemChange"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrderEditItemChangeDeleteRes","type":"`AdminOrderEditItemChangeDeleteRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminDeleteOrderEditItemChange"/>
### useAdminOrderEditUpdateLineItem
This hook creates or updates a line item change in the order edit that indicates addition, deletion, or update of a line item
into an original order. Line item changes are only reflected on the original order after the order edit is confirmed.
#### Example
```ts
import React from "react"
import { useAdminOrderEditUpdateLineItem } from "medusa-react"
type Props = {
orderEditId: string
itemId: string
}
const OrderEditItemChange = ({
orderEditId,
itemId
}: Props) => {
const updateLineItem = useAdminOrderEditUpdateLineItem(
orderEditId,
itemId
)
const handleUpdateLineItem = (quantity: number) => {
updateLineItem.mutate({
quantity,
}, {
onSuccess: ({ order_edit }) => {
console.log(order_edit.items)
}
})
}
// ...
}
export default OrderEditItemChange
```
#### Hook Parameters
<TypeList types={[{"name":"orderEditId","type":"`string`","description":"The order edit's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"itemId","type":"`string`","description":"The line item's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminOrderEditUpdateLineItem"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostOrderEditsEditLineItemsLineItemReq","type":"`AdminPostOrderEditsEditLineItemsLineItemReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminOrderEditUpdateLineItem"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrderEditsRes","type":"`AdminOrderEditsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminOrderEditUpdateLineItem"/>
### useAdminOrderEditDeleteLineItem
This hook creates a line item change in the order edit that indicates deleting an item in the original order.
The item in the original order will not be deleted until the order edit is confirmed.
#### Example
```ts
import React from "react"
import { useAdminOrderEditDeleteLineItem } from "medusa-react"
type Props = {
orderEditId: string
itemId: string
}
const OrderEditLineItem = ({
orderEditId,
itemId
}: Props) => {
const removeLineItem = useAdminOrderEditDeleteLineItem(
orderEditId,
itemId
)
const handleRemoveLineItem = () => {
removeLineItem.mutate(void 0, {
onSuccess: ({ order_edit }) => {
console.log(order_edit.changes)
}
})
}
// ...
}
export default OrderEditLineItem
```
#### Hook Parameters
<TypeList types={[{"name":"orderEditId","type":"`string`","description":"The order edit's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"itemId","type":"`string`","description":"The line item's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminOrderEditDeleteLineItem"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrderEditsRes","type":"`AdminOrderEditsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminOrderEditDeleteLineItem"/>
### useAdminUpdateOrderEdit
This hook updates an Order Edit's details.
#### Example
```ts
import React from "react"
import { useAdminUpdateOrderEdit } from "medusa-react"
type Props = {
orderEditId: string
}
const OrderEdit = ({ orderEditId }: Props) => {
const updateOrderEdit = useAdminUpdateOrderEdit(
orderEditId,
)
const handleUpdate = (
internalNote: string
) => {
updateOrderEdit.mutate({
internal_note: internalNote
}, {
onSuccess: ({ order_edit }) => {
console.log(order_edit.internal_note)
}
})
}
// ...
}
export default OrderEdit
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order edit's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateOrderEdit"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostOrderEditsOrderEditReq","type":"`AdminPostOrderEditsOrderEditReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateOrderEdit"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrderEditsRes","type":"`AdminOrderEditsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateOrderEdit"/>
### useAdminOrderEditAddLineItem
This hook creates a line item change in the order edit that indicates adding an item in the original order.
The item will not be added to the original order until the order edit is confirmed.
#### Example
```ts
import React from "react"
import { useAdminOrderEditAddLineItem } from "medusa-react"
type Props = {
orderEditId: string
}
const OrderEdit = ({ orderEditId }: Props) => {
const addLineItem = useAdminOrderEditAddLineItem(
orderEditId
)
const handleAddLineItem =
(quantity: number, variantId: string) => {
addLineItem.mutate({
quantity,
variant_id: variantId,
}, {
onSuccess: ({ order_edit }) => {
console.log(order_edit.changes)
}
})
}
// ...
}
export default OrderEdit
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order edit's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminOrderEditAddLineItem"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostOrderEditsEditLineItemsReq","type":"`AdminPostOrderEditsEditLineItemsReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminOrderEditAddLineItem"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrderEditsRes","type":"`AdminOrderEditsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminOrderEditAddLineItem"/>
### useAdminRequestOrderEditConfirmation
This hook requests customer confirmation of an order edit. This would emit the event `order-edit.requested` which Notification Providers listen to and send
a notification to the customer about the order edit.
#### Example
```ts
import React from "react"
import {
useAdminRequestOrderEditConfirmation,
} from "medusa-react"
type Props = {
orderEditId: string
}
const OrderEdit = ({ orderEditId }: Props) => {
const requestOrderConfirmation =
useAdminRequestOrderEditConfirmation(
orderEditId
)
const handleRequestConfirmation = () => {
requestOrderConfirmation.mutate(void 0, {
onSuccess: ({ order_edit }) => {
console.log(
order_edit.requested_at,
order_edit.requested_by
)
}
})
}
// ...
}
export default OrderEdit
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order edit's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminRequestOrderEditConfirmation"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrderEditsRes","type":"`AdminOrderEditsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminRequestOrderEditConfirmation"/>
### useAdminCancelOrderEdit
This hook cancels an order edit.
#### Example
```ts
import React from "react"
import {
useAdminCancelOrderEdit,
} from "medusa-react"
type Props = {
orderEditId: string
}
const OrderEdit = ({ orderEditId }: Props) => {
const cancelOrderEdit =
useAdminCancelOrderEdit(
orderEditId
)
const handleCancel = () => {
cancelOrderEdit.mutate(void 0, {
onSuccess: ({ order_edit }) => {
console.log(
order_edit.id
)
}
})
}
// ...
}
export default OrderEdit
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order edit's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCancelOrderEdit"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrderEditsRes","type":"`AdminOrderEditsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCancelOrderEdit"/>
### useAdminConfirmOrderEdit
This hook confirms an order edit. This will reflect the changes in the order edit on the associated order.
#### Example
```ts
import React from "react"
import { useAdminConfirmOrderEdit } from "medusa-react"
type Props = {
orderEditId: string
}
const OrderEdit = ({ orderEditId }: Props) => {
const confirmOrderEdit = useAdminConfirmOrderEdit(
orderEditId
)
const handleConfirmOrderEdit = () => {
confirmOrderEdit.mutate(void 0, {
onSuccess: ({ order_edit }) => {
console.log(
order_edit.confirmed_at,
order_edit.confirmed_by
)
}
})
}
// ...
}
export default OrderEdit
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order edit's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminConfirmOrderEdit"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrderEditsRes","type":"`AdminOrderEditsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminConfirmOrderEdit"/>
___
## Queries
### useAdminOrderEdit
This hook retrieves an order edit's details.
#### Example
A simple example that retrieves an order edit by its ID:
```tsx
import React from "react"
import { useAdminOrderEdit } from "medusa-react"
type Props = {
orderEditId: string
}
const OrderEdit = ({ orderEditId }: Props) => {
const {
order_edit,
isLoading,
} = useAdminOrderEdit(orderEditId)
return (
<div>
{isLoading && <span>Loading...</span>}
{order_edit && <span>{order_edit.status}</span>}
</div>
)
}
export default OrderEdit
```
To specify relations that should be retrieved:
```tsx
import React from "react"
import { useAdminOrderEdit } from "medusa-react"
type Props = {
orderEditId: string
}
const OrderEdit = ({ orderEditId }: Props) => {
const {
order_edit,
isLoading,
} = useAdminOrderEdit(
orderEditId,
{
expand: "order"
}
)
return (
<div>
{isLoading && <span>Loading...</span>}
{order_edit && <span>{order_edit.status}</span>}
</div>
)
}
export default OrderEdit
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order edit's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"`GetOrderEditsOrderEditParams`","description":"Configurations to apply on the retrieved order edit.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminOrderEdit"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminOrderEditsRes","type":"`AdminOrderEditsRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminOrderEdit"/>
### useAdminOrderEdits
This hook retrieves a list of order edits. The order edits can be filtered by fields such as `q` or `order_id` passed to the `query` parameter.
The order edits can also be paginated.
#### Example
To list order edits:
```tsx
import React from "react"
import { useAdminOrderEdits } from "medusa-react"
const OrderEdits = () => {
const { order_edits, isLoading } = useAdminOrderEdits()
return (
<div>
{isLoading && <span>Loading...</span>}
{order_edits && !order_edits.length && (
<span>No Order Edits</span>
)}
{order_edits && order_edits.length > 0 && (
<ul>
{order_edits.map((orderEdit) => (
<li key={orderEdit.id}>
{orderEdit.status}
</li>
))}
</ul>
)}
</div>
)
}
export default OrderEdits
```
To specify relations that should be retrieved within the order edits:
```tsx
import React from "react"
import { useAdminOrderEdits } from "medusa-react"
const OrderEdits = () => {
const { order_edits, isLoading } = useAdminOrderEdits({
expand: "order"
})
return (
<div>
{isLoading && <span>Loading...</span>}
{order_edits && !order_edits.length && (
<span>No Order Edits</span>
)}
{order_edits && order_edits.length > 0 && (
<ul>
{order_edits.map((orderEdit) => (
<li key={orderEdit.id}>
{orderEdit.status}
</li>
))}
</ul>
)}
</div>
)
}
export default OrderEdits
```
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```tsx
import React from "react"
import { useAdminOrderEdits } from "medusa-react"
const OrderEdits = () => {
const {
order_edits,
limit,
offset,
isLoading
} = useAdminOrderEdits({
expand: "order",
limit: 20,
offset: 0
})
return (
<div>
{isLoading && <span>Loading...</span>}
{order_edits && !order_edits.length && (
<span>No Order Edits</span>
)}
{order_edits && order_edits.length > 0 && (
<ul>
{order_edits.map((orderEdit) => (
<li key={orderEdit.id}>
{orderEdit.status}
</li>
))}
</ul>
)}
</div>
)
}
export default OrderEdits
```
#### Hook Parameters
<TypeList types={[{"name":"query","type":"`GetOrderEditsParams`","description":"Filters and pagination configurations applied to retrieved order edits.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminOrderEdits"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminOrderEditsListRes","type":"`AdminOrderEditsListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminOrderEdits"/>

View File

@@ -1,705 +0,0 @@
---
slug: /references/medusa-react/hooks/admin/orders
---
import { TypeList } from "docs-ui"
# Orders
Queries and Mutations listed here are used to send requests to the [Admin Order API Routes](https://docs.medusajs.com/api/admin#orders).
All hooks listed require [authentication](../../../../modules/user/page.mdx).
Orders are purchases made by customers, typically through a storefront using cart. Managing orders include managing fulfillment, payment, claims, reservations, and more.
Related Guide: [How to manage orders](https://docs.medusajs.com/modules/orders/admin/manage-orders).
## Mutations
### useAdminUpdateOrder
This hook updates an order's details.
#### Example
```ts
import React from "react"
import { useAdminUpdateOrder } from "medusa-react"
type Props = {
orderId: string
}
const Order = ({ orderId }: Props) => {
const updateOrder = useAdminUpdateOrder(
orderId
)
const handleUpdate = (
email: string
) => {
updateOrder.mutate({
email,
}, {
onSuccess: ({ order }) => {
console.log(order.email)
}
})
}
// ...
}
export default Order
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateOrder"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostOrdersOrderReq","type":"`AdminPostOrdersOrderReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateOrder"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminUpdateOrder"/>
### useAdminCancelOrder
This hook cancels an order and change its status. This will also cancel any associated fulfillments and payments,
and it may fail if the payment or fulfillment Provider is unable to cancel the payment/fulfillment.
#### Example
```ts
import React from "react"
import { useAdminCancelOrder } from "medusa-react"
type Props = {
orderId: string
}
const Order = ({ orderId }: Props) => {
const cancelOrder = useAdminCancelOrder(
orderId
)
// ...
const handleCancel = () => {
cancelOrder.mutate(void 0, {
onSuccess: ({ order }) => {
console.log(order.status)
}
})
}
// ...
}
export default Order
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCancelOrder"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCancelOrder"/>
### useAdminCompleteOrder
This hook completes an order and change its status. A canceled order can't be completed.
#### Example
```ts
import React from "react"
import { useAdminCompleteOrder } from "medusa-react"
type Props = {
orderId: string
}
const Order = ({ orderId }: Props) => {
const completeOrder = useAdminCompleteOrder(
orderId
)
// ...
const handleComplete = () => {
completeOrder.mutate(void 0, {
onSuccess: ({ order }) => {
console.log(order.status)
}
})
}
// ...
}
export default Order
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCompleteOrder"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCompleteOrder"/>
### useAdminCapturePayment
This hook captures all the payments associated with an order. The payment of canceled orders can't be captured.
#### Example
```ts
import React from "react"
import { useAdminCapturePayment } from "medusa-react"
type Props = {
orderId: string
}
const Order = ({ orderId }: Props) => {
const capturePayment = useAdminCapturePayment(
orderId
)
// ...
const handleCapture = () => {
capturePayment.mutate(void 0, {
onSuccess: ({ order }) => {
console.log(order.status)
}
})
}
// ...
}
export default Order
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCapturePayment"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCapturePayment"/>
### useAdminRefundPayment
This hook refunds an amount for an order. The amount must be less than or equal the `refundable_amount` of the order.
#### Example
```ts
import React from "react"
import { useAdminRefundPayment } from "medusa-react"
type Props = {
orderId: string
}
const Order = ({ orderId }: Props) => {
const refundPayment = useAdminRefundPayment(
orderId
)
// ...
const handleRefund = (
amount: number,
reason: string
) => {
refundPayment.mutate({
amount,
reason,
}, {
onSuccess: ({ order }) => {
console.log(order.refunds)
}
})
}
// ...
}
export default Order
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminRefundPayment"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostOrdersOrderRefundsReq","type":"`AdminPostOrdersOrderRefundsReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminRefundPayment"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminRefundPayment"/>
### useAdminCreateFulfillment
This hook creates a Fulfillment of an Order using the fulfillment provider, and change the order's
fulfillment status to either `partially_fulfilled` or `fulfilled`, depending on
whether all the items were fulfilled.
#### Example
```ts
import React from "react"
import { useAdminCreateFulfillment } from "medusa-react"
type Props = {
orderId: string
}
const Order = ({ orderId }: Props) => {
const createFulfillment = useAdminCreateFulfillment(
orderId
)
// ...
const handleCreateFulfillment = (
itemId: string,
quantity: number
) => {
createFulfillment.mutate({
items: [
{
item_id: itemId,
quantity,
},
],
}, {
onSuccess: ({ order }) => {
console.log(order.fulfillments)
}
})
}
// ...
}
export default Order
```
#### Hook Parameters
<TypeList types={[{"name":"orderId","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateFulfillment"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostOrdersOrderFulfillmentsReq","type":"`AdminPostOrdersOrderFulfillmentsReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateFulfillment"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateFulfillment"/>
### useAdminCancelFulfillment
This hook cancels an order's fulfillment and change its fulfillment status to `canceled`.
#### Example
```ts
import React from "react"
import { useAdminCancelFulfillment } from "medusa-react"
type Props = {
orderId: string
}
const Order = ({ orderId }: Props) => {
const cancelFulfillment = useAdminCancelFulfillment(
orderId
)
// ...
const handleCancel = (
fulfillmentId: string
) => {
cancelFulfillment.mutate(fulfillmentId, {
onSuccess: ({ order }) => {
console.log(order.fulfillments)
}
})
}
// ...
}
export default Order
```
#### Hook Parameters
<TypeList types={[{"name":"orderId","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCancelFulfillment"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"string","type":"`string`","optional":false,"defaultValue":"","description":"The fulfillment's ID.","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCancelFulfillment"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCancelFulfillment"/>
### useAdminCreateShipment
This hook creates a shipment and mark a fulfillment as shipped. This changes the order's fulfillment status to either
`partially_shipped` or `shipped`, depending on whether all the items were shipped.
#### Example
```ts
import React from "react"
import { useAdminCreateShipment } from "medusa-react"
type Props = {
orderId: string
}
const Order = ({ orderId }: Props) => {
const createShipment = useAdminCreateShipment(
orderId
)
// ...
const handleCreate = (
fulfillmentId: string
) => {
createShipment.mutate({
fulfillment_id: fulfillmentId,
}, {
onSuccess: ({ order }) => {
console.log(order.fulfillment_status)
}
})
}
// ...
}
export default Order
```
#### Hook Parameters
<TypeList types={[{"name":"orderId","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateShipment"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostOrdersOrderShipmentReq","type":"`AdminPostOrdersOrderShipmentReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateShipment"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminCreateShipment"/>
### useAdminRequestReturn
This hook requests and create a return for items in an order. If the return shipping method is specified, it will be automatically fulfilled.
#### Example
```ts
import React from "react"
import { useAdminRequestReturn } from "medusa-react"
type Props = {
orderId: string
}
const Order = ({ orderId }: Props) => {
const requestReturn = useAdminRequestReturn(
orderId
)
// ...
const handleRequestingReturn = (
itemId: string,
quantity: number
) => {
requestReturn.mutate({
items: [
{
item_id: itemId,
quantity
}
]
}, {
onSuccess: ({ order }) => {
console.log(order.returns)
}
})
}
// ...
}
export default Order
```
#### Hook Parameters
<TypeList types={[{"name":"orderId","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminRequestReturn"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostOrdersOrderReturnsReq","type":"`AdminPostOrdersOrderReturnsReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminRequestReturn"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminRequestReturn"/>
### useAdminAddShippingMethod
This hook adds a shipping method to an order. If another shipping method exists with the same shipping profile, the previous shipping method will be replaced.
#### Example
```ts
import React from "react"
import { useAdminAddShippingMethod } from "medusa-react"
type Props = {
orderId: string
}
const Order = ({ orderId }: Props) => {
const addShippingMethod = useAdminAddShippingMethod(
orderId
)
// ...
const handleAddShippingMethod = (
optionId: string,
price: number
) => {
addShippingMethod.mutate({
option_id: optionId,
price
}, {
onSuccess: ({ order }) => {
console.log(order.shipping_methods)
}
})
}
// ...
}
export default Order
```
#### Hook Parameters
<TypeList types={[{"name":"orderId","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminAddShippingMethod"/>
#### Mutation Function Parameters
<TypeList types={[{"name":"AdminPostOrdersOrderShippingMethodsReq","type":"`AdminPostOrdersOrderShippingMethodsReq`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminAddShippingMethod"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminAddShippingMethod"/>
### useAdminArchiveOrder
The hook archives an order and change its status.
#### Example
```ts
import React from "react"
import { useAdminArchiveOrder } from "medusa-react"
type Props = {
orderId: string
}
const Order = ({ orderId }: Props) => {
const archiveOrder = useAdminArchiveOrder(
orderId
)
// ...
const handleArchivingOrder = () => {
archiveOrder.mutate(void 0, {
onSuccess: ({ order }) => {
console.log(order.status)
}
})
}
// ...
}
export default Order
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminArchiveOrder"/>
#### Mutation Function Returned Data
<TypeList types={[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminArchiveOrder"/>
___
## Queries
### useAdminOrders
This hook retrieves a list of orders. The orders can be filtered by fields such as `status` or `display_id` passed
in the `query` parameter. The order can also be paginated.
#### Example
To list orders:
```tsx
import React from "react"
import { useAdminOrders } from "medusa-react"
const Orders = () => {
const { orders, isLoading } = useAdminOrders()
return (
<div>
{isLoading && <span>Loading...</span>}
{orders && !orders.length && <span>No Orders</span>}
{orders && orders.length > 0 && (
<ul>
{orders.map((order) => (
<li key={order.id}>{order.display_id}</li>
))}
</ul>
)}
</div>
)
}
export default Orders
```
You can use the `query` parameter to pass filters and specify relations that should be retrieved within the orders. In addition,
By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```tsx
import React from "react"
import { useAdminOrders } from "medusa-react"
const Orders = () => {
const {
orders,
limit,
offset,
isLoading
} = useAdminOrders({
expand: "customers",
limit: 20,
offset: 0
})
return (
<div>
{isLoading && <span>Loading...</span>}
{orders && !orders.length && <span>No Orders</span>}
{orders && orders.length > 0 && (
<ul>
{orders.map((order) => (
<li key={order.id}>{order.display_id}</li>
))}
</ul>
)}
</div>
)
}
export default Orders
```
#### Hook Parameters
<TypeList types={[{"name":"query","type":"`AdminGetOrdersParams`","description":"Filters and pagination configurations applied on the retrieved orders.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminOrders"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminOrdersListRes","type":"`AdminOrdersListRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminOrders"/>
### useAdminOrder
This hook retrieve an order's details.
#### Example
A simple example that retrieves an order by its ID:
```tsx
import React from "react"
import { useAdminOrder } from "medusa-react"
type Props = {
orderId: string
}
const Order = ({ orderId }: Props) => {
const {
order,
isLoading,
} = useAdminOrder(orderId)
return (
<div>
{isLoading && <span>Loading...</span>}
{order && <span>{order.display_id}</span>}
</div>
)
}
export default Order
```
To specify relations that should be retrieved:
```tsx
import React from "react"
import { useAdminOrder } from "medusa-react"
const Order = (
orderId: string
) => {
const {
order,
isLoading,
} = useAdminOrder(orderId, {
expand: "customer"
})
return (
<div>
{isLoading && <span>Loading...</span>}
{order && <span>{order.display_id}</span>}
</div>
)
}
export default Order
```
#### Hook Parameters
<TypeList types={[{"name":"id","type":"`string`","description":"The order's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"query","type":"`FindParams`","description":"Configurations to apply on the retrieved order.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminOrder"/>
#### Query Returned Data
<TypeList types={[{"name":"AdminOrdersRes","type":"`AdminOrdersRes`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/medusa-react/overview#expanding-fields" sectionTitle="useAdminOrder"/>

Some files were not shown because too many files have changed in this diff Show More