> For the complete documentation index, see [llms.txt](https://docs.fulfillmenttools.com/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fulfillmenttools.com/documentation/apis/context.md).

# Context

A context limits where entities, attributes, or specific properties are considered when fulfillmenttools executes business logic.

The following entities support contexts:

* Listings ([sales prices](/documentation/getting-started/facilities/prices.md#sales-price), [out-of-stock behavior](/documentation/by-pillar/global-inventory-hub/listing.md#out-of-stock-behaviour))
* [Facility discounts](/documentation/getting-started/facilities/prices.md)
* [Facility connections](/documentation/by-pillar/advanced-order-routing/complex-routing-with-combinatorics/network-model/facility-connection.md)
* [Roles](/documentation/getting-started/authentication-and-authorization/user-management.md#role-level-context-limitation)

These entities contain a `context` field. The system evaluates the context at runtime to determine if the object applies to the current use case. If no context is defined, the system sets no limitations.

The structure of the `context` is as follows:

```json
{
    ...
    "context": [
        {
            "type": "FACILITY",
            "operator": "NOT",     // optional, not available in every entity
            "values": [
                "string"
            ]
        },
        ...
    ]
}
```

* Entries in the `context` array are joined with a logical `AND`.
* Items in the `values` array are joined with a logical `OR`.
* Each entity supports different context types, such as `CATEGORY`, `FACILITY_ID`, and `FACILITY_GROUP`.
* The `operator` field is optional, and the only supported value is `NOT`. Support for this field varies by entity.

### Example <a href="#example" id="example"></a>

This example shows how to create a discount that applies only to certain facility groups and excludes a specific article category.

Adding a `context` to the discount defines the conditions under which the system considers it when routing an order.

See the [facility discounts article](/documentation/getting-started/facilities/prices.md) for more information related to discounts.

```json
{
    // discount entity
    ...
    "context": [
        {
            "type": "FACILITY_GROUP",
            "values": [
                "uuid-facility-group1",
                "uuid-facility-group2"
            ]
        },
        {
            "type": "CATEGORY",
            "operator": "NOT",
            "values": [
                "uuid-category1"
            ]
        }
    ]
}
```

In this example, the system applies the discount when:

* The facility is in facility group `uuid-facility-group1` **OR** `uuid-facility-group2`

**AND**

* The article category is **NOT** `uuid-category1`.

<br>


---

# 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.fulfillmenttools.com/documentation/apis/context.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.
