Skip to main content
In this guide, you’ll learn how to change the inventory items linked to an existing offer from your own server code. Because inventory links to the offer (not the variant), the set of inventory items backing an offer is managed through the offer ↔ inventory_item link. batchOfferInventoryItemsWorkflow applies creates, updates, and deletes to that link in a single run.

Run the batch workflow

src/api/custom/offer-inventory/route.ts
The result reports the links that were created, updated, and deleted.

Rules the workflow enforces

  • Items in create must not already be linked to the offer; items in update and delete must already be linked.
  • An inventory_item_id can’t appear in more than one section, and can’t be duplicated within a section.
  • create items must reference existing InventoryItem records; required_quantity defaults to 1.
  • Deleting an item that isn’t linked to the offer surfaces a 404 rather than silently no-op’ing.
This workflow manages the links between an offer and existing inventory items and their required_quantity. To create brand-new inventory items with starting stock as part of listing an offer, pass inventory_items to createOffersWorkflow instead.
The workflow emits offer.updated and exposes an offerInventoryItemsBatched hook carrying the offer_id, the batch result, and any additional_data you passed in.