<!-- Key events — Heystack docs. Rendered: https://heystack.dev/docs/key-events · Index: https://heystack.dev/llms.txt -->
# Key events

A **key event** is a moment that matters in your app: someone signs up, checks out, uploads a file or invites a teammate.
Tell Heystack which moments matter, and it counts each one every day, shows you the trend, and opens an issue when one
drops sharply.

Key events live in **Users & sessions › Key events** (`/key-events` in the console). Pick an app first: key events are
set up per app, and each app can have up to 50 turned on.

## What a key event can be

| Kind | What it matches | Example |
|---|---|---|
| A request to your app | A route, optionally with its method and result (succeeded, refused or failed) | `POST /api/auth/signup → 2xx` |
| An event your app sends | A product event by name, optionally with its feature and outcome | `signup.completed`, outcome `succeeded` |
| A page click or view | An automatically captured click target or page path | the "Start trial" button on `/pricing` |
| Your sign-in or payment provider | An event reported by a connected provider | a new customer in your payment provider |

Provider key events are created for you when you connect a provider and turn its key events on; the other three you
define yourself, or add from a suggestion. Page clicks and views count once your app sends automatically captured
activity.

A key event matches on exact values (or a value that starts with some text, such as every route under `/api/upload/`).
There are no wildcards, no "or" and no "not". A request key event needs a route: a method or a result on its own would
match almost everything.

## Seen in traffic or confirmed

Every key event carries an evidence label, and the two look different on purpose:

- **Seen in traffic** (a dashed outline): Heystack saw requests or events that match. That is all it means. A request
  that came back `200 OK` shows that your server answered, not that the person finished what they set out to do: a
  sign-up form can return 200 with a validation error in the page, a payment can be accepted and later fail. Treat these
  counts as activity, not as completed outcomes.
- **Confirmed by your app** or **Confirmed by your provider** (solid, ticked): the app reported the action as succeeded
  at the point where it knows it worked (an event with outcome `succeeded`), or your sign-in or payment provider reported
  it.

A key event is never shown as confirmed because of a status code. If you want a confirmed count, send a product event
with `outcome: "succeeded"` from the place in your code that knows the action worked (see
[Product activity](https://heystack.dev/docs/product-activity)), and define the key event on that event.

## When counting starts

Heystack starts counting a new key event about two minutes after you save it, so every server has picked it up before
the first one is counted. Each key event says where its counts begin, for example **Counted from Oct 18, 2026**. Counts
are kept per UTC day.

**History.** Events your app sends are counted from what is already stored, with nothing to wait for. For requests and
page clicks, Heystack counts the last 30 days once, in the background, starting about five minutes after you save; the
card says **Counting history…** until it's done. Each history count:

- covers up to 20,000 matches. A very busy key event stops there; the card says **Counted from** the oldest day it
  reached and offers **Backfill earlier**, which counts further back with the same limit.
- is limited to 5 per organisation per day, and only admins can start one.
- never counts anything twice: history stops exactly where live counting starts, and running it again (or retrying
  one that failed part-way) only counts the days not yet counted.
- may fail on a very busy app ("This app is too busy to backfill 30 days at once"). The card then offers **Try 7 days**.
- waits when Heystack is holding back detailed reads to stay within your usage limits. The card says so and offers
  **Retry**; it never retries on its own.

Days before **Counted from** are unknown, not zero.

## Changing a key event

You can rename a key event or turn it off at any time. Turning it off keeps its counts.

Changing **what it matches** saves a new version instead of editing the old one: the new version starts counting about
two minutes later and counts its history again, and the old version's counts are kept as they were, so two different
definitions are never mixed in one chart. **Show turned-off and older versions** lists them.

## Suggestions

Not sure where to start? **Suggest key events** looks at your app's busiest routes over the last 7 days and the events it
sends, and proposes moments worth counting, each with its 7-day count and why it was suggested:

- **Pattern**: a common moment Heystack recognises (sign up, log in, checkout, subscribe, pay, upload, invite,
  onboarding, creating a first project, known payment webhooks). Health checks, static files and webhook noise are left
  out.
- **AI**: an optional pass that reads the same list and proposes key events and journeys. It sees route templates,
  methods, the success and failure mix, counts and event names only: no ids, no people, no request contents and no query
  strings. It uses AI credits, and it is skipped (patterns only, and the panel says why) when your organisation has
  turned AI processing off or is out of credits.

Nothing is turned on automatically: a suggestion becomes a key event only when an admin chooses **Add**, which also
starts its history count. Suggestions are kept for a day. Members and admins can ask for new ones up to 3 times per app
per day; asking again for the same day's list doesn't count.

Suggestions can also include **journeys**, a few key events people tend to complete in order (sign up, create a
project, invite a teammate). **Save journey** keeps one for later: funnels for saved journeys arrive in a later update.

## When a key event drops

Each key event is checked against its own normal: Heystack compares yesterday's complete day (UTC) with the same
weekday over the previous 4 weeks. Only whole days are compared, so a key event that happens only in part of the day
(say, sign-ups during US business hours) is never reported as dropping every morning. When the usual count is at least
50 and the current count is at least 40% lower, **Issues** shows a usage drop for that key event, with a release first
seen in that window named as a possible cause. Below 50 the state is unknown: too little traffic to tell, never shown
as healthy.

For a notification, create an alert rule of type `key_event_rate` through the [API](https://heystack.dev/docs/api#alerts): its value is the
same drop, as a percentage, for yesterday's complete day (window `24h`, the only one, because counts are kept per
day), taken as the
largest drop among the app's key events, so a rule "above 40" fires like the usage-drop issue. While a key event's
usual count is unknown, the rule doesn't fire for it. Both the issue and the alert are worked out from the stored daily
counts, so they add no load to your app's data. Editing a key event keeps its alert rules: they follow the edited
key event.

## Event catalogue

**Users & sessions › Key events › Event catalogue** lists every event name your app has sent, with when Heystack first and
last saw it. Admins can:

- **Rename** an event (the display name only), **hide** it, or **merge** it into another, for example after renaming it
  in your code. Events already stored are never rewritten, so each of these can be undone.
- Set **property rules**: which event properties are kept (Keep) or removed (Drop). See
  [Product activity](https://heystack.dev/docs/product-activity#what-heystack-stores).
- Change the **daily event budget**, and see today's volume and anything dropped.

Each app keeps up to 500 event names; events with a new name past that are dropped and counted.

## For coding agents

The [MCP server](https://heystack.dev/docs/mcp) has two key-event tools in the `manage` toolset: `heystack_list_key_events` (counts,
evidence and history state for an app) and `heystack_define_key_event` (admin; define one from a matcher). A matcher is a
small JSON object, for example:

```json
{ "v": 1, "source": "event",
  "all": [
    { "field": "event_name", "op": "eq", "value": "signup.completed" },
    { "field": "outcome", "op": "eq", "value": "succeeded" }
  ] }
```

A request matcher uses `"source": "span"` with `http_route`, `http_method` and `status_class` (`2xx` to `5xx`). The
REST routes are under `/api/key-events` and `/api/events` in the [API reference](https://heystack.dev/docs/api).
