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 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
retrieve
Retrieve an Inventory Item's details.
Example
Parameters
inventoryItemId
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Configurations applied on the retrieved inventory item.
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.
customHeaders
Record<string, any>RequiredDefault: {}
Configurations to apply on the retrieved inventory item.
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>Requiredcreate
Create an Inventory Item for a product variant.
Example
Parameters
The inventory item to create.
customHeaders
Record<string, any>RequiredDefault: {}
Configurations to apply on the retrieved inventory item.
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
To list inventory items:
By default, only the first 20
records are retrieved. You can control pagination by specifying the limit
and offset
properties:
import Medusa from "@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
customHeaders
Record<string, any>RequiredDefault: {}
Filters and pagination configurations applied on the retrieved inventory items.
Returns
ResponsePromise
ResponsePromise<AdminInventoryItemsListWithVariantsAndLocationLevelsRes>RequiredThe list of inventory items with pagination fields.
ResponsePromise
ResponsePromise<AdminInventoryItemsListWithVariantsAndLocationLevelsRes>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.
customHeaders
Record<string, any>RequiredDefault: {}
Configurations to apply on the returned inventory item.
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.
customHeaders
Record<string, any>RequiredDefault: {}
Configurations to apply on the returned inventory item.
Returns
ResponsePromise
ResponsePromise<AdminInventoryItemsRes>Requiredthe inventory item's details.
ResponsePromise
ResponsePromise<AdminInventoryItemsRes>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
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<AdminInventoryItemsRes>Requiredthe inventory item's details.
ResponsePromise
ResponsePromise<AdminInventoryItemsRes>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
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Filters to apply on the retrieved location levels.
Returns
ResponsePromise
ResponsePromise<AdminInventoryItemsLocationLevelsRes>RequiredThe inventory item's details and list of location levels.
ResponsePromise
ResponsePromise<AdminInventoryItemsLocationLevelsRes>Required