Skip to main content
In this guide, you’ll learn how to create a commission rate from your own server code. This is useful in a seed script, a custom API route, or an onboarding flow. Mercur exposes a createCommissionRatesWorkflow that creates one or more CommissionRate records. Run it from any place that has access to the Medusa container.

Run the workflow

src/api/custom/route.ts
The workflow takes an array of rates and returns the created records. When you omit code, the module generates a unique one from name.

Create a fixed, per-currency rate

For a flat fee, use CommissionRateType.FIXED and pass per-currency values. The scalar value is the fallback when no currency matches.

Scope the rate

A rate created without rules is a catch-all. To scope it to part of the catalog, attach rules with batchCommissionRulesWorkflow.
Only the global rate (is_default) may commission shipping. To let the global rate take a cut of shipping, update it with include_shipping: true via updateCommissionRatesWorkflow.