> 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/conditions/scope.md).

# Scope

How to change a condition's 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
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/conditions/scope.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.
