Skip to main content
Skip to main content

IInventoryService

Methods

adjustInventory

**adjustInventory**(inventoryItemId, locationId, adjustment, context?): Promise<[InventoryLevelDTO](/references/services/types/InventoryLevelDTO)>

This method is used to adjust the inventory level's stocked quantity. The inventory level is identified by the IDs of its associated inventory item and location.

Example

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function adjustInventory (
inventoryItemId: string,
locationId: string,
adjustment: number
) {
const inventoryModule = await initializeInventoryModule({})

const inventoryLevel = await inventoryModule.adjustInventory(
inventoryItemId,
locationId,
adjustment
)

// do something with the inventory level or return it.
}

Parameters

inventoryItemIdstringRequired
The ID of the associated inventory item.
locationIdstringRequired
The ID of the associated location.
adjustmentnumberRequired
A positive or negative number used to adjust the inventory level's stocked quantity.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<InventoryLevelDTO>

PromisePromise<InventoryLevelDTO>Required
The inventory level's details.

confirmInventory

**confirmInventory**(inventoryItemId, locationIds, quantity, context?): Promise&#60;boolean&#62;

This method is used to confirm whether the specified quantity of an inventory item is available in the specified locations.

Example

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function confirmInventory (
inventoryItemId: string,
locationIds: string[],
quantity: number
) {
const inventoryModule = await initializeInventoryModule({})

return await inventoryModule.confirmInventory(
inventoryItemId,
locationIds,
quantity
)
}

Parameters

inventoryItemIdstringRequired
The ID of the inventory item to check its availability.
locationIdsstring[]Required
The IDs of the locations to check the quantity availability in.
quantitynumberRequired
The quantity to check if available for the inventory item in the specified locations.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<boolean>

PromisePromise<boolean>Required
Whether the specified quantity is available for the inventory item in the specified locations.

createInventoryItem

**createInventoryItem**(input, context?): Promise&#60;[InventoryItemDTO](/references/services/types/InventoryItemDTO)&#62;

This method is used to create an inventory item.

Example

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function createInventoryItem (item: {
sku: string,
requires_shipping: boolean
}) {
const inventoryModule = await initializeInventoryModule({})

const inventoryItem = await inventoryModule.createInventoryItem(
item
)

// do something with the inventory item or return it
}

Parameters

The details of the inventory item to create.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<InventoryItemDTO>

PromisePromise<InventoryItemDTO>Required
The created inventory item's details.

createInventoryItems

**createInventoryItems**(input, context?): Promise&#60;[InventoryItemDTO](/references/services/types/InventoryItemDTO)[]&#62;

This method is used to create inventory items.

Example

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function createInventoryItems (items: {
sku: string,
requires_shipping: boolean
}[]) {
const inventoryModule = await initializeInventoryModule({})

const inventoryItems = await inventoryModule.createInventoryItems(
items
)

// do something with the inventory items or return them
}

Parameters

The details of the inventory items to create.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<InventoryItemDTO[]>

PromisePromise<InventoryItemDTO[]>Required
The created inventory items' details.

createInventoryLevel

**createInventoryLevel**(data, context?): Promise&#60;[InventoryLevelDTO](/references/services/types/InventoryLevelDTO)&#62;

This method is used to create inventory level.

Example

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function createInventoryLevel (item: {
inventory_item_id: string
location_id: string
stocked_quantity: number
}) {
const inventoryModule = await initializeInventoryModule({})

const inventoryLevel = await inventoryModule.createInventoryLevel(
item
)

// do something with the inventory level or return it
}

Parameters

The details of the inventory level to create.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<InventoryLevelDTO>

PromisePromise<InventoryLevelDTO>Required
The created inventory level's details.

createInventoryLevels

**createInventoryLevels**(data, context?): Promise&#60;[InventoryLevelDTO](/references/services/types/InventoryLevelDTO)[]&#62;

This method is used to create inventory levels.

Example

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function createInventoryLevels (items: {
inventory_item_id: string
location_id: string
stocked_quantity: number
}[]) {
const inventoryModule = await initializeInventoryModule({})

const inventoryLevels = await inventoryModule.createInventoryLevels(
items
)

// do something with the inventory levels or return them
}

Parameters

The details of the inventory levels to create.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<InventoryLevelDTO[]>

PromisePromise<InventoryLevelDTO[]>Required
The created inventory levels' details.

createReservationItem

**createReservationItem**(input, context?): Promise&#60;[ReservationItemDTO](/references/services/types/ReservationItemDTO)&#62;

This method is used to create a reservation item.

