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

# JavaScript API

> Open and close the embed panel from your own code

# JavaScript API

Once your embed script is loaded on the page, a small JavaScript API is available at `window.UpdatesPage` for controlling the slide-over panel programmatically.

<Note>
  Embeds are available on the **Business** plan. See [Installing an Embed](/embeds/widget) for setup.
</Note>

## Methods

Both methods take your embed ID (the same ID that appears in your embed's script tag URL).

### Open the panel

```javascript theme={null}
window.UpdatesPage.open("<embed-id>")
```

### Close the panel

```javascript theme={null}
window.UpdatesPage.close("<embed-id>")
```

## Using a custom trigger

By default, the embed renders its own trigger button where the script tag is placed. To use your own button, link, or menu item instead:

1. In the dashboard, go to **Account → Embeds** and open your embed in the editor
2. Set the **action style** to **custom** — this hides the default button
3. Call `window.UpdatesPage.open("<embed-id>")` from your own UI

```html theme={null}
<button id="whats-new">What's New</button>

<script>
  document.querySelector('#whats-new').addEventListener('click', () => {
    window.UpdatesPage.open("<embed-id>")
  })
</script>
```

## Example: open from a navigation menu

```javascript theme={null}
// Open the posts panel when a nav item is clicked
document.querySelector('#nav-whats-new').addEventListener('click', (event) => {
  event.preventDefault()
  window.UpdatesPage.open("<embed-id>")
})
```

## Multiple embeds

If you have more than one embed on a page, pass the ID of the embed you want to control:

```javascript theme={null}
window.UpdatesPage.open("embed-id-one")
window.UpdatesPage.close("embed-id-two")
```

<Tip>
  Make sure the embed's script tag has loaded before calling `window.UpdatesPage` — place your code after the script tag, or wait for page load.
</Tip>
