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

# Delivery guarantees

> What Routa guarantees and does not guarantee about sending and delivering messages, and how to design your integration around it.

Messaging over a third-party API has physical limits. This page says clearly what Routa **promises**, what it does **not** promise and how you should design your integration.

## What Routa guarantees

> [card] No silent loss
>
> An accepted message (`202`) is durably stored before the response. It never disappears without a trace: it reaches its destination or becomes `failed`.

> [card] A status that never goes back
>
> The status only moves forward. A message does not go from `read` back to `sent` because of a late notice.

> [card] Permanent failures are visible
>
> Every terminal failure produces `message.failed`, and temporary ones are retried automatically.

> [card] Recoverable events
>
> Events stay in the log for 90 days and can be queried and replayed.

## What Routa does not guarantee

* **Immediate delivery.** Accepted is not delivered. Latency depends on the provider and on the channel queue.
* **Global order.** Messages and events can arrive out of order. Use `sequence`, `occurred_at` and the monotonic status to reconcile.
* **Exactly once.** Exactly-once delivery does not exist against a third-party HTTP API. The guarantee is **at least once**.

## Sending: accepted, then asynchronous

```text theme={null}
POST /v1/messages ─► 202 accepted ─► queue ─► provider ─► sent ─► delivered ─► read
                       (durable)                      └──────► failed
```

1. The API validates and stores the message and the `message.accepted` event in the same transaction. Only then does it respond `202`.
2. A worker sends it to the provider, within the rate limits of the channel.
3. Confirmations from the provider (`sent`, `delivered`, `read`, `failed`) update the message and produce events.

### If something fails along the way

| Situation | Behavior |
| - | - |
| Database unavailable | `503`. Nothing was stored and nothing was sent, so it is safe to retry. |
| Queue unavailable | The message stays `accepted` and a sweep process puts it back on the queue in a moment. You already have the `202`: this is latency, not loss. |
| Temporary provider failure | Automatic retries with growing delays (about 21 minutes in total, 7 attempts). The message stays `accepted`. |
| Permanent provider failure | Immediate `failed`, with `message.failed`. |
| Attempts exhausted | `failed`. |
| Provider down | The message waits in the queue and goes out when the provider is back. |

### Unknown outcome

The hardest case is a timeout against the provider: the message may or may not have been sent. Routa:

1. Sends a deterministic reference along with the message, so the provider can deduplicate.
2. Before trying again, asks the provider whether it already recorded the message, when the provider offers that query.
3. If the doubt remains, tries again: the guarantee is **at least once**. Duplicates are rare and acknowledged, never hidden.

## Receiving

Inbound messages are persisted before they are processed, and Routa deduplicates provider redeliveries. If an inbound media file fails for good, the message still exists, with the media `unavailable`.

The rule for what Routa does not understand has two parts:

* **Types Routa does not model** (such as `interactive` and `contacts`) become `content.type = "unsupported"`. The message is stored and produces `message.received`.
* **Reactions and system notices** (such as a contact changing their number) are ignored on purpose. They create no message, produce no `message.received` and do not count as usage. Routa does not yet tell you about a number change: a send to the old number can fail with no prior warning.

## Events and webhooks

* Each event is delivered **at least once** to each subscribed endpoint, with the same `id` on every attempt.
* A delivery is retried for about 20 hours. After that it becomes `exhausted` and can be replayed. See [Retries and replay](https://docs.routa.chat/en/webhooks/retries-and-replay.md).
* `GET /v1/events` lets you reconcile. See [Reconcile events](https://docs.routa.chat/en/webhooks/reconciliation.md).

## How to design your integration

**1. Send with idempotency**

Use `Idempotency-Key` on every send. See [Idempotency](https://docs.routa.chat/en/reliability/idempotency.md).

**2. Do not treat 202 as delivery**

Confirm delivery through `message.delivered`.

**3. Process events idempotently**

Deduplicate by `event.id` and never move the status backwards.

**4. Run a check job**

Run [`GET /v1/events`](https://docs.routa.chat/en/webhooks/reconciliation) periodically as a safety net.

## Data retention

Retention periods published as part of the API contract.

| Data | Retention |
| - | - |
| Message content | Depends on the plan: 60 days (Starter), 120 days (Essential) or 365 days (Growth and Pro). The project can choose a shorter period. |
| Media | 90 days |
| Events | 90 days |
| Webhook delivery records | 30 days |
| Idempotency keys | 24 hours |

### Message content retention

The period counts from `accepted_at`. Once it ends, Routa removes the **content** of the message. The rest of it stays: identifiers, addresses, `status`, timestamps and `metadata`.

* **The plan sets the maximum.** Each plan keeps content for a number of days. See the values in the table above and on the [Routa website](https://routa.chat).
* **The project can choose less.** On the **Project preferences** page, in the dashboard, you choose 30, 60, 120 or 365 days. The choice never exceeds the plan maximum.
* **The removal is permanent.** Extending retention later does not bring back content that was already removed.
* **The removal is not instant.** It runs periodically, and a message that is still being sent only loses its content after sending ends.
* **`metadata` is not removed.** It is yours and stays on the message.
* **A plan downgrade shortens the period.** The new maximum applies from the next removal run, with no grace period. See [Plans and allowance](https://docs.routa.chat/en/billing/plans-and-quota.md#change-plans).

A message without content carries `content: null` and a filled-in `content_redacted_at`. See [Content removed by retention](https://docs.routa.chat/en/concepts/messages.md#content-removed-by-retention).


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