Example

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function createReservationItem (item: {
inventory_item_id: string,
location_id: string,
quantity: number
}) {
const inventoryModule = await initializeInventoryModule({})

const reservationItem = await inventoryModule.createReservationItems(
item
)

// do something with the reservation item or return them
}

Parameters

The details of the reservation item to create.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ReservationItemDTO>

PromisePromise<ReservationItemDTO>Required
The created reservation item's details.

createReservationItems

**createReservationItems**(input, context?): Promise&#60;[ReservationItemDTO](/references/services/types/ReservationItemDTO)[]&#62;

This method is used to create reservation items.

Example

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function createReservationItems (items: {
inventory_item_id: string,
location_id: string,
quantity: number
}[]) {
const inventoryModule = await initializeInventoryModule({})

const reservationItems = await inventoryModule.createReservationItems(
items
)

// do something with the reservation items or return them
}

Parameters

The details of the reservation items to create.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ReservationItemDTO[]>

PromisePromise<ReservationItemDTO[]>Required
The created reservation items' details.

deleteInventoryItem

**deleteInventoryItem**(inventoryItemId, context?): Promise&#60;void&#62;

This method is used to delete an inventory item or multiple inventory items. The inventory items are only soft deleted and can be restored using the restoreInventoryItem method.

Example

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function deleteInventoryItem (
inventoryItems: string[]
) {
const inventoryModule = await initializeInventoryModule({})

await inventoryModule.deleteInventoryItem(
inventoryItems
)
}

Parameters

inventoryItemIdstring | string[]Required
The ID(s) of the inventory item(s) to delete.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<void>

PromisePromise<void>Required
Resolves when the inventory item(s) are successfully deleted.

deleteInventoryItemLevelByLocationId

**deleteInventoryItemLevelByLocationId**(locationId, context?): Promise&#60;void&#62;

This method deletes the inventory item level(s) for the ID(s) of associated location(s).

Example

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function deleteInventoryItemLevelByLocationId (
locationIds: string[]
) {
const inventoryModule = await initializeInventoryModule({})

await inventoryModule.deleteInventoryItemLevelByLocationId(
locationIds
)
}

Parameters

locationIdstring | string[]Required
The ID(s) of the associated location(s).
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<void>

PromisePromise<void>Required
Resolves when the inventory item level(s) are successfully restored.

deleteInventoryLevel

**deleteInventoryLevel**(inventoryItemId, locationId, context?): Promise&#60;void&#62;

This method is used to delete an inventory level. The inventory level is identified by the IDs of its associated inventory item and location.

Example

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function deleteInventoryLevel (
inventoryItemId: string,
locationId: string
) {
const inventoryModule = await initializeInventoryModule({})

await inventoryModule.deleteInventoryLevel(
inventoryItemId,
locationId
)
}

Parameters

inventoryItemIdstringRequired
The ID of the associated inventory item.
locationIdstringRequired
The ID of the associated location.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<void>

PromisePromise<void>Required
Resolves when the inventory level(s) are successfully restored.

deleteReservationItem

**deleteReservationItem**(reservationItemId, context?): Promise&#60;void&#62;

This method is used to delete a reservation item or multiple reservation items by their IDs.

Example

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function deleteReservationItems (
reservationItemIds: string[]
) {
const inventoryModule = await initializeInventoryModule({})

await inventoryModule.deleteReservationItem(
reservationItemIds
)
}

Parameters

reservationItemIdstring | string[]Required
The ID(s) of the reservation item(s) to delete.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<void>

PromisePromise<void>Required
Resolves when the reservation item(s) are successfully deleted.

deleteReservationItemByLocationId

**deleteReservationItemByLocationId**(locationId, context?): Promise&#60;void&#62;

This method deletes reservation item(s) by the ID(s) of associated location(s).

Example

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function deleteReservationItemByLocationId (
locationIds: string[]
) {
const inventoryModule = await initializeInventoryModule({})

await inventoryModule.deleteReservationItemByLocationId(
locationIds
)
}

Parameters

locationIdstring | string[]Required
The ID(s) of the associated location(s).
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<void>

PromisePromise<void>Required
Resolves when the reservation item(s) are successfully restored.

deleteReservationItemsByLineItem

**deleteReservationItemsByLineItem**(lineItemId, context?): Promise&#60;void&#62;

This method is used to delete the reservation items associated with a line item or multiple line items.

Example

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function deleteReservationItemsByLineItem (
lineItemIds: string[]
) {
const inventoryModule = await initializeInventoryModule({})

await inventoryModule.deleteReservationItemsByLineItem(
lineItemIds
)
}

