All jobs

Email List Cleaning in Klaviyo for Each Client Brand

An email agency gives each client brand an agent that checks its Klaviyo list every month and proposes which unengaged profiles to suppress, for a person to approve.

Run this on RushOpens the console with this prompt ready to send. Connect Klaviyo there first.

What the agent does

This is for an email and SMS agency that runs Klaviyo for online stores and gives every client a portal with their monthly numbers. List cleaning is the chore that slips: profiles that have not opened or clicked in months keep getting campaigns, bounce and spam-complaint rates creep up, and someone has to notice before inbox placement suffers. The agency adds a List health card to the portal, written each month by an agent that reads the brand's own Klaviyo account and ends with a suppression proposal that a person on the account team approves or changes.

The agency saves the agent once as a template with POST /o/{org}/agents, naming klaviyo in connections (it connects a Klaviyo account of its own first, because a template names connections its creator has) and instructions that keep it to read tools. When a brand signs, the portal calls POST /o/{org}/agents {"template": "<template id>", "name": "list-health-<brand id>"}, then POST /o/{org}/agents/{agent}/connections {"type": "mcp", "name": "klaviyo"}, and opens the authorize_url for the brand owner. Klaviyo's docs say its remote server at https://mcp.klaviyo.com/mcp signs in with OAuth and dynamic client registration, so the agency registers no Klaviyo app.

A run starts with get_account_details so the page names the account it read. It finds the agency's standard engagement segments by the names given in the prompt with get_segments, and reads twelve months of their membership with query_segment_series, monthly, for total_members, members_added and members_removed. It lists the last 30 days of email campaigns with get_campaigns and, for each, reads who it was sent to and who was excluded with get_audience_for_campaign_message, so it can say which sends went to the unengaged segment. It looks up the store's order metric with get_metrics, because Klaviyo's campaign values report requires a conversion_metric_id, then calls get_campaign_report once for recipients, delivered, open_rate, click_rate, bounce_rate, spam_complaint_rate and unsubscribe_rate across those campaigns. Last, get_bulk_suppress_profiles_jobs tells it when the list was last cleaned.

The page it writes has the trend of engaged against unengaged profiles, each campaign that reached the unengaged segment with its bounce and complaint rates beside the others, the date of the last bulk suppression, and a proposal: the segment to suppress, its current size, and the rule it uses. It works in counts and never copies email addresses into the page. If a segment named in the prompt does not exist, it says so and writes the definition the agency should create, rather than creating it. It never calls bulk_suppress_profiles, unsubscribe_profile_from_marketing, create_or_update_segment or any other write tool.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "<agent id>",
  "input": "List health check for November 2026. Read only. 1) get_account_details: note the account name. 2) get_segments: find the segments named 'Engaged 90d' and 'Unengaged 180d'. If one is missing, say so and write the definition we should create; do not create it. 3) query_segment_series for both, interval monthly, last 12 months: total_members, members_added, members_removed. 4) get_campaigns: email campaigns sent 2026-10-05 to 2026-11-04; for each, get_audience_for_campaign_message and note whether Unengaged 180d was included, excluded or neither. 5) get_metrics: find Placed Order and use its id as conversion_metric_id. 6) One get_campaign_report call for those campaigns: recipients, delivered, open_rate, click_rate, bounce_rate, spam_complaint_rate, unsubscribe_rate. 7) get_bulk_suppress_profiles_jobs: date and size of the latest job. Write list-health.md (segment trend, campaigns that reached Unengaged 180d with their rates beside the rest, last suppression, then a proposal: which segment to suppress, its size, and why) and list-health.json. Counts only, no email addresses. Call no tool that creates, updates, suppresses, unsubscribes or deletes."
}
  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

list-health.md reports the brand's list health and proposes a suppression rule for the account team to review. The session returns it with list-health.json as artifacts. The portal reads the JSON into the brand's List health card and puts the proposal into the account team's queue, where a person reads it, adjusts the rule if the brand has a seasonal reason to keep mailing some lapsed buyers, and runs the suppression in Klaviyo or replies with a reason not to.

What that person checks: that the campaigns listed as reaching the unengaged segment really were meant to exclude it, since a win-back campaign targets it on purpose, and that the segment's definition matches the agency's current rule. A rate on the page comes from Klaviyo's report for the window named in the prompt; the page compares campaigns with each other and does not promise what suppression will change.

When the brand's account has no unengaged segment yet, the proposal is the segment definition itself, and the first suppression waits until a person has created the segment and seen its size.

Run it on every month, per client brand

The portal's scheduler sends one POST /o/{org}/sessions per brand on the first Monday of each month, with the brand's agent id as agent, that month's window and the brand's segment names in input, and a request_id that is a UUID v5 of the brand id and the month, so a retried job starts no second run. Runs past the key's max_concurrent wait as queued and start as slots free.

An account manager who sees a bounce spike midmonth can press Check list health in the portal, which sends the same request for the last 30 days to that brand's agent.

The use case this job follows, with its automation and trigger: Run an agent per customer task.

Why run it on Rush?

Each brand's Klaviyo sign-in is that brand's own, stored in Rush's connection under the brand's agent. The agency holds no Klaviyo keys for its clients, and a run of one brand's agent cannot read another brand's profiles. The session's accounts lists the Klaviyo connection each run used, so the agency can show a client every time their account was read.

Klaviyo documents its segment series and campaign values reports at 2 requests a minute steady and 225 a day, so the agent asks for every statistic in one call rather than one call per number. Each run has its own computer and a transcript of every Klaviyo tool it called with its arguments, and the agency adds up total_cost_usd per brand with GET /o/{org}/sessions?agent=<agent id>.

Frequently asked questions

Does the agent suppress anyone?

No. It proposes a segment to suppress and its size, and a person on the account team runs the suppression in Klaviyo after reading the proposal. The prompt and the template's instructions forbid every write tool, and the transcript lists each call the run made.

Can the Klaviyo connection be made read-only?

Klaviyo's docs describe a read-only=true parameter on the server URL that turns off its write tools. The connection here uses the plain catalog address, so the read-only rule lives in the template's instructions and the prompt, and the transcript is how the agency confirms it held.

Why does the report need the store's order metric?

Klaviyo's campaign values report requires a conversion_metric_id even when you only ask for delivery and engagement rates. The agent looks up the order metric with get_metrics and passes its id, and says so on the page if the store has none.

Will the page show subscribers' email addresses?

No. The prompt asks for counts only, so the page has segment sizes and campaign rates. A person who wants to look at individual profiles opens the segment in Klaviyo itself.

More Klaviyo jobs

More jobs like this: Run an agent per customer task

Keep reading