> ## Documentation Index
> Fetch the complete documentation index at: https://docs.crispstats.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> CrispStats is a hosted, privacy-first analytics product. It has no self-hosted edition, no session replay, no heatmaps, no A/B testing and no data import except a site's history from a Plausible export (Settings, Import and export). Websites use the script. iOS, Android, React Native and Flutter use the mobile SDKs in the install guides. Those SDKs are source files, not a published package, and they do not read an advertising id.
> The script global is crispstats(...), site keys start with cs_pk_ and secret API keys start with cs_sk_. The script is served from https://in.crispstats.com/d.js and the REST API lives at https://crispstats.com/api/v1.
> The script tag is the main install; the npm package @crispstats/tracker does the same from code, never alongside the tag. Integrations copy the script tag, the queue stub, crispstats.d.ts and proxy code from these docs or from Settings, Tracking code in the dashboard. A first-party proxy forwards one path of the site to https://in.crispstats.com/p/ and forwards only content-type, user-agent, accept-language, referer, origin, if-none-match and x-forwarded-for, never cookies.

# CLI commands

> Every crispstats CLI command with its flags, the API endpoint behind it and an example: stats, breakdowns, realtime and the live map, revenue, payments and trials, goals, events, funnels, retention, visitors, site health, AI crawlers, notes, alerts, sites, the account, keys, raw events and api.

