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

# API reference

> Base URL, authentication, response format, pagination, idempotency, limits and conventions of the Routa REST API.

The Routa API is REST over HTTPS, with JSON requests and responses and key authentication in the `Bearer` scheme. This page gathers the rules shared by every endpoint. Each endpoint has its own page, with parameters, examples and a playground to try calls.

The full OpenAPI specification is in [`openapi.json`](https://docs.routa.chat/en/openapi.json).

## Base URL

```text theme={null}
https://api.routa.chat
```

Every public endpoint is under the `/v1` prefix. The API key, not the URL, defines the environment (live or test). See [Environments](https://docs.routa.chat/en/environments.md).

> [!NOTE]
>
> The API does not set CORS headers. Always call it from your server and never from a browser or an app, so you do not expose your key.

## Authentication

Send your API key in the `Authorization` header:

```bash theme={null}
curl https://api.routa.chat/v1/whoami \
  -H "Authorization: Bearer rt_live_..."
```

Each key belongs to one project and carries scopes. A route that requires a scope the key lacks responds `403 insufficient_scope`. See [API keys](https://docs.routa.chat/en/authentication.md).

The `/v1/partner/*` routes use another credential: the **partner key** (`rt_partner_...`), which belongs to the organization and provisions the projects of your customers. The two keys do not mix. The partner key never sends messages, and a project key gets `401 partner_key_invalid` on partner routes. See [Partner API](https://docs.routa.chat/en/partners/overview.md).

## What the API key reaches

| Group | Main routes | Page |
| - | - | - |
| Messages | `POST /v1/messages`, `GET /v1/messages`, `GET /v1/messages/{id}`, `POST /v1/messages/{id}/read` | [Messages](https://docs.routa.chat/en/api-reference/endpoint/messages/send.md) |
| Events | `GET /v1/events` | [Events](https://docs.routa.chat/en/api-reference/endpoint/events/list.md) |
| Webhooks | `/v1/webhook_endpoints` and sub-routes (secret, enable and disable, deliveries, replay) | [Webhooks](https://docs.routa.chat/en/api-reference/endpoint/webhooks/create.md) |
| Templates | `POST /v1/templates`, `GET /v1/templates`, `GET /v1/templates/{id}`, `POST /v1/templates/media` | [Templates](https://docs.routa.chat/en/api-reference/endpoint/templates/create.md) |
| Media | `POST /v1/media`, `GET /v1/media/{id}` | [Media](https://docs.routa.chat/en/api-reference/endpoint/media/upload.md) |
| Usage | `GET /v1/usage` | [Usage](https://docs.routa.chat/en/api-reference/endpoint/usage/retrieve.md) |
| Identity | `GET /v1/whoami` | [Identity](https://docs.routa.chat/en/api-reference/endpoint/identity/whoami.md) |

The partner routes use the partner key, not the project key:

| Group | Main routes | Page |
| - | - | - |
| Projects | `/v1/partner/projects` and sub-routes (project API keys) | [Partners](https://docs.routa.chat/en/api-reference/endpoint/partner/create-project.md) |
| Channels | `GET /v1/partner/channels`, `DELETE /v1/partner/projects/{projectId}/channels/{channelId}` | [Channels](https://docs.routa.chat/en/api-reference/endpoint/partner/list-channels.md) |
| Organization webhook | `GET`/`PUT /v1/partner/webhook` and `POST /v1/partner/webhook/rotate_secret` | [Webhook](https://docs.routa.chat/en/api-reference/endpoint/partner/set-webhook.md) |

> [!NOTE]
>
> You manage organizations, members, partner keys, a project's channels and billing in the **dashboard**, with a user session. Those routes do not accept an API key and are not part of this reference.

## Response format

### Single object

A resource is returned directly, with no envelope:

```json theme={null}
{
  "id": "msg_01J8ZK9M3Q7X...",
  "channel": "chan_01J8...",
  "direction": "outbound",
  "status": "accepted"
}
```

### Lists

Collections come inside an envelope with pagination metadata:

```json theme={null}
{
  "data": [{ "id": "msg_01J8..." }],
  "has_more": true,
  "next_cursor": "eyJ..."
}
```

### Error

```json theme={null}
{
  "error": {
    "type": "invalid_request_error",
    "code": "request_invalid",
    "message": "\"channel\" is missing or does not have the documented format.",
    "param": "channel",
    "request_id": "req_01J8..."
  }
}
```

See every field in [Errors](https://docs.routa.chat/en/errors/overview.md).

> [!WARNING]
>
> Some responses do not follow the list envelope: `GET /v1/usage` returns `{ from_date, to_date, data }` with no pagination, and `GET /v1/webhook_endpoints` returns every endpoint at once, with `has_more` always `false`. Check the format on each endpoint page.

Every response carries the `Routa-Request-Id` header. Quote it when you contact support.

## Pagination

Lists use cursor pagination. There is no `page` or `offset`.

| Parameter | Description |
| - | - |
| `limit` | Items per page, from 1 to 100. The default is 20. |
| `cursor` | The `next_cursor` of the previous page. |

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

`GET /v1/events` uses `after` (the ID of the last event) instead of `cursor`. See [Pagination](https://docs.routa.chat/en/reliability/pagination.md).

The partner listings (`GET /v1/partner/projects` and `GET /v1/partner/channels`) accept a `limit` from 1 to 200, with a default of 50.

## Idempotency

`POST /v1/messages` accepts the `Idempotency-Key` header. Repeating the request with the same key and the same body returns the original response, with `Idempotent-Replay: true`, without creating another message.

| Situation | Result |
| - | - |
| New key | The message is created. |
| Same key and same body | Original response, with `Idempotent-Replay: true`. |
| Same key, request still in progress | `409 idempotency_in_progress`, with `Retry-After`. |
| Same key, different body | `409 idempotency_key_reuse`. |

Keys are kept for 24 hours. See [Idempotency](https://docs.routa.chat/en/reliability/idempotency.md).

## Rate limits

The limits of the project routes apply per project, per endpoint class.

| Class | Sustained rate | Burst |
| - | - | - |
| Sends (`POST /v1/messages`) | 50 req/s | 100 |
| Writes | 20 req/s | 40 |
| Reads | 100 req/s | 200 |

Every response carries the `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset` headers. A `429` carries `Retry-After`:

```http theme={null}
HTTP/1.1 429 Too Many Requests
RateLimit-Limit: 50
RateLimit-Remaining: 0
RateLimit-Reset: 1
Retry-After: 1
```

The `/v1/partner/*` routes have their own limit, **per organization**: 10 req/s sustained, with a burst of 30, in a single bucket for all of those routes. A `429` carries the same headers.

See [Rate limits](https://docs.routa.chat/en/reliability/rate-limits.md).

## HTTP status codes

| Status | Meaning |
| - | - |
| `200` | Success. |
| `201` | Resource created. |
| `202` | `POST /v1/messages`: accepted, sending is asynchronous. On `DELETE /v1/partner/projects/{projectId}`, the deletion is partial: repeat the call. |
| `204` | No content. The operation is complete. |
| `400` | The body is not valid JSON. The response does not use the error format. |
| `401` | Missing or invalid API key. On partner routes, missing or invalid partner key. |
| `402` | Plan allowance or limit used up. |
| `403` | The key lacks the required scope. |
| `404` | The resource does not exist or belongs to another project. |
| `409` | Idempotency or state conflict. |
| `422` | Request outside the schema (`request_invalid`) or invalid. |
| `429` | Rate limit exceeded. |
| `503` | Routa cannot process the request right now. Try again. |

## Conventions

### Phone numbers

Use the **E.164** format, such as `+5581999999999`. The leading `+` is optional on input. Responses carry the number in E.164.

### IDs

Identifiers are opaque strings with a prefix that tells the type.

| Prefix | Resource |
| - | - |
| `msg_` | Message |
| `chan_` | Channel |
| `proj_` | Project |
| `key_` | Project API key |
| `ptn_` | Partner profile |
| `evt_` | Event |
| `tmpl_` | Template |
| `med_` | Media |
| `tmedia_` | Template header media |
| `whe_` | Webhook endpoint |
| `whd_` | Webhook delivery |
| `req_` | Request |

### Dates

All dates and times follow ISO 8601 in UTC, such as `2026-09-04T13:22:41.031Z`. Date-only parameters use `YYYY-MM-DD`.

### Enums

The values of fields such as `status` and `direction` are lowercase strings. Fields documented as open can gain new values. Handle unknown values safely.

### Versioning

The version is in the URL (`/v1`). Within `v1`, changes are **additive only**: new endpoints, new optional request fields and new response fields. Any other change becomes `v2`. Ignore unknown fields in responses.

## Next steps

> [card] [Quickstart](https://docs.routa.chat/en/quickstart.md)
>
> Send your first message.

> [card] [Send message](https://docs.routa.chat/en/api-reference/endpoint/messages/send.md)
>
> The main endpoint of the API.

> [card] [Webhooks](https://docs.routa.chat/en/webhooks/overview.md)
>
> Receive delivery events and inbound messages.

> [card] [Node.js SDK](https://docs.routa.chat/en/sdk/overview.md)
>
> Use the official TypeScript client.


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