# API introduction

> Base URL, authentication with site keys and account tokens, permissions, responses, errors, pagination and rate limits of the REST API.

The Reveata REST API reads the same numbers as the dashboard and accepts goals, payments and identify calls from your backend. Every endpoint, with its parameters, responses and code samples, is in the [API reference](https://reveata.com/api-reference); you can try requests in the [API playground](https://reveata.com/api-playground). The [CLI](https://reveata.com/docs/cli-get-started) and the [MCP server](https://reveata.com/docs/mcp-server) use the same API.

## Base URL

```text
https://reveata.com/api/v1
```

Website routes take the website id **or** its domain: `/api/v1/websites/example.com/analytics/overview`.

## Authentication

Send a credential in the `Authorization` header:

```bash
curl https://reveata.com/api/v1/whoami -H "Authorization: Bearer $REVEATA_TOKEN"
```

| Credential           | Prefix     | Where to create it               | Use it for                                                                                                 |
| -------------------- | ---------- | -------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| Website API key      | `dt_site_` | Website **Settings → Developer** | One website, server side: stats, goals, payments and identify calls.                                       |
| Account access token | `dt_pat_`  | **Account → API / MCP**                | Scripts, the CLI and tools that work across several websites, with the permissions you choose.             |
| OAuth access token   |            | An app you connect               | MCP clients and other apps you approve on the consent page; revoke them under **Account → API / MCP → Connected apps**. |

Keys are shown once when you create them; we store only a hash. Roll or revoke a key at any time from the same page. `GET /api/v1/whoami` tells you which credential you sent, its scopes and its websites.

## Permissions

Account tokens and OAuth connections use permissions of the form `<resource>:<read|write>`, for example `analytics:read` or `goals:write`. `write` includes `read`. A website API key always has these scopes on its own website: `analytics:read`, `goals:read`, `goals:write`, `payments:read`, `payments:write`, `identify:write`.

The scopes and the lowest role each one needs:

| Scope | What it allows | Lowest role | AI tools (OAuth) |
| --- | --- | --- | --- |
| `notes:read` | Notes: Read and write notes on your charts. | Viewer | Yes |
| `notes:write` | Notes: Read and write notes on your charts. | Editor | Yes |
| `analytics:read` | Analytics: Read visitors, pages, sources and revenue. | Viewer | Yes |
| `goals:read` | Goals: Read and manage goals. | Viewer | Yes |
| `goals:write` | Goals: Read and manage goals. | Editor | Yes |
| `funnels:read` | Funnels: Read and manage funnels. | Viewer | Yes |
| `funnels:write` | Funnels: Read and manage funnels. | Editor | Yes |
| `segments:read` | Segments: Read and manage your saved segments. | Viewer | Yes |
| `segments:write` | Segments: Read and manage your saved segments. | Viewer | Yes |
| `alerts:read` | Alerts: Read and manage traffic and revenue alerts. | Viewer | Yes |
| `alerts:write` | Alerts: Read and manage traffic and revenue alerts. | Editor | Yes |
| `websites:read` | Websites: List websites, and add or remove them. | Viewer | Yes |
| `websites:write` | Websites: List websites, and add or remove them. | Admin | No |
| `settings:read` | Settings: Read and change website settings. | Admin | Only when the tool asks for it (off at first, with a warning) |
| `settings:write` | Settings: Read and change website settings. | Admin | No |
| `team:read` | Team: See and invite team members. | Admin | Only when the tool asks for it (off at first, with a warning) |
| `team:write` | Team: See and invite team members. | Admin | No |
| `api_keys:read` | API keys: See and create website API keys. | Admin | Only when the tool asks for it (off at first, with a warning) |
| `api_keys:write` | API keys: See and create website API keys. | Admin | No |
| `payments:read` | Payments: Read payments and send payment events. | Viewer | Only when the tool asks for it (off at first, with a warning) |
| `payments:write` | Payments: Read payments and send payment events. | Admin | No |
| `identify:write` | Identify API: Attach your own user details to visitors. | Admin | No |
| `visitors:write` | Visitor data requests: Export or erase everything about one visitor (privacy requests). | Admin | No |
| `account:read` | Account: Read your profile and preferences, and change your name and preferences. | Any (your own account) | Only when the tool asks for it (off at first, with a warning) |
| `account:write` | Account: Read your profile and preferences, and change your name and preferences. | Any (your own account) | No |
| `tokens:read` | Access tokens: See, create and revoke your account access tokens (never with more access than the token used). | Any (your own account) | Only when the tool asks for it (off at first, with a warning) |
| `tokens:write` | Access tokens: See, create and revoke your account access tokens (never with more access than the token used). | Any (your own account) | No |

A token can only do what you chose for it **and** what your role on each website allows. If your role on a website is lowered, the token loses that access too. Viewers don't get revenue, payments or customers' details unless the website allows it. [CLI permissions and roles](https://reveata.com/docs/cli-permissions) shows the scope and role each CLI command needs.

## Responses

JSON in and out. A success is `{ "status": "ok", "data": … }`; an error is `{ "status": "error", "error": { "code", "message", "details" } }`.

- Money is in minor units (cents); dates are ISO 8601 in UTC; report days are `YYYY-MM-DD` in the website's time zone.
- Every response has an `x-request-id` header. Quote it when you contact support.
- Archived websites (after a plan downgrade, or archived by the owner) are listed by `GET /api/v1/websites` with `archived: true`. Their other routes answer `409 website_archived` until the owner restores them, except recording payments and visitor data requests (export or erase one visitor), which keep working so no money data is lost and privacy requests can always be answered.

## Pagination

Lists take `limit` and `cursor`. Pass `pagination.nextCursor` from a response as the next `cursor`; it is `null` on the last page.

## Rate limits

600 requests per minute per credential, reported in the `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset` headers. Over the limit you get `429 rate_limited` with a `Retry-After` header.

## Errors

The `code` tells you what went wrong. The reference lists the errors each endpoint can return.

| Code | HTTP status | Meaning |
| --- | --- | --- |
| `bad_request` | 400 | The request could not be read (for example malformed JSON). |
| `validation_failed` | 400 | A parameter or body field is missing or invalid; `details` lists them. |
| `invalid_domain` | 400 | The domain is not a valid public hostname. |
| `invalid_timezone` | 400 | The timezone is not a known IANA name. |
| `invalid_scope` | 400 | A scope in the request does not exist. |
| `unauthorized` | 401 | No credential was sent, or it is not a valid key or token. |
| `invalid_token` | 401 | The key or token is unknown, revoked or expired. |
| `token_expired` | 401 | The token has expired. |
| `forbidden` | 403 | The credential may not do this. |
| `insufficient_role` | 403 | Your role on the website is too low for this action. |
| `insufficient_scope` | 403 | The credential lacks the required scope. |
| `website_not_in_scope` | 403 | The credential is limited to other websites. |
| `not_found` | 404 | The website or resource does not exist or is not visible to this credential. |
| `method_not_allowed` | 405 | This method is not supported on the path. |
| `conflict` | 409 | The request conflicts with the current state. |
| `domain_taken` | 409 | A website with this domain already exists. |
| `limit_reached` | 409 | A plan or account limit was reached. |
| `website_archived` | 409 | The website is archived: tracking and the API are off until its owner restores it. |
| `reports_locked` | 402 | The website owner's plan does not include reports right now (trial ended, no plan or unpaid); `details.lockReason` says why. |
| `payload_too_large` | 413 | The request body is too large. |
| `unsupported_media_type` | 415 | Send the body as `application/json`. |
| `rate_limited` | 429 | Too many requests for this credential; wait for `Retry-After` seconds. |
| `internal_error` | 500 | Something went wrong on our side; retry later and quote the request id. |
| `not_implemented` | 501 | This feature is not available on this server yet. |
| `provider_not_configured` | 503 | A required provider is not configured on this server. |
| `provider_error` | 502 | An upstream provider failed. |
| `service_unavailable` | 503 | The service is temporarily unavailable. |
