# Webhooks

The webhook events an IMAP mailbox sends for new mail, tracked sends and its health, and how polling and reconnection change when they arrive.

Zernio polls each IMAP inbox every minute and sends what it finds as ordinary webhooks. Subscribe with `POST /v1/webhooks/settings` and the event names below.

## Events an IMAP mailbox sends

| Event | When it fires |
|-------|---------------|
| `message.received` | New mail arrives in the inbox |
| `message.sent` | Mail is sent through the API |
| `conversation.started` | The first message of a new thread is stored |
| `email.opened`, `email.link_clicked`, `email.thread_replied` | A tracked message is opened, clicked or answered |
| `email.send_failed` | A scheduled email could not be sent at its time |
| `account.disconnected` | The mailbox needs reconnecting |
| `account.connected` | The mailbox connects, or reconnects with `reconnected: true` |

## How it behaves

- Inbox events arrive one to two minutes after the mail does.
- A rejected password is tried again five minutes later. After two failures, or 30 minutes without reaching the server, polling stops so the provider does not lock the mailbox.
- `account.disconnected` then carries `reasonCode` (`auth_failed`, `imap_disabled`, `tls_error` or `unreachable`) and `reconnectUrl`, a hosted link valid for seven days.
- After a reconnect, polling continues from the last message it saw. Mail from the last 72 hours fires `message.received`; older mail does not.
- When a reconnect finds the address now uses Google or Microsoft, the user signs in there instead. The new account's `account.connected` carries `replacedAccountId`, and the IMAP account is retired with `account.disconnected` and `reasonCode: "replaced"`.

## Related

- [Inbox webhooks](/webhooks/inbox)
- [Connect](/platforms/imap/connect)