> ## Documentation Index
> Fetch the complete documentation index at: https://docs.omni.co/llms.txt
> Use this file to discover all available pages before exploring further.

# app:set-filters embed event

> Changes an embedded app's filter overrides without a reload.

> [!NOTE]
>
> This event can only be processed by apps. Sending this event to an iframe that contains a non-app Omni URL, such as a dashboard, will have no effect on the embedded page.

Changes the filter overrides on one or more of an embedded [app](https://docs.omni.co/visualize-present/apps)'s queries, without a reload. Only the fields included in the payload are affected. Fields the payload doesn't name keep their current value.

```json theme={null}
{
  "name": "app:set-filters",
  "payload": {
    "filters": {},
    "removeFilters": {}
  }
}
```

## Properties

**filters** `object`

Filter overrides to set, as an object of query name to field name to value. Omni applies each entry through `omni.query(name).setFilter()`, keyed the same way [`app:filter-changed`](https://docs.omni.co/embed/events/app-filter-changed) reports filter changes.

`null` is a filter value (is null), not a removal. To remove a filter, list it in `removeFilters` instead.

**removeFilters** `object`

Filter overrides to remove, as an object of query name to an array of field names. Omni applies each entry through `omni.query(name).removeFilter()`.

Omni applies removals before sets. If a field appears in both `filters` and `removeFilters`, it ends up set.

> [!NOTE]
>
> If a field has an override from this event and a document control that also filters it, Omni combines them with `AND` instead of the override replacing the control. Setting both on the same field can narrow a query to no rows.

## When to send this event

Send this event after Omni emits [`page:ready`](https://docs.omni.co/embed/events/page-ready).

If the app isn't ready when the event arrives, Omni keeps the event and applies it once the app is ready:

* **If you send a [`navigate`](https://docs.omni.co/embed/events/navigate) event**, Omni discards the filters that are still waiting for the page the user leaves.
* **If you send this event after a `navigate` event**, Omni applies the filters to the app where the navigation lands. If the navigation lands on a page without an app, Omni drops the filters.

## Example

This example sets a filter on the `orders` query and removes an existing filter from the same query:

```javascript wrap theme={null}
const iframe = document.querySelector("iframe#omni-app")

iframe.contentWindow.postMessage(
  {
    name: "app:set-filters",
    payload: {
      filters: {
        orders: {
          "users.country": "Spain",
        },
      },
      removeFilters: {
        orders: ["users.state"],
      },
    },
  },
  "https://yourcompany.embed-omniapp.co"
)
```
