Skip to main content
Creates one offer per entry: creates and links new inventory items (with optional starting stock levels) to the offer and the seller, ensures the master variant has a PriceSet, writes the offer’s prices onto that shared set scoped by an offer_id price rule, and links the price rows to the offer. Emits offer.created. Triggered by POST /vendor/offers and the vendor/admin offer batch routes.

Usage

import { createOffersWorkflow } from "@mercurjs/core/workflows"

const { result } = await createOffersWorkflow(container).run({
  input: {
    offers: [
      {
        seller_id: "sel_123",
        created_by: "member_123",
        variant_id: "variant_123",
        shipping_profile_id: "sp_123",
        sku: "ACME-TEE-M",
        inventory_items: [
          { stock_levels: [{ location_id: "sloc_123", stocked_quantity: 50 }] },
        ],
        prices: [{ amount: 1999, currency_code: "usd" }],
      },
    ],
  },
})

Input

offers
object[]
required
Offers to create.
additional_data
object
Custom data passed through to the workflow hooks.

Result

result
OfferDTO[]
The created offers.

Hooks

  • validate — runs first with { input }.
  • offersCreated — runs after creation with { offers, additional_data }.
createOffersWorkflow.hooks.offersCreated(async ({ offers, additional_data }) => {
  // react to new offers
})