---
title: "Retrieve event counts"
method: GET
path: "/api/v1/events/stats"
tags: ["Events"]
---

# Retrieve event counts

`GET /api/v1/events/stats`

## Request

- Base URL: `https://api.sendly.now`
- URL: `https://api.sendly.now/api/v1/events/stats`
- Auth: one of:
  - HTTP bearer
  - API key in cookie `better-auth.session_token`
  - OAuth 2 (authorization code, authorization URL `https://app.sendly.now/api/auth/oauth2/authorize`, token URL `https://app.sendly.now/api/auth/oauth2/token`, scopes: `events:read`)

Per-name event counts over a bounded window, most frequent first.

The window defaults to the last 30 days and never reaches further back than 90: this is a GROUP BY over the highest-volume table in the system, and an all-time answer is not one it can keep giving at scale. A wider request is narrowed rather than refused, and the `window` field states the range actually covered.

Requires the `events:read` scope — View the custom events your application has recorded.

## Query parameters

- `from` string, date-time, nullable: Start of the window (ISO 8601). Defaults to 30 days ago; clamped to at most 90 days back.
- `to` string, date-time, nullable: End of the window (ISO 8601). Defaults to now.

## Response `200`

Event counts

- EventStatsV1: Per-name event counts over the applied window.
  - `data` object[], required
    - `count` integer, required
    - `name` string, required
  - `window` AnalyticsWindowV1, required: The time range this response was computed over, after the 90-day clamp.
    - `from` string, date-time, required
    - `to` string, date-time, required

## Other responses

- `401`: `invalid_api_key` or `invalid_session` — missing or invalid credentials.
- `403`: `scope_missing`, `project_access_denied`, or `project_disabled`.
- `422`: `validation_error` — query, path, or body parameters did not match the schema.
- `429`: `rate_limited` — see `Retry-After` and the `RateLimit` headers.
- `500`: `internal_error`.

---

[API](https://skmtc.dev/sendly/apis/sendly-api.md) · [All operations](https://skmtc.dev/sendly/apis/sendly-api/llms.txt) · [OpenAPI document](https://skmtc.dev/sendly/apis/sendly-api/revisions/ce7cfb7f7c7e?raw)
