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

# Track delivery

> Find out whether a message reached its recipient using webhooks, a direct query or the event log.

When `POST /v1/messages` responds `202`, the message is `accepted`: Routa stored it, but it still has to reach WhatsApp and the customer's device. There are three ways to follow the rest of the way.

| Way | When to use it |
| - | - |
| **Webhooks** | Recommended in production. You are told about every change without polling. |
| **`GET /v1/messages/{id}`** | To show the current status of a specific message, on a support screen for example. |
| **`GET /v1/events`** | To recover missed events and reconcile your state. |

## 1. By webhook

Subscribe to message events. The `message.*` wildcard covers all of them.

```bash 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.*"]
  }'
```

Each message transition produces an event whose `data` is the message in its current state:

| Event | The message is |
| - | - |
| `message.sent` | With the provider. |
| `message.delivered` | On the recipient's device. |
| `message.read` | Read. |
| `message.failed` | Failed for good. |

Update your database using the message `data.id` and `data.status`. Because deliveries can arrive out of order, **never move the status backwards**:

```ts theme={null}
const RANK = { accepted: 10, sent: 30, delivered: 40, read: 50, failed: 90 } as const

function shouldApply(current: keyof typeof RANK, incoming: keyof typeof RANK): boolean {
  if (incoming === 'failed') return RANK[current] < RANK.delivered
  return RANK[incoming] > RANK[current]
}
```

See the full setup in [Webhooks](https://docs.routa.chat/en/webhooks/overview.md).

## 2. Querying the message

```bash theme={null}
curl https://api.routa.chat/v1/messages/msg_01J8... \
  -H "Authorization: Bearer $ROUTA_API_KEY"
```

The `sent_at`, `delivered_at`, `read_at` and `failed_at` fields show when each step happened, or `null` if it has not happened yet.

> [!WARNING]
>
> Avoid polling in a loop to find out whether a message was delivered. Use webhooks. Queries count against your read limit. See [Rate limits](https://docs.routa.chat/en/reliability/rate-limits.md).

## 3. Reconciling with the event log

If your server was unavailable, list the events you missed, starting from the last one you processed:

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

See [Reconcile events](https://docs.routa.chat/en/webhooks/reconciliation.md).

## What `failed` means

`failed` is terminal. It happens when the provider rejects the message for good or when the send attempts run out. Routa retries temporary failures automatically, and they do **not** show up as a status. The message `failure_code` field carries the reason (see [Failure reasons](https://docs.routa.chat/en/concepts/messages.md#failure-reasons)), and the message timeline in the dashboard shows the detail.

> [!NOTE]
>
> If a message stays `accepted` for a long time, there is usually a provider outage or the channel has a queue above its capacity. The message is not lost: it is sent as soon as the path recovers.


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