# Events

Every event type and its payload: server events and connect window events.

## Server events

An event is recorded for everything that happens to a connection, a sign-in or an async run, whether or not you have a webhook. [List them](https://sidelatch.com/docs/api#ref-get-v1-events) for 30 days. Set `webhook_url` in [settings](https://sidelatch.com/docs/api#ref-patch-v1-settings) and each one is also POSTed to you. Events carry ids and statuses only, never portal data or credentials.

| Event | When | `data` |
|---|---|---|
| `connection.connected` | A user linked an account, or signed in again on one that needed it (`relinked: true`). | `connection_id, user_id, portal, status, relinked` |
| `connection.reconnect_needed` | The portal refused the stored login and only the user can fix it. Sent once, when the status changes. | `connection_id, user_id, portal, status, reason` |
| `connection.deleted` | A connection was disconnected and its stored login deleted. | `connection_id, user_id, portal, status` |
| `link.challenge_required` | During sign-in, the portal asked the user for a step: a code, a choice, a phone approval, security questions or a CAPTCHA. | `user_id, portal, kind` |
| `link.failed` | A sign-in did not finish. `reason` is `auth_failed` (wrong password or code), `blocked` (the portal wants a check on its own page), `abandoned` (the user left the hosted browser) or `busy`. | `user_id, portal, reason` |
| `run.completed` | An async run finished. Read the result with `GET /v1/runs/{id}`. | `run_id, connection_id, user_id, portal, operation, status` |
| `run.failed` | An async run failed. `error` is one of the error codes. | `run_id, connection_id, user_id, portal, operation, status, error` |
| `build.completed` | A portal build finished: `status` is `ready`, `partial`, `needs_operator` or `published`. | `build_id, status, portal` |
| `webhook.test` | You sent a test event from the console or the API. | `message` |

**Event body**

```json
{
  "id": "evt_1f0c...",
  "type": "connection.reconnect_needed",
  "created": 1795700000,
  "data": {
    "connection_id": "conn_8f2c41d07a9b4e6f",
    "user_id": "agency-42",
    "portal": "demo_carrier",
    "status": "reconnect_needed",
    "reason": "wrong_password"
  }
}
```

Every event has the same envelope: `id`, `type`, `created` (unix seconds) and `data`, whose fields are listed above. [The API](https://sidelatch.com/docs/api#ref-get-v1-events-event-id) also returns `object`, `created_at` and the delivery attempts.

## Connect window events

The connect window reports to your page as it goes: `link.js` and `@sidelatch/link` pass these to `onEvent(name, data)`, for your own funnel analytics. They never carry a login or anything the portal returned.

| Name | When | `data` |
|---|---|---|
| `opened` | The sign-in form is showing. | `{}` |
| `submitted` | The user sent their login. | `{}` |
| `challenge` | The portal asked for a verification step. | `{kind}`: `code`, `choice`, `push`, `questions` or `captcha` |
| `browser` | The portal's own sign-in page opened in a hosted browser. | `{}` |
| `error` | Something went wrong; the user can usually try again. | `{code, message}`, `code` from the [error codes](https://sidelatch.com/docs/errors) |
| `connected` | The account is linked. `onSuccess(connectionId, {portal})` follows. | `{connectionId, portal}` |
| `exit` | The window closed without a connection. `onExit(error)` follows. | `{error}`: the last `{code, message}`, or null |

If you embed `/connect` in your own iframe instead, these arrive as `postMessage` data: `{type: "sidelatch:event", name, ...data}`, `{type: "sidelatch:connected", connection_id, portal}` and `{type: "sidelatch:exit", error}`. Check that `event.origin` is your Sidelatch host before you trust one.

---

Sidelatch docs: [Docs](https://sidelatch.com/docs.md) · [Quick start](https://sidelatch.com/docs/quickstart.md) · [Concepts](https://sidelatch.com/docs/concepts.md) · [The connect window](https://sidelatch.com/docs/guides/connect-window.md) · [Webhooks](https://sidelatch.com/docs/guides/webhooks.md) · [MCP for AI agents](https://sidelatch.com/docs/guides/mcp.md) · [Writes](https://sidelatch.com/docs/guides/writes.md) · [Build a portal](https://sidelatch.com/docs/guides/build-a-portal.md) · [Events](https://sidelatch.com/docs/events.md) · [Errors](https://sidelatch.com/docs/errors.md) · [API reference](https://sidelatch.com/docs/api.md)
