# Get started with the CLI

> Install the reveata command line tool, sign in with a token, choose a website and get tables or JSON.

The `reveata` command line tool works with the same data as the [REST API](https://reveata.com/docs/api-introduction), from your terminal or your scripts: websites, stats, realtime visitors, goals, funnels, visitor profiles and payments. It can also send goals, payments and crawler requests from your backend.

## Install

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 shown in the [API introduction](https://reveata.com/docs/api-introduction).

It needs Node 22 or newer.

```bash
npm install -g @reveata/cli
reveata --help
```

## Sign in

Create an **account token** (`dt_pat_…`) under **Account → API / MCP** with the permissions you need, or use a website's **site key** (`dt_site_…`) from **Settings → Developer**. [CLI permissions and roles](https://reveata.com/docs/cli-permissions) explains what each command needs.

Then sign in once:

```bash
reveata login --api-url https://reveata.com
```

Without `--token`, the CLI asks for the token (the input is hidden on a terminal; otherwise it reads the first line of standard input). It checks the token with `GET /api/v1/whoami` and saves it, together with the API URL, in the config file. The token is never printed again: output shows a masked form such as `dt_pat_…a91c`.

```bash
echo "$REVEATA_TOKEN" | reveata login --api-url https://reveata.com
reveata whoami
```

## Config file and environment

The token and API URL are saved in `~/.config/reveata/config.json` (under `$XDG_CONFIG_HOME` when it is set). Only you can read the folder (mode 0700) and the file (mode 0600). `reveata logout` removes the token and keeps the API URL.

For both values, a `--token` or `--api-url` flag wins over the environment, and the environment wins over the config file. The CLI reads these environment variables:

- `REVEATA_TOKEN`: API token, used instead of the saved one.
- `REVEATA_API_URL`: Server origin, used instead of the saved one.
- `REVEATA_SITE`: Website id or domain used when --site is not given.
- `REVEATA_CONFIG`: Path of the config file to use instead of the default.
- `REVEATA_BOT_TOKEN`: Website bot request token for bots forward.

## Choose a website

Most commands act on one website, named with `--site <id|domain>`: its id or its domain. Without `--site`, the CLI uses `REVEATA_SITE`, then the default saved with `reveata config set-site` ([reveata config](https://reveata.com/docs/cli-config)), and for a site key the key's own website. An account token can reach several websites, so it must name one.

```bash
reveata sites list
reveata stats overview --site example.com
```

## Tables or JSON

Every command prints a readable table by default. Money is shown in the website's currency, for example `€1,234.50`.

With `--json` the CLI prints the API's `data` as JSON on standard output: the object for one resource, and every collected row (an array) for lists. Money stays in minor units (cents), as the API returns it. Messages, hints and errors always go to standard error, so the output can be piped:

```bash
reveata sites list --json | jq '.[].domain'
```

`--verbose` prints every request with its status and `x-request-id` on standard error. Quote the request id when you contact support.

The exit code is `0` on success, `1` when the API answered with an error or the server could not be reached, and `2` when the command line itself is wrong (an unknown command or option, or a missing argument). A server that does not offer an endpoint yet answers `501 not_implemented`, which the CLI reports as not available on this server yet.

## Options on every command

- `--json`: Print the raw JSON data instead of a table
- `--verbose`: Print every request with its status and x-request-id on stderr
- `--token <token>`: API token for this call (overrides REVEATA_TOKEN and the config file)
- `--api-url <origin>`: Server origin, e.g. https://analytics.example.com (overrides REVEATA_API_URL)
- `-h, --help`: Show help for the command
- `--version`: Print the CLI version

`reveata help <command>` (or `reveata <command> --help`) prints the help of one command, with its options and examples.

## Account commands

`reveata account get` and `account update` read and change your own profile and preferences (`account:read` / `account:write`). To save a default website, see [reveata config](https://reveata.com/docs/cli-config).

### `reveata login`

Verify an API token and save it for later commands.

Accepts an account token (dt_pat_…, Account settings → API / MCP → Account tokens) or a site key (dt_site_…, a website’s Settings → Developer → Site API keys). Without --token you are prompted (hidden input on a terminal; otherwise the first line of stdin is read). The token is checked with GET /api/v1/whoami and saved with the API URL in the config file (mode 0600).

No options beyond the global ones.

Calls [`GET /api/v1/whoami`](https://reveata.com/api-reference/whoami) and [`GET /api/v1/websites`](https://reveata.com/api-reference/list-websites) (`websites:read`).

```bash
reveata login --api-url https://analytics.example.com
reveata login --token "$REVEATA_TOKEN" --api-url http://localhost:3000
```

### `reveata logout`

Remove the saved token from the config file.

No options beyond the global ones.

```bash
reveata logout
```

### `reveata whoami`

Show the credential in use, its scopes and (with --site) its access there.

Options:

- `--site <id|domain>`: Website id or domain (defaults to REVEATA_SITE, or a site key’s own website)

Calls [`GET /api/v1/whoami`](https://reveata.com/api-reference/whoami).

```bash
reveata whoami
reveata whoami --site example.com --json
```

### `reveata account get`

Your profile, sign-in methods and preferences.

No options beyond the global ones.

Calls [`GET /api/v1/account`](https://reveata.com/api-reference/get-account) (`account:read`).

```bash
reveata account get
```

### `reveata account update`

Change your name and preferences.

Options:

- `--name <name>`: Display name
- `--theme <theme>`: light, dark or system
- `--email-notifications <true|false>`: Receive account emails (alerts and reports have their own settings)

Calls [`PATCH /api/v1/account`](https://reveata.com/api-reference/update-account) (`account:write`).

```bash
reveata account update --name "Jane Doe"
reveata account update --theme dark --email-notifications false
```

## Every command

- [reveata sites](https://reveata.com/docs/cli-websites): list, add and inspect websites, and change their settings and attribution.
- [reveata stats](https://reveata.com/docs/cli-analytics): headline metrics, time series, breakdowns and new versus returning visitors.
- [reveata realtime](https://reveata.com/docs/cli-realtime): visitors online right now.
- [reveata goals](https://reveata.com/docs/cli-goals): goal completions and the revenue they bring, recent completions, and goal display settings.
- [reveata funnels](https://reveata.com/docs/cli-funnels): create, change and delete funnels, and read their conversion.
- [reveata visitors](https://reveata.com/docs/cli-visitors): visitor profiles and journeys.
- [reveata events](https://reveata.com/docs/cli-events): send goals from your server.
- [reveata payments, customers and revenue](https://reveata.com/docs/cli-payments): send and list payments, customers and subscription metrics.
- [reveata bots](https://reveata.com/docs/cli-bots): crawler traffic and rules, and forwarding crawler requests from your access logs.
- [reveata team, keys and tokens](https://reveata.com/docs/cli-team): members and invites, website API keys and account access tokens.
- [reveata alerts](https://reveata.com/docs/cli-alerts): alerts and scheduled reports, their tests and history.
- [reveata segments and notes](https://reveata.com/docs/cli-segments-and-notes): saved segments and chart notes.
- [reveata config and completion](https://reveata.com/docs/cli-config): a default website and shell completion.
