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

# Webhooks overview

> Receive normalized Routa events on your HTTPS server: how to register an endpoint, the delivery format and the limits.

Webhooks deliver Routa events to your server as soon as they happen. They are the recommended way to follow [message delivery](https://docs.routa.chat/en/guides/track-delivery.md) and to receive [customer messages](https://docs.routa.chat/en/guides/receive-messages.md).

Routa delivers **normalized events** (`message.delivered`, `message.received`…), never provider payloads. You write a single integration, whatever the channel.

> [!NOTE]
>
> Required scope to manage endpoints: `webhooks:write`.

## How it works

**1. Register an endpoint**

Provide the HTTPS URL and the event types you want to receive.

**2. Store the secret**

The response carries the signing `secret`. It is shown **only once**.

**3. Verify every delivery**

Validate the `Routa-Signature` header over the raw body before you trust the event. See [Signatures](https://docs.routa.chat/en/webhooks/signatures.md).

**4. Answer 2xx**

Return a `2xx` status within 10 seconds. Any other response counts as a failure and is retried.

## Register an endpoint

```bash cURL theme={null}
curl https://api.routa.chat/v1/webhook_endpoints \
  -H "Authorization: Bearer $ROUTA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/webhooks/routa",
    "subscribed_types": ["message.*", "channel.status_changed"]
  }'
```

```ts Node.js theme={null}
const webhook = await routa.webhooks.create({
  url: 'https://example.com/webhooks/routa',
  subscribedTypes: ['message.*', 'channel.status_changed'],
})

console.log(webhook.id, webhook.secret) // store the secret safely
```

```json Response (201 Created) theme={null}
{
  "id": "whe_01J8...",
  "url": "https://example.com/webhooks/routa",
  "subscribed_types": ["message.*", "channel.status_changed"],
  "api_version": "v1",
  "status": "enabled",
  "consecutive_failures": 0,
  "last_success_at": null,
  "last_failure_at": null,
  "created_at": "2026-09-04T13:00:00.000Z",
  "secret": "whsec_..."
}
```

### Subscribed types

`subscribed_types` needs at least one item. Each item is an exact event type (`message.delivered`, for example) or a per-resource wildcard: `message.*`, `channel.*` or `template.*`. A bare wildcard (`*`) or a type that does not exist returns `422 invalid_subscribed_types`. The full list is in [Event types](https://docs.routa.chat/en/webhooks/event-types.md).

To change the subscription later, use `PATCH /v1/webhook_endpoints/{id}`.

### URL requirements

* In a live project, the URL must use **HTTPS**.
* Private, loopback and *link-local* addresses are rejected (`invalid_webhook_url`). Routa also checks DNS again at the time of each delivery, and does not follow redirects.
* `http://localhost` is accepted only in [test projects](https://docs.routa.chat/en/environments.md).
* Each project can have up to **5 endpoints**. Beyond that, creation returns `422 too_many_webhook_endpoints`.

## What Routa sends

Each delivery is a `POST` with a single event in the body and these headers:

```http theme={null}
POST /webhooks/routa HTTP/1.1
Content-Type: application/json
Routa-Event-Id: evt_01J8...
Routa-Event-Type: message.delivered
Routa-Delivery-Id: whd_01J8...
Routa-Delivery-Attempt: 3
Routa-Signature: t=1757000000,v1=9f86d081...
User-Agent: Routa-Webhooks/1.0
```

| Header | Description |
| - | - |
| `Routa-Event-Id` | Event ID. Use it to deduplicate. |
| `Routa-Event-Type` | Event type. |
| `Routa-Delivery-Id` | ID of this delivery (one event to one endpoint). |
| `Routa-Delivery-Attempt` | Attempt number, starting at 1. |
| `Routa-Signature` | HMAC signature with timestamp. |

The body is the [event object](https://docs.routa.chat/en/concepts/events.md). There is no batching: **one event per request**.

## Delivery semantics

* **At least once.** The same event can arrive more than once. Deduplicate by `id`.
* **No global order.** Events can arrive out of order. Treat the status as monotonic.
* **Success** is any `2xx` within 10 seconds. The response body is ignored.
* Failures are retried with growing delays for about 20 hours. See [Retries and replay](https://docs.routa.chat/en/webhooks/retries-and-replay.md).

## Best practices

> [card] Answer fast
>
> Validate, put the event on a queue and return `200`. Process it afterwards.

> [card] Verify the signature
>
> Never trust an event without validating `Routa-Signature` over the raw body.

> [card] Deduplicate
>
> Keep the `id` of processed events for at least 24 hours.

> [card] Tolerate the unknown
>
> Ignore new types and fields. Routa only makes additive changes within `v1`.

## Manage endpoints

| Action | Endpoint |
| - | - |
| Create | [`POST /v1/webhook_endpoints`](https://docs.routa.chat/en/api-reference/endpoint/webhooks/create) |
| List | [`GET /v1/webhook_endpoints`](https://docs.routa.chat/en/api-reference/endpoint/webhooks/list) |
| Retrieve | [`GET /v1/webhook_endpoints/{id}`](https://docs.routa.chat/en/api-reference/endpoint/webhooks/retrieve) |
| Change types | [`PATCH /v1/webhook_endpoints/{id}`](https://docs.routa.chat/en/api-reference/endpoint/webhooks/update) |
| Rotate the secret | [`POST /v1/webhook_endpoints/{id}/rotate_secret`](https://docs.routa.chat/en/api-reference/endpoint/webhooks/rotate-secret) |
| Disable | [`POST /v1/webhook_endpoints/{id}/disable`](https://docs.routa.chat/en/api-reference/endpoint/webhooks/disable) |
| Re-enable | [`POST /v1/webhook_endpoints/{id}/enable`](https://docs.routa.chat/en/api-reference/endpoint/webhooks/enable) |
| View deliveries | [`GET /v1/webhook_endpoints/{id}/deliveries`](https://docs.routa.chat/en/api-reference/endpoint/webhooks/list-deliveries) |


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