# Scope

A condition is checked against a specific payload to determine whether it's a match or not. The payload can contain several instances of the resources specified in the condition's field. By default a condition is considered satisfied if at least one (i.e. **any**) of those instances matches the condition's requirements. If you want to override this behavior and ensure that a condition is satisfied only if **all** of those instances match the condition's requirements, you need to modify the condition scope.

## Example

Let's consider the [previous example](/rules-engine/conditions.md#example) and add the `scope` key with value `all` to the second condition to better understand how the matching criteria change:

{% tabs %}
{% tab title="Any (default)" %}
The following couple of conditions check if an order is tagged as `dropship` *and* contains at least a line item whose SKU code starts with the string `TSHIRT`:

```json
"conditions": [
  {
    "field": "order.tags.name",
    "matcher": "eq",
    "value": "dropship"
  },
  {
    "field": "order.line_items.sku.code",
    "matcher": "start_with",
    "value": "TSHIRT",
    "group": "tshirts"
  }
]
```

{% endtab %}

{% tab title="All" %}
The same couple of conditions now check if an order is tagged as `dropship` and the SKU code of *all* its line items associated with an SKU starts with the string `TSHIRT`:

<pre class="language-json"><code class="lang-json">"conditions": [
  {
    "field": "order.tags.name",
    "matcher": "eq",
    "value": "dropship"
  },
  {
    "field": "order.line_items.sku.code",
    "matcher": "start_with",
    "value": "TSHIRT",
<strong>    "scope": "all",
</strong>    "group": "tshirts"
  }
]
</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/conditions/scope.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.
