Skip to main content
Runs create, update, and delete operations on a commission rate’s rules in parallel. Rules bind a rate to a reference (e.g. a seller, category, or product type) so the rate applies when an order line matches. Triggered by POST /admin/commission-rates/:id/rules.

Usage

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

const { result } = await batchCommissionRulesWorkflow(container).run({
  input: {
    commission_rate_id: "comrate_123",
    create: [{ reference: "seller", reference_id: "sel_123" }],
    update: [{ id: "comrule_456", reference_id: "sel_789" }],
    delete: ["comrule_999"],
  },
})

Input

commission_rate_id
string
required
The commission rate the rules belong to.
create
object[]
Rules to create.
update
object[]
Rules to update.
delete
string[]
IDs of rules to delete.

Result

result.created
CommissionRuleDTO[]
The created rules.
result.updated
CommissionRuleDTO[]
The updated rules.
result.deleted
string[]
IDs of the deleted rules.