Skip to main content
Creates master catalog products, resolving Mercur attributes inputs into native product options and value links, linking each product to its eligible sellers (product_seller links), and recording a confirmed PRODUCT_ADD audit action attributed to created_by. Triggered by POST /admin/products and POST /vendor/products. Variants default to manage_inventory: false unless set explicitly. Emits product.created.

Usage

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

const { result } = await createProductsWorkflow(container).run({
  input: {
    products: [{ title: "Linen Shirt", seller_ids: ["sel_01H..."] }],
    created_by: "sel_01H...",
  },
})

Input

products
object[]
required
Products to create.
created_by
string
required
Actor id recorded on the PRODUCT_ADD audit action.
additional_data
object
Arbitrary data forwarded to the underlying Medusa create workflows and the productsCreated hook.

Result

result
ProductDTO[]
The created products, including their generated ids, options, and statuses.

Hooks

validate
hook
Runs first with { input, products } — use it to reject invalid payloads before anything is created.
productsCreated
hook
Runs after creation with { products, additional_data }.