# Customer Health Score From PostHog for Each Account

A customer-success platform gives each SaaS customer an agent that reads its PostHog weekly and scores every account's product usage, with the reason for each drop.

[Run this on Rush](https://cloud.getrush.ai/run/customer-health-score-for-each-account/posthog/). Opens the console with this prompt ready to send. Connect PostHog there first.

## What the agent does

This is for a company that sells a customer-success platform to B2B SaaS companies: their CS managers see every account, its renewal date, its support tickets and a health score that says which accounts need a call. The usage part of that score is the hard part. Each SaaS customer tracks product usage in its own PostHog, with its own event names and its own idea of what an engaged account looks like, so the platform's team used to build every customer's usage query by hand during onboarding and fix it whenever the customer renamed an event. The platform now gives each customer an agent that reads that customer's PostHog every week and returns a usage score per account, with the reason behind each one that fell.

The platform's team connects its own PostHog once at `POST /me/connections {"type": "mcp", "name": "posthog", "url": "https://mcp.posthog.com/mcp"}` and saves the agent as a template with `POST /o/{org}/agents`, naming `"connections": ["posthog"]` and instructions that keep it to reading. When a SaaS company becomes a customer, the platform makes its agent with `{"template": "<template id>", "name": "health-<customer id>"}`, stores the id against the customer, and calls `POST /o/{org}/agents/{agent}/connections {"type": "mcp", "name": "posthog"}`. The customer's PostHog admin opens the `authorize_url` in a popup and signs in on PostHog's page, which routes to the customer's US or EU region and asks which projects to allow; PostHog refuses the agent's requests to any other project. The platform registers no OAuth app and holds no PostHog key.

Each week the agent starts from the settings the platform stores for that customer: the PostHog project, the group type that stands for a customer account, the three or four key events that mean real use, and the weights for the score. It calls `groups-types-list` to confirm the group type and `read-data-schema` to confirm each key event still exists, and stops with a clear message if one was renamed. Then it runs `execute-sql` queries over the last eight weeks of events, grouped by account: weekly active users for each of the last four weeks against the four before, how many accounts used each key event and how often, the share of an account's people active in the last 14 days, and the last time anyone at the account was seen. It reads each account's name from `groups-list` so the scores carry names rather than keys.

From those numbers it computes each account's usage score from 0 to 100 with the customer's weights, and a band: healthy, watch or at risk, by the cut-offs in the input. For every account that dropped a band since last week's scores, which the platform sends in the input, it writes one or two sentences on why, from the data: active users halved, a key feature unused for three weeks, only one person still logging in. It writes `health-scores.csv` with every account's inputs and score, `drops.md` with the accounts that fell, and returns the scores as JSON. It creates no insight, cohort or property in PostHog and changes nothing there.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "<agent id>",
  "input": "Score product usage for every customer account for the week ending 2026-11-29. Read only: use groups-types-list, groups-list, read-data-schema and execute-sql; do not create, update or delete anything in PostHog. Settings: PostHog project 'Ledgerly production'; the account group type is 'company'; key events are 'invoice_sent', 'bank_feed_connected' and 'report_exported'. 1) groups-types-list: confirm 'company' exists; read-data-schema: confirm all three events exist. If any is missing or renamed, stop and report which. 2) With execute-sql, for each company over the 8 weeks from 2026-10-06 to 2026-11-29: weekly active users (distinct persons with any event) for each week; for each key event, the number of weeks it was used in the last 4 and its total count in the last 4 weeks; distinct persons active in the last 14 days and in the last 90 days; last event timestamp. 3) groups-list for each company's name. Score each company 0 to 100: 40 points for active users in the last 4 weeks compared with the 4 before (40 at 100% or more, scaled down to 0 at 0%), 30 points for key event use (10 per event used in at least 3 of the last 4 weeks), 20 points for the share of 90-day active persons active in the last 14 days, 10 points if anyone was active in the last 3 days. Bands: healthy 70 and over, watch 40 to 69, at risk under 40. Last week's bands: {\"Brightwater Dental\": \"healthy\", \"Kestrel Logistics\": \"watch\", \"Oakline Studio\": \"healthy\"}. For every company that moved down a band, write one or two sentences on why, using only the numbers above. Write health-scores.csv (company, group_key, score, band, last_week_band, wau_last4, wau_prev4, key_events_weeks, active_14d, active_90d, last_seen) and drops.md. End with JSON {week_ending, accounts: [{company, score, band, last_week_band, reason}], missing_settings: [], notes: []}. Do not guess at reasons the data does not show."
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

`health-scores.csv` gives each account a usage health score, and `drops.md` lists the accounts that dropped with the reason for each. The same scores come back as JSON in the session's `result`, which the `run.completed` webhook carries to the platform's server, and both files are on the session. The platform stores the scores as the usage part of each account's health, shows the band beside the renewal date, and puts the accounts that dropped at the top of the CS manager's list with the agent's reason under each. Every score carries the numbers it was computed from, so a CS manager can see that an account fell because two of three key events went quiet, not because of a formula they cannot read.

What the CS manager checks before calling: whether the drop has an explanation the data cannot see, such as a customer's holiday shutdown, a planned migration, or a champion who moved to another tool inside the same company, and the platform's own billing and support signals, which this score leaves out. If the agent reports a key event as missing, someone on the customer's side renamed it and the settings need updating before next week. The agent writes no note to the customer and changes nothing in PostHog.

## Run it on every Monday morning

The platform starts one run per SaaS customer each Monday at 5:00 in that customer's timezone: `POST /o/{org}/sessions` with `{"agent": "<agent id>", "input": "…"}` for that customer's agent, the input written from the settings the platform stores and last week's bands from the previous run's JSON, with a `request_id` that is a UUID v5 of the customer id and the week, so a retried scheduler starts nothing twice.

A platform with three hundred SaaS customers starts three hundred runs at once, each on its own computer and each signed into only its own customer's PostHog. A CS manager preparing for a renewal call can start the same agent mid-week for a fresh score of that customer's accounts.

## Why run it on Rush?

Each SaaS customer's PostHog sign-in is held in Rush's connection under that customer's own agent, limited by PostHog to the projects the customer allowed, so the platform keeps no PostHog keys and no run can read another customer's analytics. Each session lists the PostHog connection it used in `accounts`, and `GET /o/{org}/sessions?account=<connection id>` lists every run that used it, which answers a customer's security review asking what the platform read.

A fixed usage query breaks the week a customer renames an event and goes on scoring every account as idle. The agent checks the schema first, stops and says what changed when an event is gone, and writes the reason behind each drop in words a CS manager can repeat on a call. Each run has its own computer and a record of every query it ran, and `GET /o/{org}/sessions?agent=<agent id>` adds up what each customer's scoring costs in model calls.

## Frequently asked questions

### What is a customer health score?

A number or band per customer account that says how likely it is to renew, built from signals such as product usage, support tickets, billing and the relationship. This agent produces the product usage part from PostHog; the platform combines it with the other signals.

### Does the SaaS company need PostHog group analytics?

Scoring by account needs events tied to an account, which in PostHog means a group type such as company or organization. If a customer sends no groups, the agent reports that the group type is missing and scores nothing, rather than guessing accounts from email domains.

### Can the customer change what counts as healthy?

Yes. The key events, weights and band cut-offs are in the input the platform writes from each customer's settings, so a customer who decides exports matter more than invoices changes a setting and next Monday's scores use it.

### Does it write scores back into PostHog?

No. The prompt keeps it to reading, and the scores go to the platform through the result and the files. A customer who wants the score as a PostHog group property can have the platform set it, with a person deciding that it should.

## More PostHog jobs

- [Summarize PostHog Experiment Results](https://getrush.ai/run/experiment-results/posthog/)
- [Which of Our Customers' Accounts Stopped Using the Product This Week? A Customer-Success App's Weekly Check of Each Customer's PostHog](https://getrush.ai/run/find-accounts-whose-usage-dropped/posthog/)
- [Find Where Users Drop Off in a PostHog Funnel](https://getrush.ai/run/funnel-drop-off-report/posthog/)

## More jobs like this: Run an agent per customer task

- [Dunning Email for Each Failed Stripe Payment](https://getrush.ai/run/draft-a-dunning-email-for-each-failed-payment/stripe/)
- [Chargeback Response Drafts for Each Square Dispute](https://getrush.ai/run/draft-each-chargeback-response/square/)
- [How Did My Client's Site Do Last Month? A Reporting App Drafts Each Agency's Client Reports From Vercel Web Analytics](https://getrush.ai/run/draft-each-clients-monthly-traffic-report/vercel/)

## Keep reading

- [Connect PostHog to Rush once, then name it on any run](https://getrush.ai/integrations/posthog/)
- [Start your first run from the developer API quickstart](https://getrush.ai/docs/quickstart/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