Parameters

lineItemIdstring | string[]Required
The ID(s) of the line item(s).
A context used to share re9sources, such as transaction manager, between the application and the module.

Returns

Promise<void>

PromisePromise<void>Required
Resolves when the reservation items are successfully deleted.

listInventoryItems

**listInventoryItems**(selector, config?, context?): Promise&#60;[[InventoryItemDTO](/references/services/types/InventoryItemDTO)[], number]&#62;

This method is used to retrieve a paginated list of inventory items along with the total count of available inventory items satisfying the provided filters.

Example

To retrieve a list of inventory items using their IDs:

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function retrieveInventoryItems (ids: string[]) {
const inventoryModule = await initializeInventoryModule({})

const [inventoryItems, count] = await inventoryModule.listInventoryItems({
id: ids
})

// do something with the inventory items or return them
}

To specify relations that should be retrieved within the inventory items:

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function retrieveInventoryItems (ids: string[]) {
const inventoryModule = await initializeInventoryModule({})

const [inventoryItems, count] = await inventoryModule.listInventoryItems({
id: ids
}, {
relations: ["inventory_level"]
})

// do something with the inventory items or return them
}

By default, only the first 10 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function retrieveInventoryItems (ids: string[], skip: number, take: number) {
const inventoryModule = await initializeInventoryModule({})

const [inventoryItems, count] = await inventoryModule.listInventoryItems({
id: ids
}, {
relations: ["inventory_level"],
skip,
take
})

// do something with the inventory items or return them
}

Parameters

The filters to apply on the retrieved inventory items.
The configurations determining how the inventory items are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a inventory item.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<[InventoryItemDTO[], number]>

PromisePromise<[InventoryItemDTO[], number]>Required
The list of inventory items along with the total count.

listInventoryLevels

**listInventoryLevels**(selector, config?, context?): Promise&#60;[[InventoryLevelDTO](/references/services/types/InventoryLevelDTO)[], number]&#62;

This method is used to retrieve a paginated list of inventory levels along with the total count of available inventory levels satisfying the provided filters.

Example

To retrieve a list of inventory levels using their IDs:

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function retrieveInventoryLevels (inventoryItemIds: string[]) {
const inventoryModule = await initializeInventoryModule({})

const [inventoryLevels, count] = await inventoryModule.listInventoryLevels({
inventory_item_id: inventoryItemIds
})

// do something with the inventory levels or return them
}

To specify relations that should be retrieved within the inventory levels:

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function retrieveInventoryLevels (inventoryItemIds: string[]) {
const inventoryModule = await initializeInventoryModule({})

const [inventoryLevels, count] = await inventoryModule.listInventoryLevels({
inventory_item_id: inventoryItemIds
}, {
relations: ["inventory_item"]
})

// do something with the inventory levels or return them
}

By default, only the first 10 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function retrieveInventoryLevels (inventoryItemIds: string[], skip: number, take: number) {
const inventoryModule = await initializeInventoryModule({})

const [inventoryLevels, count] = await inventoryModule.listInventoryLevels({
inventory_item_id: inventoryItemIds
}, {
relations: ["inventory_item"],
skip,
take
})

// do something with the inventory levels or return them
}

Parameters

The filters to apply on the retrieved inventory levels.
The configurations determining how the inventory levels are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a inventory level.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<[InventoryLevelDTO[], number]>

PromisePromise<[InventoryLevelDTO[], number]>Required
The list of inventory levels along with the total count.

listReservationItems

**listReservationItems**(selector, config?, context?): Promise&#60;[[ReservationItemDTO](/references/services/types/ReservationItemDTO)[], number]&#62;

This method is used to retrieve a paginated list of reservation items along with the total count of available reservation items satisfying the provided filters.

Example

To retrieve a list of reservation items using their IDs:

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function retrieveReservationItems (ids: string[]) {
const inventoryModule = await initializeInventoryModule({})

const [reservationItems, count] = await inventoryModule.listReservationItems({
id: ids
})

// do something with the reservation items or return them
}

To specify relations that should be retrieved within the reservation items:

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function retrieveReservationItems (ids: string[]) {
const inventoryModule = await initializeInventoryModule({})

const [reservationItems, count] = await inventoryModule.listReservationItems({
id: ids
}, {
relations: ["inventory_item"]
})

// do something with the reservation items or return them
}

