# Price rules

When you [create or patch a price list](https://docs.commercelayer.io/rules-engine/resources/price-lists) filling up the related `rules` object you're basically setting up **price rules**, meaning that the Core API integration will check your rules against the payload of a price. For performance reasons, it is a lightweight version of the [full price payload](https://app.gitbook.com/s/RWJeylueWkzLadK710XZ/prices/object), containing only the attributes and relationships needed to evaluate the rule [conditions](https://docs.commercelayer.io/rules-engine/conditions) and apply the related [actions](https://docs.commercelayer.io/rules-engine/actions) based on the values specified in the rule keys (e.g. fields, selectors, etc.).

{% hint style="info" %}
Adding a price rule to a price list will result in applying the discounts due to the rule actions to all the price list's prices that satisfy the rule conditions.
{% endhint %}

{% hint style="success" %}
The structure, constraints, and data types for the price rules JSON dataset are described in the public [Price Rules JSON schema](https://core.commercelayer.io/api/public/schemas/price_rules). Feel free to use it to implement validation scripts for your rules, automatically generate code, or just better understand how the Rules Engine works behind the scenes.
{% endhint %}

### Example

{% tabs %}
{% tab title="Rules" %}
The following rule offers a 20% discount on the prices of some promotional products (identified by a prefix in their SKU code) for the price lists associated with specific markets:

<pre class="language-json"><code class="lang-json">{
  "rules": [
    {
      "name": "20% discount off promo products in EU and AU markets",
      "conditions": [
        {
<strong>          "field": "price.sku.code",
</strong>          "matcher": "start_with",
          "value": "PROMO"
        },
        {
<strong>          "field": "price.jwt_markets.name",
</strong>          "matcher": "is_in",
          "value": ["Europe", "Australia"]
        }
      ],
      "actions": [
        {
          "type": "percentage",
<strong>          "selector": "price",
</strong>          "value": "0.2"
        }
      ]
    }
  ]
}
</code></pre>

{% endtab %}

{% tab title="Price" %}
The lightweight version of the price payload the rule is checked against by the Core API integration will contain only the strictly necessary information to evaluate the rule matching:

* The SKU associated with the price and its `code`
* The market associated with the JWT and its `name`

<pre class="language-json"><code class="lang-json">{
  "price": {
    "id": "lpeNYUvMTE",
<strong>    "sku": {
</strong>      "id": "klzEhmRAMM",
<strong>      "code": "PROMOTSHIRT"
</strong>    },
<strong>    "jwt_markets": [
</strong>      {
        "id": "jugEskRJSa",
<strong>        "name": "Europe"
</strong>      }
    ]
  }
}
</code></pre>

{% endtab %}
{% endtabs %}