Every command reads the site picked by `--site`, `CRISPSTATS_SITE` or `crispstats use` (see [pick a site](https://docs.crispstats.com/cli/introduction.md#pick-a-site)), and takes the [flags for every command](https://docs.crispstats.com/cli/introduction.md#flags-for-every-command). Each one calls one endpoint of the [REST API](https://docs.crispstats.com/api-reference/introduction.md); its flags are that endpoint's query parameters, and the API names any flag value it does not accept. Run `crispstats <command> --help` for the same list in the terminal.

## Period and filter flags

Most reports take these flags, the [query parameters](https://docs.crispstats.com/api-reference/query-parameters.md) the endpoints share:

| Flag | Query parameter | What it does |
| - | - | - |
| `--range <period>` | `range` | `today`, `yesterday`, `24h`, `7d`, `30d` (default), `90d`, `mtd`, `last_month`, `ytd`, `12m` or `all` |
| `--from <YYYY-MM-DD>`, `--to <YYYY-MM-DD>` | `from`, `to` | A custom period in the site's timezone, both ends inclusive. Use instead of `--range`. |
| `--compare previous\|year` | `compare` | Also show the previous period, or the same period a year earlier |
| `--filter <dimension:op:value>` | `filter` | Narrow the data, such as `country:is:DE` or `page:contains:/blog`. Repeat for more; all must match. |
| `--no-imported` | `imported=false` | Leave out days imported from another tool. On `stats`, `timeseries`, `breakdown` and `events`. |

## Sign in

| Command | What it does |
| - | - |
| `crispstats login` | Opens the API keys section of the API and MCP page, reads a secret key from a hidden prompt (or from stdin when piped), checks it and saves it. `--no-browser` only prints the address. |
| `crispstats logout` | Removes the saved key. The key works until you revoke it. |
| `crispstats whoami` | Checks the key against `GET /sites` and shows where it came from, the API address, the sites it reads and the default site. Never shows the key. |
| `crispstats use <site>` | Saves the default site, by id or by domain. |
| `crispstats sites` | `GET /sites`: the sites the key reads. `*` marks the default. |

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
crispstats login < key.txt   # piped from a file or a secret store, without a prompt
```

## Workspace

| Command | Endpoint | What it does |
| - | - | - |
| `crispstats account` | `GET /account` | The workspace, its plan and trial, this month's usage against the plan's limits, and the key's sites and permissions |
| `crispstats keys` | `GET /keys` | The workspace's keys within this key's sites: name, prefix, sites, permissions, last use, expiry. `*` marks the key in use. Needs **See API keys**. `--include-revoked` adds revoked keys; `--limit` (up to 100) and `--offset` page. `keys list` is the same. Secrets are never shown, and keys are created, rolled and revoked on the API and MCP page. |
| `crispstats sites show [site]` | `GET /sites/{siteId}` | One site with every setting, its exclusions and bot settings. Needs **Sites: read**. |
| `crispstats sites create` | `POST /sites` | Adds a site and prints its public key for the snippet. Needs **Sites: write**, a key for every site, made by an owner or admin. |
| `crispstats sites update [site]` | `PATCH /sites/{siteId}` | Changes only the settings given. Needs **Sites: write**, made by an owner or admin. |

`sites show` and `sites update` act on the site given as their argument, or on `--site` and the default.

`sites create` takes `--domain` (required: a domain, or with `--app` an app's bundle id), `--name`, `--timezone` (IANA, default `UTC`) and `--currency` (default `USD`).

`sites update` takes `--name`, `--domain`, `--timezone`, `--currency`, `--bot-filter off|standard|strict`, the switches `--persist-visitors`, `--paused` and `--public-live-count` (each `on` or `off`), and these lists, each repeatable or comma-separated and each replacing the stored list (pass `""` once to clear it): `--hostname`, `--exclude-path`, `--query-param`, `--excluded-hostname`, `--excluded-country`. `--exclude-ip` and `--include-ip` add or remove one IP address from the excluded ones; only a hash is stored.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
crispstats sites create --domain quillbook.example --timezone Europe/Berlin --currency EUR
crispstats sites update --exclude-path "/admin/*" --exclude-path "/preview/*" --paused off
```

## Traffic

### stats

Key metrics: visitors, sessions, pageviews, views per visit, bounce rate, visit duration, revenue, conversion rate. `GET /sites/{siteId}/stats`.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
crispstats stats --range 7d --compare previous
```

### timeseries

The same metrics per hour, day, week or month. `GET /sites/{siteId}/timeseries`. `--granularity hour|day|week|month`, picked from the period by default.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
crispstats timeseries --range 7d --granularity day
```

### breakdown

Top values of one dimension with visitors, pageviews, bounce rate, duration, revenue and share. `GET /sites/{siteId}/breakdown/{dimension}`. Dimensions: `page`, `entry_page`, `exit_page`, `hostname`, `channel`, `source`, `referrer`, `utm_source`, `utm_medium`, `utm_campaign`, `utm_term`, `utm_content`, `country`, `region`, `city`, `browser`, `os`, `device`, `language`, `event`, `ai_assistant`, `outbound_link`.

| Flag | What it does |
| - | - |
| `--sort <metric>` | `visitors` (default), `pageviews`, `revenue`, `conversionRate` or `bounceRate` |
| `--limit <n>`, `--offset <n>` | One page of rows, up to 100 |
| `--all` | Every page, as one list |
| `--search <text>` | Only rows containing the text |

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
crispstats breakdown country --range 30d --limit 5
```

Shortcuts: `pages`, `sources`, `referrers`, `channels`, `campaigns`, `countries`, `devices` and `browsers` are `breakdown` with that dimension, such as `crispstats sources --range 7d`.

### realtime

Visitors on the site now, pageviews in the last 30 minutes, top pages, sources and countries, and recent payments. `GET /sites/{siteId}/realtime`.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
crispstats realtime
```

### realtime map

Everyone on the site now, up to 200, with country, city, coordinates rounded to 0.1 degrees, page, source, device and whether they have paid, plus the latest payments in `--json`. A visitor known only by country is placed at its centre. `GET /sites/{siteId}/realtime/map`.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
crispstats realtime map --json
```

## Revenue

### revenue

Revenue, new and renewal revenue, refunds, MRR, customers, average order, revenue per visitor and conversion rate. `GET /sites/{siteId}/revenue`.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
crispstats revenue --range mtd
```

### payments

Payments with their kind, amount, product, masked customer, source and country. `GET /sites/{siteId}/payments`. Takes `--limit` (up to 100), `--offset` and `--all`. `crispstats payments list` is the same.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
crispstats payments --range 7d
```

### payments record

Records a payment, renewal, refund or free trial from your own checkout. `POST /sites/{siteId}/payments`, needs a key with **Revenue and payments: write**. See the [payments API](https://docs.crispstats.com/revenue/payment-api.md) for how payments are attributed.

| Flag | Body field | What it is |
| - | - | - |
| `--transaction-id <id>` | `transactionId` | Required. Your id for the payment. Sending it again records nothing new. For a refund, the sale's id. |
| `--amount <minor units>` | `amount` | Required, except with `--trial`. A whole number in minor units: `4900` is 49.00. `49.00` is refused. |
| `--currency <code>` | `currency` | Required with an amount. ISO 4217, such as `USD` |
| `--visitor-id <id>` | `visitorId` | The id from `crispstats.id()`, to credit the visitor's source |
| `--customer-id <id>` | `customerId` | Your id for the customer, as passed to `identify()` |
| `--email <address>` | `email` | Stored only hashed and masked |
| `--product <name>` | `product` | What was bought |
| `--subscription` | `subscription: true` | The first payment of a new subscription |
| `--renewal` | `renewal: true` | A subscription renewal |
| `--refunded` | `refunded: true` | A refund of the sale named by `--transaction-id` |
| `--refund-id <id>` | `refundId` | Refunds only: your id for this refund |
| `--trial` | `trial: true` | A free trial start, not a payment: credited to the visitor's source and never counted as revenue. `--amount` becomes optional: when given, it is the price the trial converts to. Not with `--subscription`, `--renewal`, `--refunded` or `--refund-id`. |
| `--timestamp <ISO time>` | `timestamp` | When it happened, such as `2026-12-01T09:30:00Z`. Defaults to now. |

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
crispstats payments record --transaction-id order_1042 --amount 4900 --currency USD --email ana@example.com
crispstats payments record --trial --transaction-id trial_1042 --email ana@example.com
```

### payments delete

Deletes payments recorded through the API, such as test sales, and free trials recorded through the API that match. Payments from a connected provider are never deleted. `DELETE /sites/{siteId}/payments`, needs **Revenue and payments: write**. Pick the payments with `--transaction-id`, with `--visitor-id` (optionally within `--from` and `--to`), or with both `--from` and `--to`.

It asks before deleting. Pass `--yes` to skip the question; without a terminal to ask in, `--yes` is required. The API deletes up to 1,000 payments a call; the CLI calls again until everything that matches is gone.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
crispstats payments delete --transaction-id test_order_1
```

## Conversions

### goals

Goals with completions, unique visitors, conversion rate and revenue. `GET /sites/{siteId}/goals`.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
crispstats goals --range 30d
```

### events

Custom events with count, unique visitors and when each was last seen. `GET /sites/{siteId}/events`. `--limit` up to 100.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
crispstats events --range 7d
```

### events properties

One custom event broken down by its properties. `GET /sites/{siteId}/events/{event}/properties`. `--limit` values per property, up to 50.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
crispstats events properties signup --range 7d
```

### events delete

Deletes custom events of one name, such as test events, between two days or times. Pageviews and errors are never touched. `DELETE /sites/{siteId}/events`, needs **Goals and events: write** from a key made by an owner or admin. `--name <event>` or `--goal <id>` (a goal that counts an event) picks the events; `--from` and `--to` are both required, each a day in the site's timezone or an ISO time, `--to` inclusive.

It asks before deleting, like `payments delete`, and accepts `--yes`. The API deletes up to 1,000 events a call; the CLI calls again until none match.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
crispstats events delete --name test_signup --from 2026-12-01 --to 2026-12-02
```

### funnels

Without an argument, the site's funnels (`GET /sites/{siteId}/funnels`). With a funnel id, each step with visitors, conversion from the start and from the previous step, drop-off and median time (`GET /sites/{siteId}/funnels/{funnelId}`). `--segment-by <dimension>` splits each step.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
crispstats funnels funnel_signup --range 30d
```

### funnels create, update and delete

`funnels create` makes a funnel from its steps (`POST /sites/{siteId}/funnels`), `funnels update <funnel>` changes only what is given (`PATCH`), and `funnels delete <funnel>` removes it (`DELETE`, asks first, accepts `--yes`). They need **Funnels: write**.

| Flag | What it does |
| - | - |
| `--name <name>` | The funnel's name, unique on the site. Required to create. |
| `--step <step>` | One step, in order, 2 to 12 of them: `page:/pricing` (a path, `*` at the end matches below it) or `event:signup`. Put a name in front to label it: `Saw pricing=page:/pricing`. On update, the steps given replace all of them. |
| `--window <length>` | How long a visitor has to finish: `30m`, `24h`, `7d` (the default) or seconds |

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
crispstats funnels create --name Signup --step page:/ --step page:/pricing --step event:signup --window 7d
```

### retention

Cohorts of visitors by when they were first seen and the share that came back in each later interval. `GET /sites/{siteId}/retention`. `--interval day|week|month`, week by default.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
crispstats retention --interval week
```

## Visitors

### visitors

Without an argument, visitors with country, device, sessions, pageviews, revenue and first source (`GET /sites/{siteId}/visitors`). With a visitor id, that visitor and their sessions (`GET /sites/{siteId}/visitors/{visitorId}`, `--sessions <n>` for how many).

| Flag | What it does |
| - | - |
| `--segment <who>` | `all` (default), `customers`, `identified`, `online` or `returning` |
| `--sort <order>` | `lastSeen` (default), `revenue`, `sessions` or `pageviews` |
| `--search <text>` | Only visitors matching the text |
| `--limit <n>`, `--offset <n>`, `--all` | Paging, up to 100 a page |

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
crispstats visitors --segment customers --sort revenue
```

## Health and AI

| Command | Endpoint | What it shows |
| - | - | - |
| `crispstats vitals` | `GET /sites/{siteId}/vitals` | The score and p75, p50 and rating of each core web vital |
| `crispstats errors` | `GET /sites/{siteId}/errors` | JavaScript errors grouped by message. `--status open\|resolved\|ignored`. |
| `crispstats uptime` | `GET /sites/{siteId}/uptime` | Monitors with status, uptime and response times |
| `crispstats ai-traffic` | `GET /sites/{siteId}/ai-traffic` | Visitors, share and revenue from AI assistants |
| `crispstats bots traffic` | `GET /sites/{siteId}/bot-traffic` | AI crawler hits by crawler, with operator, purpose and change. `--category training\|search\|user`, `--operator`, `--crawler`, `--verified` (only verified hits), `--include-hidden`, `--granularity` for the series in `--json`, and `--range`, `--from`, `--to`. |
| `crispstats bots pages` | `GET /sites/{siteId}/bot-traffic/pages` | The pages crawlers read most. `--search`, `--limit` (up to 200), `--offset`, `--verified`, `--include-hidden`. |
| `crispstats bots settings` | `GET` and `PUT /sites/{siteId}/bot-settings` | Which crawlers are hidden from reports or not recorded. With flags it changes them: `--hide` and `--show`, `--exclude` and `--record` (each repeatable), `--verified-only on\|off`. Changing needs **Sites: write** from an owner or admin. `--exclude` asks first, since a crawler that is not recorded leaves no hits to recover. |

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
crispstats errors --status open --range 7d
crispstats bots settings --hide CCBot --exclude Bytespider
```

## Notes and alerts

### notes

`crispstats notes` lists the dated notes on the charts, newest first (`GET /sites/{siteId}/notes`, **Notes: read**). `--from` and `--to` (days), `--search`, `--limit` (up to 500) and `--offset`. `notes list` is the same.

`crispstats notes add "<text>"` adds one (`POST`, **Notes: write**). `--at` picks the day: `now` (the default, today in the site's timezone), `YYYY-MM-DD`, or an ISO time placed on its day in the site's timezone. The same text on the same day is added once, so a deploy script can run it on every deploy and retries never stack notes.

`crispstats notes update <note>` changes `--text` or `--at` (`PATCH`). `crispstats notes delete <note>` removes it (`DELETE`), asking first; `--yes` skips the question.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
crispstats notes add "Shipped pricing page" --at now
```

### alerts

| Command | Endpoint | What it does |
| - | - | - |
| `crispstats alerts [alert]` | `GET /sites/{siteId}/alerts`, `GET /alerts/{alertId}` | The site's alert rules and the workspace's notification channels by name (never their addresses), or one rule. **Alerts: read**. `alerts list` is the same. |
| `crispstats alerts create` | `POST /sites/{siteId}/alerts` | A new rule from flags. **Alerts: write**. |
| `crispstats alerts delete <alert>` | `DELETE /sites/{siteId}/alerts/{alertId}` | Removes a rule, asking first; `--yes` skips the question. |
| `crispstats alerts history` | `GET /sites/{siteId}/alerts/history` | What the alerts sent, newest first. `--alert <id>`, `--limit` (up to 200), `--offset`. |

`alerts create` takes `--name` and `--rule` (both required; the rule is one of `traffic_spike`, `traffic_drop`, `no_traffic`, `error_spike`, `new_error`, `vitals_regression`, `monitor_down`, `goal_completed`, `revenue_received`, `revenue_milestone`, `usage_limit`), `--threshold` (a ratio such as `1.5` for spikes and drops, a count for errors, minor units for revenue, milliseconds for vitals), `--window` and `--cooldown` in minutes (60 by default), `--channel <id>` (repeatable, from `alerts`; with none the alert is only logged in its history), `--metric`, `--goal <id>` (repeatable) and `--delivery each|summary` for `goal_completed`, `--monitor <id>` for `monitor_down`, and `--disabled` to create it switched off.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
crispstats alerts create --name "Traffic doubled" --rule traffic_spike --threshold 2 --channel 3b2a6c1e-…
```

## Raw data

### raw-events

The site's events one by one, oldest first, for exports. `GET /sites/{siteId}/raw-events`, needs a key with **Raw events export** and **Visitor details**. `--from` is required; `--to` defaults to now. A page holds up to 10,000 events (`--limit`); pass the printed cursor back with `--cursor`, or use `--all` to follow every page. The table shows a few columns: `--json` has them all. See [raw events](https://docs.crispstats.com/api-reference/raw-events.md).

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
crispstats raw-events --from 2026-11-01 --to 2026-11-30 --all --json > events.json
```

### api

Calls any endpoint, for what has no command yet. The path is relative to `/api/v1` (a full path or URL on the API's own host works too; the key is never sent to another host). `-q key=value` adds a query parameter, repeatable. `-d` sends a JSON body: inline, `@file` to read a file, or `-` for stdin. A `DELETE` asks first, like `payments delete`.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
crispstats api GET /sites/demo/breakdown/country -q range=7d -q limit=5
```

The response body is printed as sent, formatted for reading when the output is a terminal and untouched otherwise or with `--json`.


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