# Stats API (/docs/api/stats)

The stats API gives your own tools the numbers the dashboard shows, so you can check them, chart them somewhere else or load them into a warehouse. [`/openapi.json`](https://numbers.obelism.studio/openapi.json) describes it, under the `readToken` security scheme.

## Read tokens [#read-tokens]

A developer or admin of the Space makes one on the setup page: **API tokens**, with **Can: Read numbers**. A token belongs to one Space and one environment, and is shown once.

- A read token starts with `numr_`. It reads the stats API and can't send events.
- A token that sends events (`num_…`, **Send events**) can't read. Make one of each.
- Keep read tokens on servers and in scripts: the stats API answers no browser (there is no CORS), and a read token reads every event of its environment.
- Revoke a token on the setup page. The list shows who created each one, when it expires and when it was last used. A token can expire in 30 days, 90 days or a year, or never; an expired token is refused like a revoked one.

```
Authorization: Bearer numr_…
```

The token names the Space and environment, so the paths don't.

## Endpoints [#endpoints]

| Request                      | Answers                                                                                          |
| ---------------------------- | ------------------------------------------------------------------------------------------------ |
| `GET /api/v1/report`         | The dashboard's overview as JSON: the totals against the range before, the series, the top lists. |
| `GET /api/v1/export/{table}` | A report table as CSV: see [Export to CSV](/docs/api/export).                                    |
| `GET /api/v1/events`         | Every event as stored, a page at a time.                                                         |
| `GET /api/v1/funnels`        | The environment's saved funnels, with their ids.                                                 |
| `GET /api/v1/buckets`        | The environment's campaign buckets, with their ids.                                              |

`report` and `export` take `range` (`24h`, `7d` by default, `30d` or `90d`) and the same [filters](/docs/api/agent#filters) as the agent API. The funnel table's `funnelId` comes from `/api/v1/funnels`, and the `bucket` filter's ids from `/api/v1/buckets`.

## Raw events [#raw-events]

`GET /api/v1/events?from=2026-11-01&to=2026-11-08` answers the events between `from` and `to`, oldest first.

| Parameter | Takes                                                                         |
| --------- | ----------------------------------------------------------------------------- |
| `from`    | A date (`2026-11-01`, midnight UTC) or an ISO 8601 date-time. Required.        |
| `to`      | The same, at most 366 days after `from`. Now when left out.                     |
| `limit`   | Events per page, 1 to 1,000. 1,000 when left out.                              |
| `cursor`  | The `nextCursor` of the page before.                                           |
| `format`  | `json` (the default) or `csv`.                                                |

A JSON page has `events`, the `from` and `to` it read, and `nextCursor`, which is null on the last page. A CSV page carries the cursor in the `Next-Cursor` header instead. Send every next page the `from` and `to` the first page echoed: left out, `to` is now again on each call. Events that arrive later land on later pages, so none is skipped or repeated.

Each event has `id`, `timestamp` (UTC, to the microsecond), `visitorId`, `event`, `scope`, `value`, `currency`, `params`, `path`, `referrer`, `utmSource`, `utmMedium`, `utmCampaign`, `device`, `browser`, `os`, `screen`, `pointer`, `visitor`, `country` and `region`. That is what Numbers stores and nothing more: there are no IP addresses, and paths and referrers come without their query strings (see [Privacy](/docs/privacy)).

## Limits and errors [#limits-and-errors]

- 300 requests a minute, per token and per address. Every answer carries `RateLimit-Policy`. Past the limit the answer is a `429` with `RateLimit` and `Retry-After`.
- Every answer is `Cache-Control: private, no-store`.
- Errors are JSON [problem details](/docs/api/errors): `unauthorized` (no token, or one that is unknown, revoked, expired or sends events), `invalid_request` (a parameter the path doesn't take, one sent twice, or a value it can't read), `not_found` (a funnel this environment doesn't have) and `rate_limited`.
