# How Many Subscribers Did We Gain and Lose This Week? A Meal-Kit Company's Monday Report From PlanetScale

A meal-kit subscription company's agent runs read-only queries on its PlanetScale database each Monday and reports new, paused and cancelled subscriptions.

[Run this on Rush](https://cloud.getrush.ai/run/weekly-new-and-cancelled-subscriptions/planetscale/). Opens the console with this prompt ready to send. Connect PlanetScale there first.

## What the agent does

This is for a meal-kit company that sells weekly boxes on subscription. Its own app keeps every subscription in a PlanetScale database: a `subscriptions` table with `id`, `plan`, `status`, `started_at`, `paused_at`, `cancelled_at` and a free-text `cancel_reason` the customer types when they leave. On Monday the head of growth wants one page: how many people started, paused and cancelled last week, on which plans, why the leavers said they left, and how many cancelled within their first four boxes. Today an engineer runs those queries by hand when someone asks, which is not every week.

The run names one connection, `planetscale`, which the head of growth signed in to through PlanetScale's own OAuth page. Two settings keep it to reading. An organization administrator sets **MCP query access** to read-only queries in the organization's settings, and during sign-in the person picks read-only access for this database. PlanetScale's server sends reads to a replica by default when the branch has one, so the report never adds load to the primary that takes orders, and every query carries a `source=planetscale-mcp` comment, so the engineers can see the report's queries in Insights.

The agent calls `planetscale_list_databases` and `planetscale_get_branch_schema` on the `main` branch to check that the table and columns the prompt names exist, and stops with a note if one does not. Then it runs `planetscale_execute_read_query` for the counts: subscriptions started, paused and cancelled between Monday and Monday, each by `plan`; the same counts for the week before; and the cancellations whose `started_at` was less than 28 days before `cancelled_at`, the people who left inside their first four boxes.

For the reasons, it selects only `plan` and `cancel_reason` for last week's cancellations, never a name, email or address, groups the reasons into a few themes in the customer's own words (price, too much food, delivery problems, moving, going on holiday), counts each theme and quotes two or three reasons per theme as written. It writes `subscriptions-week.md` with the counts, the change from the week before, the early-cancellation number and the reason themes, and `subscriptions-week.csv` with the counts by plan for the growth team's sheet.

## Start it with one API call

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

```json
{
  "agent": "claude",
  "input": "Report last week's subscription changes from our PlanetScale database. Use the planetscale connection, database mealkit, branch main. 1) Call planetscale_get_branch_schema and confirm table subscriptions has id, plan, status, started_at, paused_at, cancelled_at, cancel_reason; if not, stop and say what is missing. 2) With planetscale_execute_read_query only, for 2026-11-09 00:00 to 2026-11-16 00:00 UTC: count subscriptions started (started_at), paused (paused_at) and cancelled (cancelled_at) in the week, each by plan; the same for 2026-11-02 to 2026-11-09; and count last week's cancellations where cancelled_at is less than 28 days after started_at, by plan. 3) Select only plan and cancel_reason for last week's cancellations, no other columns. Group the reasons into at most eight themes, count each, and quote up to three reasons per theme exactly as written. Write subscriptions-week.md (totals, by plan, change from the week before, early cancellations, reason themes) and subscriptions-week.csv (plan, started, paused, cancelled, early cancelled, each with last week's value). Do not call planetscale_execute_write_query, planetscale_update_payment_method, planetscale_start_insights_agent_run, planetscale_update_insights_agent_schedule or any tool that changes anything. Select no names, emails, phone numbers or addresses.",
  "connections": [
    "planetscale"
  ]
}
```

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

The session returns `subscriptions-week.md` and `subscriptions-week.csv` as artifacts. The Markdown opens with the week's net change and the three numbers behind it, then the plans that moved most, then the early cancellations, then the reasons people gave grouped into themes with their counts and a few quotes, so the head of growth reads in one place what changed and what customers said about it.

What a person checks before acting on it: that the week's numbers match what the billing provider shows, since a subscription paused and resumed in the same week counts once in each column; that a jump in one plan is not a promotion that ended or a plan the team renamed; and that the theme the agent put a reason under is the one they would choose, because free text like "too expensive for what it is" could be read as price or as quality. The quotes are there so the reader can judge that.

## Run it on every Monday morning

The head of growth saves the agent with `POST /o/{org}/agents`, naming `planetscale` and the instructions above with "last week, Monday to Monday in UTC" in place of the dates, and adds a console automation with a `schedule` trigger, `cron` `0 6 * * 1`, so the report is ready before the weekly meeting. A schedule fills nothing into the prompt, so the instructions name every table and column.

After a price change or a new menu, the same agent can be started by hand with a two-week window in `input` to compare the weeks before and after, with no change to the Monday automation.

## Why run it on Rush?

The database behind a meal-kit app holds every customer's address and order history. On Rush the PlanetScale sign-in stays in the connection, read-only at two levels set by the people who own the data, and the prompt keeps personal columns out of every query; a script with a database password on someone's laptop has neither limit. Each query runs with short-lived credentials that PlanetScale deletes after it finishes.

Each Monday's run has its own computer and a record of every query it sent and what its model calls cost. When the board asks where a churn number came from, the answer is a run with the exact SQL in it, not a dashboard someone built two years ago and nobody can check.

## Frequently asked questions

### Will the report slow down our checkout?

PlanetScale's server sends read queries to a replica by default when the branch has one, so the counts run away from the primary that takes orders. On a branch with no replica they run on the primary, where a few grouped counts over one table are small.

### Can the agent write to the database?

Not if the organization's MCP query access is set to read-only queries and the person chose read-only access at sign-in; PlanetScale applies that setting to new sign-ins, so set it before connecting. The prompt also forbids the write tool, and the run's record lists every call.

### Our schema is different. Does that matter?

Change the table and column names in the prompt. The agent checks them with `planetscale_get_branch_schema` first and stops with a note when one is missing, so a renamed column shows up as a message, not a wrong count.

### Does the agent see customer details?

The prompt lets it select only plan, dates and the cancel reason. A customer can still type something personal into a free-text reason, so whoever reads the quotes should treat the report as internal.

## More PlanetScale jobs

- [Which Orders Are Stuck Between Paid and Shipped? A Back-Office App's Morning Check of Each Marketplace's PlanetScale Database](https://getrush.ai/run/find-orders-stuck-between-paid-and-shipped/planetscale/)
- [Which Upcoming Shows Are Selling Slower Than Usual? A Ticketing Platform's Monday Check of Its PlanetScale Database](https://getrush.ai/run/find-shows-selling-slower-than-usual/planetscale/)
- [Find the Free Trials That Never Activated, Straight From Your PlanetScale Database](https://getrush.ai/run/find-trials-that-never-activated/planetscale/)

## More jobs like this: Produce a report or file, no repo

- [Get a Weekly Product Metrics Report From PostHog](https://getrush.ai/run/weekly-product-metrics/posthog/)
- [Write a Weekly Project Status From Asana](https://getrush.ai/run/weekly-project-status/asana/)
- [What Moved in Each Client's Rankings This Week? An SEO Agency's Monday Rank Tracker Summary From Ahrefs](https://getrush.ai/run/weekly-rank-changes-for-each-client/ahrefs/)

## Keep reading

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