# Custom promotion rules

Commerce Layer provides a promotional engine built on top of two main resources: [promotions](https://docs.commercelayer.io/core-api-reference/promotions) and [promotion rules](https://docs.commercelayer.io/core-api-reference/promotion_rules).

Custom promotions rules add extreme flexibility when building your promotion logic. They are used to trigger the associated promotion only when some specific conditions on the order attributes and/or relationships are met (e.g. the customer is tagged with a specific tag, the SKU code of the products in the cart contains a specific sequence of character, etc.). Those conditions are defined using the `filters` attribute:

```
...
  "filters": {
    "{{predicate}}": {{value}},
    ...
  }
```

To compose the filter predicate you just need to follow the [same syntax](https://app.gitbook.com/s/-LgByaSP8eKjad-MIuHE/filtering-data) you use when filtering a collection of resources — `{{attributes}}_{{matcher}}`. You must specify filtering rules as a valid JSON object. List values for the `*_in` matcher need to be expressed as arrays.

{% hint style="warning" %}
Since if you try to filter a collection of resources by a [non-filterable](https://app.gitbook.com/s/-LgByaSP8eKjad-MIuHE/filtering-data#filterable-fields) or wrong/mispelled field you don't get any error and the API returns the full unfiltered list, make sure to use filters correctly (you can test them before via API). Otherwise, it would be like using no promotion rule and the promotion would be applied to [all the orders in scope](https://docs.commercelayer.io/core-api-reference/promotions#application-scope). The same happens if you create a custom promotion rule with no `filters` attribute.
{% endhint %}
