createOffersWorkflow that creates the Offer record, its
inventory items, and its price rows, and wires up every link in one run. Run it
from any place that has access to the Medusa container.
Run the workflow
src/api/custom/route.ts
Each offer must reference an existing master
variant_id and include at least
one inventory_items entry. The SKU must be unique within the store.
Reusing an existing (seller_id, sku) pair is rejected.What the workflow wires up
A single run does more than insert a row:- Creates a new
InventoryItemperinventory_itemsentry (with anystock_levels) and links each to the offer. Remember, inventory links to the offer, not the variant. - Writes each price onto the master variant’s shared price set, stamped with an
offer_idrule, and links the price rows to the offer. - Links the offer to its store, product, variant, and shipping profile.
- Emits
offer.created.
Attach custom data
The workflow accepts anadditional_data payload that is passed to its
offersCreated hook, letting you persist marketplace-specific data alongside the
offer without forking the workflow.