> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mercurjs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Commission rates and rules

> How a commission rate expresses the marketplace's cut, how rules scope it, and what the global commission does.

A commission rate is the cut the marketplace takes from a sale, and rules decide which lines it applies to. Every marketplace has one global rate that covers everything, and you add scoped rates on top of it for specific sellers or parts of the catalog. Getting this model right decides what every seller is paid.

## A rate is a type and a value

A rate is a `CommissionRate` record (id prefix `comrate`). Its `type` says how to read its `value`, and two flags change the base amount the value applies to.

| `type` | How `value` is read | Line `amount` |
| - | - | - |
| `percentage` | A percent, so `10` means 10% | `base × value ÷ 100` |
| `fixed` | A flat amount per line item | The per-currency amount, or `value` |

The base amount is the line’s `subtotal`. A rate changes it with these flags:

* **`include_tax`**: adds the line’s `tax_total` to the base before the rate applies
* **`include_shipping`**: lets the rate commission shipping methods, and only takes effect on the global rate
* **`is_enabled`**: disabled rates are skipped during resolution

> [!WARNING]
>
> A fixed rate applies once per line item, not once per unit. A line with a quantity of 3 still gets one fixed amount. The `system` provider doesn’t cap a fixed amount at the line total.

Each rate also has a `name` and a unique `code`. When you create a rate without a `code`, the module builds one from the name plus a random suffix, so `"Standard"` becomes something like `standard-k3x9qa`.

```ts theme={null}
import { CommissionRateType } from "@mercurjs/types"
import { createCommissionRatesWorkflow } from "@mercurjs/core/workflows"

await createCommissionRatesWorkflow(container).run({
  input: [
    { name: "Standard", type: CommissionRateType.PERCENTAGE, value: 10 },
  ],
})
```

The example creates a 10% rate with no rules, which matches every line until a more specific rate wins.

## Per-currency amounts for fixed rates

A fixed rate holds one amount per currency in `CommissionRateValue` records (id prefix `comval`). During resolution, Mercur picks the value whose `currency_code` equals the order’s currency. When none matches, it uses the rate’s own `value`.

Percentage rates ignore `values`, because a percent is the same in every currency. A rate’s own `currency_code` field is separate: when it’s set, the rate only applies to orders in that currency.

| Rate | `values` | Order in `usd` | Order in `gbp` |
| - | - | - | - |
| fixed, `value: 3` | `usd: 2.5`, `eur: 2` | 2.5 per line | 3 per line |
| percentage, `value: 10` | ignored | 10% of base | 10% of base |

## Rules scope a rate

A rule is a `CommissionRule` record (id prefix `comrule`) that belongs to one rate. It’s a `reference` naming a dimension and a `reference_id` naming the record, for example `seller` and `sel_01JD8Q1234567`. A rate without rules matches every line. A rate with rules matches only the lines that satisfy them.

The five dimensions are:

* **`product`**: a master product id
* **`product_type`**: a product type id
* **`product_collection`**: a collection id
* **`product_category`**: a category id
* **`seller`**: the seller of the offer on the order line

[Rule matching](https://docs.mercurjs.com/platform/commission/concepts/rule-matching.md) explains how rules combine and which rate wins when several match.

## The global commission

The global commission is the rate with `is_default: true`. The module seeds it on boot when none exists, as a 0% percentage rate named `Default` with the code `default`. You raise it to set the marketplace’s baseline cut.

The global rate has rules that set it apart:

* **Always present**: `deleteCommissionRatesWorkflow` throws `NOT_ALLOWED` if you try to delete it
* **Fallback for items**: it has no rules, so it matches every line and loses to any scoped rate that also matches
* **Only shipping rate**: its `include_shipping` flag is the only one that produces shipping commission lines

> [!NOTE]
>
> Nothing stops you from setting `include_shipping` on a scoped rate, but the flag has no effect there. Shipping is resolved from the global rate alone.

## Related

* [How Mercur picks one rate for each line](https://docs.mercurjs.com/platform/commission/concepts/rule-matching.md)
* [Create a rate from your server code](https://docs.mercurjs.com/platform/commission/guides/create-a-rate.md)
* [All `CommissionRate` fields](https://docs.mercurjs.com/platform/commission/reference/data-models)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.