Skip to main content
Pass a list of entries to createOffersWorkflow when you onboard a store’s catalog or run an import. One run creates every offer or none of them.

Before you begin

You need these records in place:
  • A store and a member: the seller_id and the created_by member id for every entry
  • Master variants: one variant_id per row you import
  • A shipping profile and a stock location: both owned by the store
Keep each run to one store. The workflow links all new inventory items to the store of the first entry, so mixing stores in one run assigns the other stores’ stock to the wrong store.

Import a store’s rows

1

Map your rows to offer entries

Turn each source row into a CreateOfferDTO from @mercurjs/types.
src/lib/to-offers.ts
Each entry is independent and carries its own SKU, price, and starting stock.
2

Run the workflow once for the batch

Call the workflow with the mapped entries.
src/api/admin/custom/offers/import/route.ts
The run emits one offer.created event per offer.
The batch is all or nothing. A missing variant, an entry without inventory items, or a SKU the store already uses fails the run, and compensation removes everything it created.

Update offers in bulk

updateOffersWorkflow takes the same array shape, keyed by offer id. Every field except id is optional.
The first entry renames a SKU and keeps its prices. The second replaces that offer’s prices: send an existing price id to update a row in place, since rows left out are deleted. updated_by reaches the offersUpdated and offerPricesUpserted hooks.

Delete offers in bulk

deleteOffersWorkflow takes a list of ids and soft-deletes the offer rows.
The run emits offer.deleted per offer. Its offersDeleted hook gets a snapshot of each offer and its prices taken before the delete. The workflow has no step that removes the offer’s prices or inventory items.

Next steps