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

# Reconcile events

> Recover missed events by querying GET /v1/events after your server was unavailable.

Because webhook delivery is *at least once*, not *exactly once*, Routa gives you a second way to check what happened: `GET /v1/events`. It turns hours of downtime into a deterministic recovery, with no help needed from support.

> [!NOTE]
>
> Required scope: `events:read`.

## When to use it

* Your server was down longer than the [retry](https://docs.routa.chat/en/webhooks/retries-and-replay.md) window (about 20 hours).
* You suspect gaps between the events you received and what happened.
* You are connecting a new integration and want to load the history.
* You want a periodic check job as a safety net.

## How it works

Store the `id` of the last event you processed. Ask for the following events with `after`. Repeat while `has_more` is `true`.

```bash cURL theme={null}
curl "https://api.routa.chat/v1/events?after=evt_01J8ZK9M3Q7X...&limit=100" \
  -H "Authorization: Bearer $ROUTA_API_KEY"
```

```ts Node.js theme={null}
let cursor = await loadLastProcessedEventId()

for await (const event of routa.events.list({ after: cursor, limit: 100 })) {
  if (!('id' in event)) continue // a type this SDK version does not know comes without an id
  await processEvent(event) // idempotent, deduplicating by event.id
  cursor = event.id
  await saveLastProcessedEventId(cursor)
}
```

```json Response theme={null}
{
  "data": [
    {
      "id": "evt_01J8...",
      "type": "message.failed",
      "api_version": "v1",
      "schema_version": 1,
      "project_id": "proj_01J8...",
      "external_ref": null,
      "sequence": 918274,
      "occurred_at": "2026-09-04T13:23:00.000Z",
      "recorded_at": "2026-09-04T13:23:00.150Z",
      "data": { "id": "msg_01J8...", "status": "failed" }
    }
  ],
  "has_more": false,
  "next_cursor": null
}
```

| Parameter | Description |
| - | - |
| `after` | Resumes after this event ID. |
| `type` | Filters by an event type. |
| `limit` | Items per page, from 1 to 100. |

Events come back in ascending `sequence` order. If the `after` event does not exist, the API returns `404 event_not_found`.

## Process idempotently

Events from this route are the same ones the webhook delivers, with the same `id`. If you received an event by webhook and also see it in the query, deduplicating by `id` keeps you from processing it twice.

**1. Store the id**

Before you apply the effect, record the event `id` in a table with a unique key, in the same transaction as the effect.

**2. Ignore repeats**

If the `id` already exists, skip the event.

**3. Respect the monotonic status**

For message events, only move the status forward. Never move it back.

## Retention

Events are available for **90 days**. Reconcile within that period.


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