Inventory Module in Medusa Flows
In this guide, you'll learn how Medusa uses the Inventory Module in its commerce flows, including product variant creation, adding to cart, order placement, order fulfillment, and order return.
Product Variant Creation#
When a product variant is created and its manage_inventory property's value is true and the variant's inventory_items are set, the Medusa application creates an inventory item associated with that product variant.

Add to Cart#
When a product variant with manage_inventory set to true is added to the cart, the Medusa application checks whether there's sufficient stocked quantity. If not, an error is thrown and the product variant won't be added to the cart.

Order is Placed#
When an order is placed, the Medusa application creates a reservation item for each product variant with manage_inventory set to true.

Order Fulfillment#
When an item in an order is fulfilled and the associated variant has its manage_inventory property set to true, the Medusa application performs the following for each of the item's reservations:
- Subtracts the fulfilled quantity, multiplied by the inventory item's required quantity, from the
stocked_quantityin the inventory level associated with the variant's inventory item. - Decreases the
reserved_quantityof the inventory level by the same quantity. - Deletes the reservation item if its full quantity is fulfilled, or decreases the reservation item's quantity if only part of it is fulfilled.
Learn more in the Reservations Lifecycle guide.
manage_inventory enabled must have an associated inventory reservation, otherwise the createOrderFulfillmentWorkflow throws an error. Reservations are created automatically when an order is placed through the completeCartWorkflow. If you create an order with a workflow that doesn't create reservations, such as createOrderWorkflow, use the createReservationsWorkflow to create reservations before fulfilling the order, and set each reservation's line_item_id to the order item's ID.
Order Return#
When an item in an order is returned and the associated variant has its manage_inventory property set to true, the Medusa application increments the stocked_quantity of the inventory item's level with the returned quantity.

Dismissed Returned Items#
If a returned item is considered damaged or is dismissed, its quantity doesn't increment the stocked_quantity of the inventory item's level.