What the agent does
This is for a company that sells an address-lookup and geocoding API by volume: each customer's plan includes a number of lookups a month, and calls past it are billed as overage. Every request the API serves is already logged to Axiom with the customer's account id, the endpoint, the status code and the plan. At month end someone in finance needs one number per customer and per endpoint to draft the invoices, and until now an engineer has written that query by hand each month, slightly differently each time. The agent writes the same count every month, from the same rules, and shows its work.
The finance lead, or an engineer for them, connects Axiom once with POST /me/connections {"type": "mcp", "name": "axiom", "url": "https://mcp.axiom.co/mcp", "auth": {"mode": "oauth"}} and signs in on Axiom's page. Axiom's docs say the server acts as that user through OAuth, so the run sees the datasets that user's role can query, and that hourly and daily query cost limits can be set on the role to keep an agent's queries within a budget. A team whose data sits in Axiom's EU region connects https://mcp.eu.axiom.co/mcp instead.
On a run the agent calls listDatasets and getDatasetFields on the request dataset the prompt names, so it uses the field names the API really logs and stops with a note if customer_id or status is missing. It then runs queryDataset with one APL query over the month: requests grouped by customer, endpoint and status class, counting only the statuses the billing rules say are billable. A second query counts the requests with no customer id at all, which usually means an unauthenticated call or a logging change, and a third compares each customer's total with the month before so a sudden jump stands out.
It writes the counts to a CSV the billing system can import and a short note for finance. The agent never touches Axiom's dashboards or monitors: the prompt forbids createDashboard, replaceDashboard, updateDashboardChart, deleteDashboard, the monitor and notifier tools that write, createDataset and deleteDatasetFields. It also prices nothing, because the plan allowances and overage rates live in the billing system, where a person applies them.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Count billable API calls per customer for October 2026 (2026-10-01T00:00:00Z to 2026-11-01T00:00:00Z) from our Axiom dataset api-requests. Use the axiom connection. Call listDatasets and getDatasetFields on api-requests first and stop with a note if customer_id, endpoint, status or plan is missing. With queryDataset run: (1) requests in the month where status < 500 and status != 429, summarized by customer_id, plan and endpoint; (2) requests in the month with no customer_id, by endpoint and status; (3) the same count as (1) for September 2026, by customer_id. Write usage-2026-10.csv with customer_id, plan, endpoint, billable_calls, and usage-2026-10.md with each customer's total, the change from September in percent, every customer whose total changed by more than 50%, and the unattributed requests. Do not price anything. Do not call any tool that creates, updates or deletes a dataset, field, dashboard, monitor or notifier.",
"connections": [
"axiom"
]
}- 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.
- 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.
- 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 run counts each customer's billable API calls for the month by plan and endpoint, and notes whose usage moved by more than half. The session returns usage-2026-10.csv and usage-2026-10.md as artifacts. The CSV has one row per customer, plan and endpoint with the billable count, ready to import into the billing system, which applies each plan's allowance and overage rate. The note lists every customer whose usage moved by more than half against September and the requests the logs could not attribute to anyone.
What finance checks before invoices go out: that the billable rule in the prompt (no 5xx, no 429) is still what the contract says, that a customer with a big jump was not caught in a retry loop the company caused, and that the unattributed requests are not a logging bug hiding a customer's real usage. The transcript holds each APL query exactly as it ran, so an engineer can paste one into Axiom's query editor and get the same numbers.
Run it on every first day of the month
The finance lead saves the agent with POST /o/{org}/agents, naming the axiom connection and the billable rules, and adds a console automation with a schedule trigger (0 6 1 * * in UTC) that runs it. A schedule fills nothing into the prompt, so the saved instructions say "the previous calendar month in UTC" instead of fixed dates.
When a customer disputes an invoice, someone sends the same prompt from the company's backend with POST /o/{org}/sessions, that month's dates and that customer's id, and gets the same count with the queries behind it.
The use case this job follows, with its automation and trigger: Produce a report or file, no repo.
Why run it on Rush?
The count needs an Axiom sign-in that can read production request logs, and on Rush it stays in the connection rather than in a token on an engineer's laptop or in the billing job's environment. Axiom's own role settings decide which datasets the run can read and how much it may spend on queries, so finance gets the count without anyone handing it broader access.
Each month's run has its own computer and a record of every query and what its model calls cost, which is the record an invoice dispute needs. When a customer asks how their October number was reached, the answer is the session: the field check, the three queries and the rows they returned.
Frequently asked questions
Does the agent work out what each customer owes?
No. It counts billable calls by the rule in the prompt and leaves pricing to the billing system, where the plan allowances and overage rates already live. Keeping the two apart means a pricing change never needs a new prompt.
Can the queries run up a large Axiom bill?
Axiom's docs describe hourly and daily query cost limits set on the role of the user the MCP server acts as. Putting the finance sign-in on a role with such a limit caps what any run can spend, and the transcript records each query the run sent.
What counts as a billable call?
Whatever the contract says. This prompt counts every request under 500 except 429 rate-limit answers, which is a common rule but not the only one. Change the filter in the saved instructions when the rule changes, and every later month uses it.
What if the logs change shape mid-month?
The agent reads the dataset's fields before it queries and stops with a note when a field it needs is missing. A field that was renamed partway through the month shows up as a drop in one customer's usage and a rise in unattributed requests, which the note lists.
More Axiom jobs
- Which Checkout Errors Did Shoppers Hit This Week? An Online Store's Monday Report From Axiom Logs
- Which Customers Keep Hitting Our Rate Limits? An SMS API Company's Weekly List From Axiom
- How Do I Find Which Customers' Webhook Endpoints Keep Failing? A Weekly Report From Axiom for a SaaS Customer-Success Team