Review customers nearing their API caps

Rank customers by monthly API quota consumption, show threshold and projection evidence, and prepare human-reviewed account outreach without sending it.

Updated · published

markdown for agents →

difficulty intermediate · time to value 10 minutes · execution human review required

Start from this

Review customers at or above 80% of their monthly API quota. Show calls used, cap source, projected month-end usage, threshold band, and recent usage change. Draft account notes but do not contact customers or change limits.

Why this matters

A customer approaching a monthly cap may face an outage, a legitimate growth event, or a runaway integration. The same number can lead to very different decisions. Review usage, remaining quota, month-end projection, plan source, and recent deploy context before recommending outreach or a limit change.

Run the review

Prove api_request.customer_id and api_request.plan are answer-ready through the saved signal map, verified current onboarding state, and live event-property metadata. Then fetch the filtered schema for POST /v1/projects/:project_id/analytics/query and, in the interactive owner session, calculate one bounded row per customer:

customer_id
plan
calls_this_month
authoritative_cap
percent_used
calls_last_24h
projected_month_end

The cap mapping must come from an authoritative billing or product source provided by the reviewer. Do not infer limits from plan names. Use minimum volume checks so a test account does not dominate the result.

Classify rows for review:

  • 80–89%: verify expected growth and remaining days;
  • 90–99%: identify the owning team and likely cap date;
  • 100% or projected above cap: distinguish growth from a runaway loop;
  • sudden step-change: compare with recent deploys and endpoint mix.

Output format

Quota review — <month and UTC as_of>

Customer | Plan | Used / cap | Projected | Change | Evidence
<id>     | <p>  | <n>/<n>    | <n>       | <n>%   | <source>

Needs account-owner review
- <customer> — <why> — <questions to answer before outreach>

Possible technical anomaly
- <customer> — <endpoint/deploy evidence> — <next investigation>

Draft account note
- <customer> — <draft only; not sent>

Customer IDs, plan data, and usage are owner-visible data. Keep the result in the human-controlled session. A human chooses whether to contact an account, change a cap, or share a summary.

Instrumentation

Emit usage from the trusted application server with a stable customer ID:

await fetch("https://api.agentry.sh/v1/analytics/", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.AGENTRY_SERVER_API_KEY}`,
    "Content-Type": "application/json",
    "User-Agent": "api-service/1.0",
  },
  body: JSON.stringify({
    event: "api_request",
    distinct_id: user.id,
    properties: {
      customer_id: account.id,
      plan: account.plan,
      endpoint: request.route,
    },
  }),
});

Unattended boundary

No current versioned automation template grants a runner raw customer usage, generic HogQL, messaging, or quota mutation. Do not install an owner key in a scheduler or use agent-local state for deduplication. Keep this review on demand until a narrow server-owned source and explicit policy exist.

Variations

  • “Compare this month with the same elapsed days last month.”
  • “Break sudden growth down by endpoint to find runaway loops.”
  • “Show accounts with no usage after a historically active period.”
  • “Draft a CS handoff for the top five accounts; do not send it.”

Adapt this workflow in your own agent.

Ask your agent to map the starter prompt to your saved signal map, live events, and the current HTTP API before answering.

Agentry gives coding agents production context from errors, product analytics, and deploys through one HTTP API. Fetch and read https://agentry.sh/install.md completely, then install Agentry's full first-time telemetry baseline in this repository. I authorize device-code login, saving the owner key only to ~/.agentry/credentials.json, creating one Agentry project for this repository, and read-only inspection of shipped source plus hidden CI/provider configuration. Deeply analyze the product's business logic and complete value flow before choosing telemetry. Save the complete source-backed plan and show me its exact contents and hash. Until I explicitly approve that plan or request a replacement, do not edit app/CI source, place runtime/CI credentials, commit, exercise product traffic, start proof, push, or deploy. After approval, I authorize only the reviewed targets: place the required scoped browser/server/CI credentials through the established environment or secret mechanism, preserve existing telemetry, implement and test the baseline, commit it, push that reviewed commit when the shipped CI/provider path requires it, exercise safe proof paths with test/non-customer data, and perform one deployment through the reviewed shipped CI/provider path. Ask first if proof would charge money, contact a third party, change real customer data, or require new external access. After the plan is saved, immediately before every onboarding state-changing POST, GET current onboarding state, perform only its single returned next_action, then read state again; do not batch or infer later stages. Continue until status is verified, installation_complete is true, and next_action is null. Keep all secrets, source snapshots, proof markers, and scratch files outside the repository.

+ Full access
5.5 Extra High
  1. 1. Open your repo in Codex, Claude Code, Cursor etc.
  2. 2. Paste the install prompt.
  3. 3. Your agent reads the install doc and shows you an implementation plan for approval.