By default, only the first 10 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function retrieveReservationItems (ids: string[], skip: number, take: number) {
const inventoryModule = await initializeInventoryModule({})

const [reservationItems, count] = await inventoryModule.listReservationItems({
id: ids
}, {
relations: ["inventory_item"],
skip,
take
})

// do something with the reservation items or return them
}

Parameters

The filters to apply on the retrieved reservation items.
The configurations determining how the reservation items are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a reservation item.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<[ReservationItemDTO[], number]>

PromisePromise<[ReservationItemDTO[], number]>Required
The list of reservation items along with the total count.

restoreInventoryItem

**restoreInventoryItem**(inventoryItemId, context?): Promise&#60;void&#62;

This method is used to restore an inventory item or multiple inventory items that were previously deleted using the deleteInventoryItem method.

Example

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function restoreInventoryItem (
inventoryItems: string[]
) {
const inventoryModule = await initializeInventoryModule({})

await inventoryModule.restoreInventoryItem(
inventoryItems
)
}

Parameters

inventoryItemIdstring | string[]Required
The ID(s) of the inventory item(s) to restore.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<void>

PromisePromise<void>Required
Resolves when the inventory item(s) are successfully restored.

retrieveAvailableQuantity

**retrieveAvailableQuantity**(inventoryItemId, locationIds, context?): Promise&#60;number&#62;

This method is used to retrieve the available quantity of an inventory item within the specified locations.

Example

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function retrieveAvailableQuantity (
inventoryItemId: string,
locationIds: string[],
) {
const inventoryModule = await initializeInventoryModule({})

const quantity = await inventoryModule.retrieveAvailableQuantity(
inventoryItemId,
locationIds,
)

// do something with the quantity or return it
}

Parameters

inventoryItemIdstringRequired
The ID of the inventory item to retrieve its quantity.
locationIdsstring[]Required
The IDs of the locations to retrieve the available quantity from.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<number>

PromisePromise<number>Required
The available quantity of the inventory item in the specified locations.

retrieveInventoryItem

**retrieveInventoryItem**(inventoryItemId, config?, context?): Promise&#60;[InventoryItemDTO](/references/services/types/InventoryItemDTO)&#62;

This method is used to retrieve an inventory item by its ID

Example

A simple example that retrieves a inventory item by its ID:

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function retrieveInventoryItem (id: string) {
const inventoryModule = await initializeInventoryModule({})

const inventoryItem = await inventoryModule.retrieveInventoryItem(id)

// do something with the inventory item or return it
}

To specify relations that should be retrieved:

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function retrieveInventoryItem (id: string) {
const inventoryModule = await initializeInventoryModule({})

const inventoryItem = await inventoryModule.retrieveInventoryItem(id, {
relations: ["inventory_level"]
})

// do something with the inventory item or return it
}

Parameters

inventoryItemIdstringRequired
The ID of the inventory item to retrieve.
The configurations determining how the inventory item is retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a inventory item.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<InventoryItemDTO>

PromisePromise<InventoryItemDTO>Required
The retrieved inventory item.

retrieveInventoryLevel

**retrieveInventoryLevel**(inventoryItemId, locationId, context?): Promise&#60;[InventoryLevelDTO](/references/services/types/InventoryLevelDTO)&#62;

This method is used to retrieve an inventory level for an inventory item and a location.

Example

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function retrieveInventoryLevel (
inventoryItemId: string,
locationId: string
) {
const inventoryModule = await initializeInventoryModule({})

const inventoryLevel = await inventoryModule.retrieveInventoryLevel(
inventoryItemId,
locationId
)

// do something with the inventory level or return it
}

Parameters

inventoryItemIdstringRequired
The ID of the inventory item.
locationIdstringRequired
The ID of the location.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<InventoryLevelDTO>

PromisePromise<InventoryLevelDTO>Required
The retrieved inventory level.

retrieveReservationItem

**retrieveReservationItem**(reservationId, context?): Promise&#60;[ReservationItemDTO](/references/services/types/ReservationItemDTO)&#62;

This method is used to retrieve a reservation item by its ID.

Example

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function retrieveReservationItem (id: string) {
const inventoryModule = await initializeInventoryModule({})

const reservationItem = await inventoryModule.retrieveReservationItem(id)

// do something with the reservation item or return it
}

Parameters

reservationIdstringRequired
The ID of the reservation item.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ReservationItemDTO>

PromisePromise<ReservationItemDTO>Required
The retrieved reservation item.

retrieveReservedQuantity

**retrieveReservedQuantity**(inventoryItemId, locationIds, context?): Promise&#60;number&#62;

This method is used to retrieve the reserved quantity of an inventory item within the specified locations.

