# Order rules

When you [create a flex promotion](/rules-engine/resources/promotions.md) filling up the related `rules` object you're basically setting up **order rules**, meaning that the Core API integration will check your rules against the payload of an order. For performance reasons, it is a lightweight version of the [full order payload](/core-api-reference/orders/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" %}
The resulting promotion (i.e. the rule actions) will be applied to all the orders that satisfy the rule conditions.
{% endhint %}

{% hint style="success" %}
The structure, constraints, and data types for the order rules JSON dataset are described in the public [Order Rules JSON schema](https://core.commercelayer.io/api/public/schemas/order_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 order rule offers free shipping and a 10% discount on the line items associated with an SKU if the email of the customer belongs to a specified domain:

<pre class="language-json"><code class="lang-json">{
  "rules": [
    {
      "name": "Get 10% off item cost plus free shipping for company customers",
      "conditions": [
        {
<strong>          "field": "order.customer_email",
</strong>          "matcher": "matches",
          "value": ".*@mybrand.com"
        }
      ],
      "actions": [
        {
          "type": "percentage",
<strong>          "selector": "order.line_items.sku",
</strong>          "value": "0.1"
        },
        {
          "type": "percentage",
<strong>          "selector": "order.line_items.shipment",
</strong>          "value": "1"
        }
      ]
    }
  ]
}
</code></pre>

{% endtab %}

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

* The order's `customer_email`
* The order's line items of type `skus` and `shipments`

<pre class="language-json"><code class="lang-json">{
  "order": {
    "id": "oXkhYLlzgE",
<strong>    "customer_email": "john@mybrand.com",
</strong><strong>    "line_items": [
</strong>      {
        "id": "dKdhYLlzgE",
        "quantity": 1,
<strong>        "sku": { "id": "dKfhgdlzgE" }
</strong>      },
      {
        "id": "eKfhYFkztQ",
        "quantity": 2,
<strong>        "sku": { "id": "sDfhYFkcfR" }
</strong>      },
      {
        "id": "kKffYAkzdW",
        "quantity": 2,
<strong>        "sku": { "id": "sWfhYDccwQ" }
</strong>      },
      {
        "id": "adfSYwAzar",
        "quantity": 1,
<strong>        "shipment": { "id": "dwFhYDGtwE" }
</strong>      }
    ]
  }

</code></pre>

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
