> For the complete documentation index, see [llms.txt](https://developers.citrusad.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.citrusad.com/integration/reference/ad-generation-filtering-1.md).

# Ad generation filtering

{% hint style="info" %}
Epsilon Retail Media's documentation is now centralized with our knowledgebase!

For up to date guides, please view [this page](https://help.citrusad.com/retail-media-interface/integration/data-api/api-overview/ad-generation-filtering-1) in the new Integration APIs space of our documentation.
{% endhint %}

When requesting ads, you should aim to support your customer's filtering by brand, categories, dietary restrictions, and more. If your e-commerce site supports filtering that uses the and/or functionality, Epsilon Retail Media can support this with the additional `filterMode` parameter in your request.

There are two types of filtering, as outlined below.

## `andOr` filtering (recommended)

`andOr` filtering is useful for contexts where the user has filtered deep in their search. It allows simpler context formatting, while still supporting deep filtering. This method follows the structure outlined below:

```json
"productFilters": [
     [ "" OR "" ] AND [ "" OR "" ] AND [ "" OR "" ]
    ],
    "options": {
     "filterMode": "AndOr"
    },
```

An example request looks like the following:

```http
POST $BASE_URL/v1/ads/generate HTTP/1.1
accept: application/json
content-type: application/json
Authorization: Basic <API_KEY>
{
    "customerId": "wertg5432a",
    "sessionId": "ec9-4e07-881d-3e9",
    "placement": "category",
    "catalogId": "628dbe95-2ec9-4e07-881d-3e9f92ab2e0b",
    "productFilters": [
     	 ["category:bread"],
    	 ["brand:brandA","brand:brandB"],
    	 ["price:below $10"],
    	 ["nutrition:organic","nutrition:vegan"]
    ],
    "options": {
   							 "filterMode": "AndOr"
 							 },
    "maxNumberOfAds": 3
}
```

This approach is typically easier for retailers to chain requests by type when customers filter deep into their searches.

{% hint style="warning" %}
You must specify the `filterMode` of `andOr` for this functionality to work correctly.
{% endhint %}

## `orAnd` filtering (default mode)

The default method of filtering product filters follows the structure outlined below:

```json
"productFilters": [
     [ "" AND "" ], OR [ "" AND "" ], OR [ "" AND "" ]
    ],
    "options": {
     "filterMode": "OrAnd"
    },
```

The same example presented above would be sent as a request like the below:

```http
POST $BASE_URL/v1/ads/generate HTTP/1.1
accept: application/json
content-type: application/json
Authorization: Basic <API_KEY>
{
    "customerId": "wertg5432a",
    "sessionId": "ec9-4e07-881d-3e9",
    "placement": "category",
    "catalogId": "628dbe95-2ec9-4e07-881d-3e9f92ab2e0b",
    "productFilters": [
     	 ["category:bread","brand:brandA","price:below $10","nutrition:organic"],
     	 ["category:bread","brand:brandB","price:below $10","nutrition:organic"],
     	 ["category:bread","brand:brandA","price:below $10","nutrition:vegan"],
     	 ["category:bread","brand:brandB","price:below $10","nutrition:vegan"],
    ],
    "options": {
   							 "filterMode": "OrAnd"
 							 },
    "maxNumberOfAds": 3
}
```

{% hint style="info" %}
You don’t need to specify a `filterMode` of `orAnd` for this functionality, as it is the default behaviour.
{% endhint %}
