Skip to main content

Overview

The Inventory Module manages inventory tracking across multiple stock locations. It handles inventory items, stock levels per location, and inventory reservations for orders and carts. Key Features:
  • Inventory item management
  • Multi-location stock levels
  • Inventory reservations
  • Available quantity calculations
  • Backorder support
  • Stock adjustments and tracking

When to Use

Use the Inventory Module when you need to:
  • Track inventory across multiple warehouses
  • Reserve inventory for orders and carts
  • Check product availability
  • Manage stock levels per location
  • Support backorders
  • Adjust inventory quantities
  • Track incoming and stocked quantities

Data Models

InventoryItem

Represents a trackable inventory item (usually linked to product variants).
string
required
Unique inventory item identifier
string
Stock keeping unit identifier
string
Country of origin (two-letter ISO code)
string
Harmonized System code for customs
string
Manufacturer item number
string
Item material composition
number
Item weight
number
Item length
number
Item height
number
Item width
boolean
Whether item requires shipping
object
Additional custom data

InventoryLevel

Tracks stock quantity for an inventory item at a specific location.
string
required
Unique inventory level identifier
string
required
ID of the inventory item
string
required
ID of the stock location
BigNumber
required
Quantity physically stocked at location
BigNumber
required
Quantity reserved (calculated from reservations)
BigNumber
required
Quantity expected to arrive
BigNumber
Available quantity (calculated: stocked - reserved)
object
Additional custom data

ReservationItem

Reserves inventory for orders, carts, or other purposes.
string
required
Unique reservation identifier
string
required
ID of the inventory item
string
required
ID of the stock location
BigNumber
required
Reserved quantity
string
ID of the associated line item
string
Reservation description or reason
string
User ID who created the reservation
object
Additional custom data

Service Interface

The Inventory Module service is available at @medusajs/medusa/inventory.

Create Inventory Item

Create a new inventory item.
CreateInventoryItemDTO | CreateInventoryItemDTO[]
required
Inventory item data
string
Stock keeping unit
boolean
Whether item requires shipping
number
Item weight
number
Item length
number
Item height
number
Item width
InventoryItemDTO | InventoryItemDTO[]
The created inventory item(s)

Create Inventory Level

Set stock quantity at a location.
CreateInventoryLevelDTO | CreateInventoryLevelDTO[]
required
Inventory level data
string
required
ID of the inventory item
string
required
ID of the stock location
number
required
Quantity in stock
number
Quantity expected to arrive

Update Inventory Level

Adjust stock quantities.
UpdateInventoryLevelDTO
required
Update data
string
required
ID of the inventory item
string
required
ID of the stock location
number
New stocked quantity
number
New incoming quantity

Retrieve Inventory Level

Get inventory level for item at location.
string
required
ID of the inventory item
string
required
ID of the stock location
InventoryLevelDTO
The inventory level with available quantity

Create Reservation

Reserve inventory for an order or cart.
CreateReservationItemDTO | CreateReservationItemDTO[]
required
Reservation data
string
required
ID of the inventory item
string
required
ID of the stock location
number
required
Quantity to reserve
string
ID of the line item
string
Reservation description
ReservationItemDTO | ReservationItemDTO[]
The created reservation(s)

Update Reservation

Modify reservation quantity.

Delete Reservation

Release reserved inventory.

Confirm Inventory

Check if sufficient inventory is available.
string
required
ID of the inventory item
string[]
required
IDs of stock locations to check
number
required
Required quantity
boolean
Whether sufficient inventory is available

Retrieve Available Quantity

Get available quantity across locations.

Retrieve Stocked Quantity

Get total stocked quantity across locations.

Retrieve Reserved Quantity

Get total reserved quantity.

Integration Examples

With Product Module

Create inventory for product variants.

With Cart Module

Check availability and reserve inventory.

With Order Module

Adjust inventory on order completion.

With Stock Location Module

Manage inventory across multiple locations.

With Fulfillment Module

Reserve inventory for fulfillment.

Best Practices

  1. Reserved Quantity: The reserved_quantity field is calculated automatically from reservation items. Never update it directly - always create/delete reservations.
  2. Inventory Adjustments: Use adjustInventory for relative changes (add/subtract), updateInventoryLevels for absolute values.
  3. Reservation Lifecycle:
    • Create reservation when adding to cart
    • Update reservation when cart quantity changes
    • Delete reservation when:
      • Cart is completed (order created)
      • Cart item is removed
      • Cart expires
  4. Multi-Location: When checking availability, always specify which locations to check. This is crucial for multi-warehouse scenarios.
  5. Backorders: Set appropriate thresholds for when to allow backorders. Check available_quantity and compare with incoming_quantity.
  6. Bulk Operations: Use array input for bulk operations to improve performance when creating multiple inventory items or levels.