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

# Widget events

> The messages a widget posts to your page: what happened inside it, for your own UI

A widget tells your page what happened inside it, for example that a restaurant saved a template or sent a campaign.
Use the events to update your own UI.

## Example

```js theme={null}
Minimo.mountWidget({
  url: session.urls.campaigns,
  container: '#minimo-campaigns',
  onEvent: function (event) {
    if (event.type === 'campaign.sent') {
      console.log('Campaign', event.data.campaignId, 'sent to', event.data.recipients, 'guests');
    }
  },
});
```

`mountWidget` keeps only the messages of its own iframe and calls `onEvent({ widget, type, data })`. Without the SDK,
listen to `message` events yourself and accept only those from `https://api.minimo.it` with
`source: 'minimo-widget'`.

## All events

Every message is `{ source: 'minimo-widget', widget, type, data }`, posted only to your allowed origins.

| `widget` | `type` | `data` |
| - | - | - |
| any | `ready` | `count` (items shown) |
| any | `resize` | `height` (handled by `mountWidget`) |
| any | `error` | `message` or `code` |
| `templates` | `template.customized` | `templateId` (the tenant copy), `masterId` |
| `templates` | `template.reset` | `masterId` |
| `templates` | `template.previewed`, `editor.opened` | `templateId` |
| `templates` | `automation.toggled` | `tenant`, `rule`, `enabled`: the tenant switched an [automatic send](https://docs.minimo.it/embedded/automations.md) on or off (saved by Minimo) |
| `editor` | `ready`, `template.saved`, `closed` | `templateId` |
| `campaigns` | `campaign.created` | `campaignId` |
| `campaigns` | `contact.added` | `contactId` |
| `campaigns` | `campaign.sent` | `campaignId`, `status`, `submissionId`, `recipients` |
| `contacts` | `contact.added`, `contact.updated`, `contact.removed`, `contacts.exported` | see [Contacts widget](https://docs.minimo.it/embedded/widget-contacts.md#events) |
| `brand` | `ready` | `tenant` |
| `brand` | `brand.saved` | `tenant`, `fields` (the fields the restaurant changed, e.g. `logoUrl`, `brandColor`), `appliedTo` (personalized messages recolored) |
| `stats` | `ready` | `period` (7, 30 or 90), `sent` |
| `whatsapp` | `ready` | `tenant`, `status` (`not_connected`, `connecting`, `connected`, `error`) |
| `whatsapp` | `whatsapp.connected` | `tenant`, `number` |
| `whatsapp` | `whatsapp.error` | `tenant`, `code` (see [WhatsApp widget](https://docs.minimo.it/embedded/widget-whatsapp.md#errors)) |
| `whatsapp` | `whatsapp.connect_requested` | `tenant`, `url`: the browser blocked the setup window, open `url` yourself from a click |

Events are a convenience for your UI. To know the real state from your backend, use the API (tenant profile, rules, statistics, message list).

## Next step

[Automatic messages widget](https://docs.minimo.it/embedded/widget-automatic-messages.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.