Example

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function retrieveReservedQuantity (
inventoryItemId: string,
locationIds: string[],
) {
const inventoryModule = await initializeInventoryModule({})

const quantity = await inventoryModule.retrieveReservedQuantity(
inventoryItemId,
locationIds,
)

// do something with the quantity or return it
}

Parameters

inventoryItemIdstringRequired
The ID of the inventory item to retrieve its reserved quantity.
locationIdsstring[]Required
The IDs of the locations to retrieve the reserved quantity from.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<number>

PromisePromise<number>Required
The reserved quantity of the inventory item in the specified locations.

retrieveStockedQuantity

**retrieveStockedQuantity**(inventoryItemId, locationIds, context?): Promise&#60;number&#62;

This method is used to retrieve the stocked quantity of an inventory item within the specified locations.

Example

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function retrieveStockedQuantity (
inventoryItemId: string,
locationIds: string[],
) {
const inventoryModule = await initializeInventoryModule({})

const quantity = await inventoryModule.retrieveStockedQuantity(
inventoryItemId,
locationIds,
)

// do something with the quantity or return it
}

Parameters

inventoryItemIdstringRequired
The ID of the inventory item to retrieve its stocked quantity.
locationIdsstring[]Required
The IDs of the locations to retrieve the stocked quantity from.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<number>

PromisePromise<number>Required
The stocked quantity of the inventory item in the specified locations.

updateInventoryItem

**updateInventoryItem**(inventoryItemId, input, context?): Promise&#60;[InventoryItemDTO](/references/services/types/InventoryItemDTO)&#62;

This method is used to update an inventory item.

Example

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function updateInventoryItem (
inventoryItemId: string,
sku: string
) {
const inventoryModule = await initializeInventoryModule({})

const inventoryItem = await inventoryModule.updateInventoryItem(
inventoryItemId,
{
sku
}
)

// do something with the inventory item or return it
}

Parameters

inventoryItemIdstringRequired
The ID of the inventory item.
The attributes to update in the inventory item.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<InventoryItemDTO>

PromisePromise<InventoryItemDTO>Required
The updated inventory item's details.

updateInventoryLevel

**updateInventoryLevel**(inventoryItemId, locationId, update, context?): Promise&#60;[InventoryLevelDTO](/references/services/types/InventoryLevelDTO)&#62;

This method is used to update an inventory level. The inventory level is identified by the IDs of its associated inventory item and location.

Example

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function updateInventoryLevel (
inventoryItemId: string,
locationId: string,
stockedQuantity: number
) {
const inventoryModule = await initializeInventoryModule({})

const inventoryLevel = await inventoryModule.updateInventoryLevels(
inventoryItemId,
locationId,
{
stocked_quantity: stockedQuantity
}
)

// do something with the inventory level or return it
}

Parameters

inventoryItemIdstringRequired
The ID of the inventory item.
locationIdstringRequired
The ID of the location.
The attributes to update in the location level.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<InventoryLevelDTO>

PromisePromise<InventoryLevelDTO>Required
The updated inventory level's details.

updateInventoryLevels

**updateInventoryLevels**(updates, context?): Promise&#60;[InventoryLevelDTO](/references/services/types/InventoryLevelDTO)[]&#62;

This method is used to update inventory levels. Each inventory level is identified by the IDs of its associated inventory item and location.

Example

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function updateInventoryLevels (items: {
inventory_item_id: string,
location_id: string,
stocked_quantity: number
}[]) {
const inventoryModule = await initializeInventoryModule({})

const inventoryLevels = await inventoryModule.updateInventoryLevels(
items
)

// do something with the inventory levels or return them
}

Parameters

The attributes to update in each inventory level.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<InventoryLevelDTO[]>

PromisePromise<InventoryLevelDTO[]>Required
The updated inventory levels' details.

updateReservationItem

**updateReservationItem**(reservationItemId, input, context?): Promise&#60;[ReservationItemDTO](/references/services/types/ReservationItemDTO)&#62;

This method is used to update a reservation item.

Example

import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"

async function updateReservationItem (
reservationItemId: string,
quantity: number
) {
const inventoryModule = await initializeInventoryModule({})

const reservationItem = await inventoryModule.updateReservationItem(
reservationItemId,
{
quantity
}
)

// do something with the reservation item or return it
}

Parameters

reservationItemIdstringRequired
The ID of the reservation item.
The attributes to update in the reservation item.
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ReservationItemDTO>

PromisePromise<ReservationItemDTO>Required
The updated reservation item.
Was this section helpful?