Skip to main content
Skip to main content

retrieveInventoryItem - Inventory Module Reference

This documentation provides a reference to the retrieveInventoryItem method. This belongs to the Inventory Module.

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

PromisePromise<InventoryItemDTO>Required
The retrieved inventory item.
Was this section helpful?