# API and CLI

> Authenticate with the REST API, choose between website keys and account tokens, and use the command-line tool.

The REST API lives under `https://reveata.com/api/v1`. It reads the same numbers as the dashboard and accepts goals and payments. The [API introduction](https://reveata.com/docs/api-introduction) covers authentication, errors and limits in detail. The full list of endpoints, request and response formats is in the [API reference](https://reveata.com/api-reference), and you can try requests in the [API playground](https://reveata.com/api-playground).

## Authentication

Send a key in the `Authorization` header:

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

There are two kinds of credentials:

| Credential           | Prefix     | Where to create it               | Use it for                                                                                     |
| -------------------- | ---------- | -------------------------------- | ---------------------------------------------------------------------------------------------- |
| Website API key      | `dt_site_` | Website **Settings → Developer** | One website: server-side payments, goals and stats.                                            |
| Account access token | `dt_pat_`  | **Account → API / MCP**                | Scripts, the CLI and tools that work across several websites, with the permissions you choose. |

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.

An account token can only do what you choose for it **and** what your role on each website allows. If your role on a website is lowered, the token loses that access too.

## Permissions

Account tokens and MCP connections use permissions of the form `<resource>:<read|write>`, for example `analytics:read` or `goals:write`. `write` includes `read`. Every scope, the lowest role it needs and whether an AI tool can be granted it are listed in the [OAuth reference](https://reveata.com/docs/oauth#scopes).

## Conventions

- JSON in and out. Every response has the shape `{ "status": "ok", "data": … }` or `{ "status": "error", "error": { "code", "message" } }`.
- Website routes take the website id **or** its domain: `/api/v1/websites/example.com/…`.
- Money is in minor units (cents) in responses; dates are ISO 8601 in UTC; report days are `YYYY-MM-DD` in the website’s time zone.
- Lists are paginated with `?limit=` and an opaque `cursor`.
- Archived websites (after a plan downgrade, or archived by the owner) are listed by `GET /api/v1/websites` with `archived: true` and `archivedAt`. Their other routes answer `409 website_archived` until the owner restores them, except recording payments, which keeps working so no money data is lost.
- Requests are limited to 600 per minute per key. Over the limit you get `429` with a `Retry-After` header.

## Command-line tool

The `reveata` CLI signs in with an account access token and works with the same data as the API from your terminal or scripts: websites and their settings, stats, realtime visitors, goals, funnels, visitor profiles, alerts, notes, segments, the team, API keys and access tokens, and sending goals and payments. Create a token with the permissions you need under **Account → API / MCP**.

Install it from npm with `npm install -g @reveata/cli`. Anything the CLI does, you can also do by calling the API with the same token, for example with `curl` as above.

[Get started with the CLI](https://reveata.com/docs/cli-get-started) covers signing in, the config file and JSON output, and the CLI section of the docs lists every command with its options and examples.
