> ## 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-controls embed event

> Updates one or more document controls on an embedded app 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.

Updates one or more document controls on an embedded [app](https://docs.omni.co/visualize-present/apps), without a reload. This event doesn't have an effect if document controls are disabled.

```json theme={null}
{
  "name": "app:set-controls",
  "payload": {
    "controls": {},
    "clearControls": []
  }
}
```

## Properties

**controls** `object`

Control values to set, as an object of control ID to value, in the same form `omni.setControl()` accepts. An ID that doesn't match any control on the app is ignored.

> [!TIP]
>
> A value from [`app:control-changed`](https://docs.omni.co/embed/events/app-control-changed)'s `controls` payload can be sent back here as-is.

**clearControls** `string[]`

An array of control IDs to clear. Omni applies each entry through `omni.clearControl()`. An ID that appears in both `controls` and `clearControls` is set, not cleared.

## 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 more than one event**, Omni applies the events in the order that you sent them. If two events set the same control, the later event wins.
* **If you send a [`navigate`](https://docs.omni.co/embed/events/navigate) event**, Omni discards the controls that are still waiting for the page the user leaves.
* **If you send this event after a `navigate` event**, Omni applies the controls to the app where the navigation lands. If the navigation lands on a page without an app, Omni drops the controls.

## Example

This example sets a brand control directly and clears a region control:

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

iframe.contentWindow.postMessage(
  {
    name: "app:set-controls",
    payload: {
      controls: {
        brand: "Levi",
      },
      clearControls: ["region"],
    },
  },
  "https://yourcompany.embed-omniapp.co"
)
```
