AdminInventoryItemsResource
This class is used to send requests to Admin Inventory Item API Routes. To use these API Routes, make sure to install the
@medusajs/inventory 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 user authentication.
Inventory items, provided by the Inventory Module, can be used to manage the inventory of saleable items in your store.
Related Guide: How to manage inventory items.
Methods
create
Create an Inventory Item for a product variant.
Example
Parameters
The inventory item to create.
Configurations to apply on the retrieved inventory item.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminInventoryItemsRes>RequiredThe inventory item's details.
ResponsePromise
ResponsePromise<AdminInventoryItemsRes>RequiredcreateLocationLevel
Create a Location Level for a given Inventory Item.
Example
import Medusa from "@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
inventoryItemId
stringRequiredThe location level to create.
Configurations to apply on the returned inventory item.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminInventoryItemsRes>Requiredthe inventory item's details.
ResponsePromise
ResponsePromise<AdminInventoryItemsRes>Requireddelete
Delete an Inventory Item. This does not delete the associated product variant.
Example
Parameters
inventoryItemId
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<DeleteResponse>RequiredThe deletion operation's details.
ResponsePromise
ResponsePromise<DeleteResponse>RequireddeleteLocationLevel
Delete a location level of an Inventory Item.
Example
import Medusa from "@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
inventoryItemId
stringRequiredlocationId
stringRequiredConfigurations to apply on the returned inventory item.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminInventoryItemsRes>Requiredthe inventory item's details.
ResponsePromise
ResponsePromise<AdminInventoryItemsRes>Requiredlist
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
Parameters
Filters and pagination configurations applied on the retrieved inventory items.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminInventoryItemsListWithVariantsAndLocationLevelsRes>RequiredThe list of inventory items with pagination fields.
ResponsePromise
ResponsePromise<AdminInventoryItemsListWithVariantsAndLocationLevelsRes>RequiredlistLocationLevels
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
import Medusa from "@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
inventoryItemId
stringRequiredFilters to apply on the retrieved location levels.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminInventoryItemsLocationLevelsRes>RequiredThe inventory item's details and list of location levels.
ResponsePromise
ResponsePromise<AdminInventoryItemsLocationLevelsRes>Requiredretrieve
Retrieve an Inventory Item's details.
Example
Parameters
inventoryItemId
stringRequiredConfigurations applied on the retrieved inventory item.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminInventoryItemsRes>RequiredThe inventory item's details.
ResponsePromise
ResponsePromise<AdminInventoryItemsRes>Requiredupdate
Update an Inventory Item's details.
Example
import Medusa from "@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
inventoryItemId
stringRequiredThe attributes to update in the inventory item.
Configurations to apply on the retrieved inventory item.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminInventoryItemsRes>RequiredThe inventory item's details.
ResponsePromise
ResponsePromise<AdminInventoryItemsRes>RequiredupdateLocationLevel
Update a location level's details for a given inventory item.
Example
import Medusa from "@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
inventoryItemId
stringRequiredlocationId
stringRequiredThe attributes to update in the location level.
Configurations to apply on the returned inventory item.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminInventoryItemsRes>Requiredthe inventory item's details.
ResponsePromise
ResponsePromise<AdminInventoryItemsRes>Required