> For the complete documentation index, see [llms.txt](https://help.citrusad.com/retail-media-interface/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.citrusad.com/retail-media-interface/integration/pt-br/data-api/api-overview/ad-generation-filtering-1.md).

# Filtragem de geração de anúncios

Ao solicitar anúncios, você deve buscar dar suporte à filtragem do seu cliente por marca, categorias, restrições alimentares e muito mais. Se o seu site de e-commerce suportar filtragem que usa a funcionalidade e/ou, Epsilon Retail Media pode dar suporte a isso com o parâmetro adicional `filterMode` em sua solicitação.

Existem dois tipos de filtragem, conforme descrito abaixo.

## `andOr` filtragem (recomendada)

`andOr` a filtragem é útil para contextos em que o usuário usou filtros avançados em sua busca. Ela permite uma formatação de contexto mais simples, enquanto ainda dá suporte à filtragem avançada. Este método segue a estrutura descrita abaixo:

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

Uma solicitação de exemplo é parecida com a seguinte:

```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
}
```

Esta abordagem geralmente é mais fácil para os varejistas encadearem solicitações por tipo quando os clientes usam filtros avançados em suas buscas.

{% hint style="warning" %}
Você deve especificar o `filterMode` of `andOr` para que esta funcionalidade funcione corretamente.
{% endhint %}

## `orAnd` filtragem (modo padrão)

O método padrão de filtragem de produtos segue a estrutura descrita abaixo:

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

O mesmo exemplo apresentado acima seria enviado como uma solicitação como a abaixo:

```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" %}
Você não precisa especificar um `filterMode` of `orAnd` para esta funcionalidade, pois este é o comportamento padrão.
{% endhint %}


---

# 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 dynamically by asking a question.

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

```
GET https://help.citrusad.com/retail-media-interface/integration/pt-br/data-api/api-overview/ad-generation-filtering-1.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
