> ## 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.

# Event types

> Reference of the message, channel and template events Routa delivers by webhook and through the event log.

All events share the same [envelope](https://docs.routa.chat/en/concepts/events.md). What changes is the `type` and the content of `data`.

To subscribe to a whole group, use a wildcard in the endpoint `subscribed_types`: `message.*`, `channel.*` or `template.*`.

## Message events

`data` is the full [message](https://docs.routa.chat/en/concepts/messages.md) in its current state.

| Type | Fired when |
| - | - |
| `message.accepted` | Routa accepted a message you sent. You already know this from the `202`, but you can subscribe to the event. |
| `message.sent` | The provider accepted the message. It is also the only event of a message the business sent from the WhatsApp Business app (`data.origin` is `business_app`). |
| `message.delivered` | Delivery to the recipient's device was confirmed. |
| `message.read` | The recipient read the message. |
| `message.failed` | The message failed for good. |
| `message.received` | A message from a customer arrived on your channel. |

```json message.delivered theme={null}
{
  "id": "evt_01J8ZK9M3Q7X...",
  "type": "message.delivered",
  "api_version": "v1",
  "schema_version": 1,
  "project_id": "proj_01J8...",
  "external_ref": null,
  "sequence": 918273,
  "occurred_at": "2026-09-04T13:22:41.031Z",
  "recorded_at": "2026-09-04T13:22:41.244Z",
  "data": {
    "id": "msg_01J8...",
    "channel": "chan_01J8...",
    "direction": "outbound",
    "origin": "api",
    "from": "+5581988888888",
    "to": "+5581999999999",
    "content": { "type": "text", "body": "Hi! Your order is confirmed." },
    "content_redacted_at": null,
    "status": "delivered",
    "failure_code": null,
    "metadata": { "order_id": "1234" },
    "accepted_at": "2026-09-04T13:22:40.812Z",
    "sent_at": "2026-09-04T13:22:41.031Z",
    "delivered_at": "2026-09-04T13:22:42.402Z",
    "read_at": null,
    "failed_at": null
  }
}
```

> [!NOTE]
>
> A message event always carries the full state of the message at that moment. If you miss `message.sent` but receive `message.delivered`, you still have `sent_at` and every field.

On a template send, `data.content` also carries `header_parameter` and `button_parameters`, with the values as you sent them: the `media_id` of the file, never a URL. Both keys are absent when the template asks for nothing there. In this example, the header file became unavailable before sending:

```json message.failed theme={null}
{
  "id": "evt_01J8...",
  "type": "message.failed",
  "api_version": "v1",
  "schema_version": 1,
  "project_id": "proj_01J8...",
  "external_ref": null,
  "sequence": 918310,
  "occurred_at": "2026-09-04T13:30:02.118Z",
  "recorded_at": "2026-09-04T13:30:02.240Z",
  "data": {
    "id": "msg_01J8...",
    "channel": "chan_01J8...",
    "direction": "outbound",
    "origin": "api",
    "from": "+5581988888888",
    "to": "+5581999999999",
    "content": {
      "type": "template",
      "template_id": "tmpl_01J8...",
      "body_parameters": ["Ana", "1234"],
      "header_parameter": { "media_id": "med_01J8...", "filename": "invoice.pdf" },
      "button_parameters": [{ "index": 1, "text": "1234" }]
    },
    "content_redacted_at": null,
    "status": "failed",
    "failure_code": "media_unavailable",
    "metadata": { "order_id": "1234" },
    "accepted_at": "2026-09-04T13:30:01.007Z",
    "sent_at": null,
    "delivered_at": null,
    "read_at": null,
    "failed_at": "2026-09-04T13:30:02.118Z"
  }
}
```

Messages sent from the WhatsApp Business app have no `message.accepted`, and the history imported when the channel is connected produces no event at all. See [Messages sent from the WhatsApp Business app](https://docs.routa.chat/en/concepts/messages.md#messages-sent-from-the-whatsapp-business-app).

## Channel events

### `channel.status_changed`

Fired when the status of a channel changes. The most common cases:

* The channel becomes `degraded` because of authentication failures with the provider. Act early: a `degraded` channel needs attention in the dashboard.
* The channel becomes `disabled` because your team disabled it, because the customer disconnected the number in the WhatsApp Business app or because the provider removed the account.
* A `disabled` channel goes back to `active` when you re-enable it in the dashboard.

`data` carries the channel and the transition:

| Field | Description |
| - | - |
| `channel_id` | Channel ID. |
| `status` | New status: `pending`, `active`, `degraded` or `disabled`. |
| `previous_status` | Previous status, or `null` on creation. |
| `connection_mode` | `cloud_api` or `coexistence`. See [Connection mode](https://docs.routa.chat/en/concepts/data-model.md#connection-mode). |
| `reason` | Only when the provider caused the change: `disconnected_by_customer` (the customer disconnected the number in the app) or `offboarded` (the account was removed). Absent when your team disabled the channel. |
| `disconnection_reason` | Only with `disconnected_by_customer`: the reason for the disconnection. One of `account_disconnected`, `business_downgrade`, `change_number`, `companion_inactivity`, `primary_inactivity`, `user_re_registered` and `unknown`. |

> [!NOTE]
>
> Deleting a disabled channel produces no event. An event recorded before `connection_mode` existed does not have that field: ignore fields you do not recognize.

```json theme={null}
{
  "id": "evt_01J8...",
  "type": "channel.status_changed",
  "api_version": "v1",
  "schema_version": 1,
  "project_id": "proj_01J8...",
  "external_ref": null,
  "sequence": 918400,
  "occurred_at": "2026-09-04T14:00:00.000Z",
  "recorded_at": "2026-09-04T14:00:00.120Z",
  "data": {
    "channel_id": "chan_01J8...",
    "status": "degraded",
    "previous_status": "active",
    "connection_mode": "cloud_api"
  }
}
```

## Template events

`data` is the full [template](https://docs.routa.chat/en/concepts/templates.md) in its current state.

| Type | Fired when |
| - | - |
| `template.submitted` | The template was sent for review. |
| `template.pending` | The review is in progress. |
| `template.approved` | The template was approved and can now be used to send. |
| `template.rejected` | The template was rejected. See `rejection_reason` in `data`. |
| `template.paused` | The provider paused the template. |
| `template.disabled` | The provider disabled the template. |
| `template.failed` | Routa could not send the template to the provider. See `failure_code` in `data`. |
| `template.category_changed` | The provider changed the category of the template. `data` also carries `previous_category`. |
| `template.updated` | A `failed` or `rejected` template was edited in the dashboard and went back to review. `data` has `status: "submitted"`. |
| `template.deleted` | The template was removed. `data` is the template in its last state. |

`template.deleted` is sent when the removal finishes. A template that never reached the provider, or that is `disabled`, is removed right away. The others keep `deletion_requested: true` until the provider confirms the deletion. A template removed because it no longer exists on WhatsApp, found during a sync, and templates deleted along with a channel produce **no** event.

Importing a template that already existed on WhatsApp produces **no** event. See [Imported templates](https://docs.routa.chat/en/concepts/templates.md#imported-templates).

`data` carries the [variable examples](https://docs.routa.chat/en/concepts/templates.md#variable-examples) in `variables[].example`, `components.header.example` and `components.buttons[].example`. When there is no example, as on an old or imported template, the key is absent. Do not put real personal data or a real token in an example: it travels in every event of the template.

```json template.approved theme={null}
{
  "id": "evt_01J8...",
  "type": "template.approved",
  "api_version": "v1",
  "schema_version": 1,
  "project_id": "proj_01J8...",
  "external_ref": null,
  "sequence": 918500,
  "occurred_at": "2026-09-04T15:10:00.000Z",
  "recorded_at": "2026-09-04T15:10:00.200Z",
  "data": {
    "id": "tmpl_01J8...",
    "channel": "chan_01J8...",
    "name": "order_confirmation",
    "language": "en_US",
    "category": "utility",
    "body_text": "Hi {{1}}! Your order {{2}} is confirmed.",
    "variables": [
      { "index": 1, "example": "Ana" },
      { "index": 2, "example": "1234" }
    ],
    "components": {
      "header": { "kind": "text", "text": "Order {{1}}", "example": "A-10" },
      "buttons": [
        {
          "kind": "url",
          "text": "Track order",
          "url": "https://example.com/orders/{{1}}",
          "example": "1234"
        }
      ]
    },
    "status": "approved",
    "rejection_reason": null,
    "failure_code": null,
    "failure_detail": null,
    "deletion_requested": false,
    "deletion_failure_detail": null,
    "origin": "routa",
    "read_only": false,
    "unsupported_components": [],
    "created_at": "2026-09-04T15:00:00.000Z",
    "updated_at": "2026-09-04T15:10:00.000Z"
  }
}
```

`template.category_changed` carries the full template in its current state, with the new category in `category`, plus the `previous_category` field. Use it to understand why the cost of a send changed.

```json template.category_changed theme={null}
{
  "id": "evt_01J8...",
  "type": "template.category_changed",
  "api_version": "v1",
  "schema_version": 1,
  "project_id": "proj_01J8...",
  "external_ref": null,
  "sequence": 918600,
  "occurred_at": "2026-09-04T16:30:00.000Z",
  "recorded_at": "2026-09-04T16:30:00.180Z",
  "data": {
    "id": "tmpl_01J8...",
    "channel": "chan_01J8...",
    "name": "order_confirmation",
    "language": "en_US",
    "category": "marketing",
    "previous_category": "utility",
    "body_text": "Hi {{1}}! Your order {{2}} is confirmed.",
    "variables": [
      { "index": 1, "example": "Ana" },
      { "index": 2, "example": "1234" }
    ],
    "components": {
      "header": { "kind": "text", "text": "Order {{1}}", "example": "A-10" },
      "buttons": [
        {
          "kind": "url",
          "text": "Track order",
          "url": "https://example.com/orders/{{1}}",
          "example": "1234"
        }
      ]
    },
    "status": "approved",
    "rejection_reason": null,
    "failure_code": null,
    "failure_detail": null,
    "deletion_requested": false,
    "deletion_failure_detail": null,
    "origin": "routa",
    "read_only": false,
    "unsupported_components": [],
    "created_at": "2026-09-04T15:00:00.000Z",
    "updated_at": "2026-09-04T16:30:00.000Z"
  }
}
```

## New types

New event types can be introduced at any time, with no version notice. Because each endpoint subscribes to an explicit list, a new type only reaches you if it belongs to a wildcard you subscribed to. Always have a default branch that **ignores** what you do not recognize.

```ts theme={null}
switch (event.type) {
  case 'message.delivered':
    // ...
    break
  default:
    // unknown type: safe to ignore
    break
}
```


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