> For the complete documentation index, see [llms.txt](https://docs.commercelayer.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.commercelayer.io/rules-engine/core-api-integration/price-rules.md).

# Price rules

How the Rules Engine integration with Commerce Layer Core API price lists resource works behind the scenes

When you [create or patch a price list](/rules-engine/resources/price-lists.md) 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](/core-api-reference/prices/object.md), containing only the attributes and relationships needed to evaluate the rule [conditions](/rules-engine/conditions.md) and apply the related [actions](/rules-engine/actions.md) 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 %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.commercelayer.io/rules-engine/core-api-integration/price-rules.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
