What the agent does
This is for a software company that sells rent collection and bookkeeping to small landlords, people who own somewhere between two and thirty units. Many of them pay the water, gas, electricity and trash bills for some units and pass the cost on to tenants, or need the bills for their own books. The bills arrive in the landlord's Gmail as PDFs from each utility, addressed by service address rather than by the landlord's unit names, and get filed by nobody. On the first of each month the software's new feature reads the landlord's own inbox and lays last month's bills out by property.
The company saves the agent once as a template with POST /o/{org}/agents and "connections": [{"name": "gmail", "access": "read"}], after connecting a Gmail account of its own. When a landlord turns the feature on, the backend makes their agent with {"template": "<template id>", "name": "bills-<landlord id>"}, calls POST /o/{org}/agents/{agent}/connections {"type": "app", "name": "gmail"}, and opens the authorize_url in a popup, where the landlord signs in to Google. At the read level each landlord's consent asks Google for gmail.readonly only, so the agent can read bills but cannot send, delete or label mail.
On a run the agent calls Gmail's users.messages.list with a q that limits the search to last month and to the utility senders the app knows for this landlord (from:(billing@cityutilities.example OR noreply@gasco.example) has:attachment after:2026/10/01 before:2026/11/01), following nextPageToken. It reads each message with users.messages.get and each PDF with users.messages.attachments.get, and takes from the bill the utility, the account number, the service address, the service period, the amount due and the due date. Bills that arrive without an attachment are read from the message body.
It matches each bill to a property by the service address and account number in the property list the app sends, and to a unit when the account belongs to one unit. A bill whose address matches no property goes to an Unmatched list. A property that had a bill last month but none this month is listed as Missing, which is often the first sign that a utility switched the landlord to paper or that an account was closed. The agent works out no tenant's share: the landlord's lease terms decide that, and the app applies them after the landlord approves the list.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "<agent id>",
"input": "Collect my utility bills for October 2026. Search Gmail with users.messages.list, q: from:(billing@cityutilities.example OR noreply@gasco.example OR ebill@powerco.example OR invoices@haulers.example) has:attachment after:2026/10/01 before:2026/11/01, following nextPageToken. Read each with users.messages.get and each PDF with users.messages.attachments.get; read the body when there is no PDF. Properties: P1 14 Elm St (units A, B), P2 220 Cedar Ave (single), P3 9 Mill Rd (units 1, 2, 3). Known accounts: city water 4471-02 P1, gas 88120 P2, power 30-551-7 P3 unit 2. Match by account number, then by service address. Return only JSON {bills: [{property, unit or null, utility, account, service_from, service_to, amount_due, due_date, message_id}], unmatched: [{from, subject, account, service_address, amount_due}], missing: [{property, utility, account}], unreadable: [{from, subject}]}. Last month's accounts with bills: 4471-02, 88120, 30-551-7. Read only: do not send, label, archive or delete any mail."
}- 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 session's answer is the JSON, which the app's webhook handler turns into a Bills screen for the month: each property with its bills, amounts, service periods and due dates, and a link back to the email each one came from. Unmatched bills, missing accounts and unreadable messages sit at the top, since each one is a bill the landlord might otherwise pay late or forget to pass on.
What the landlord checks before approving: that a bill matched to a property by address alone really belongs to it (two units on one street are easy to confuse), that the amounts read from scanned PDFs are right, and that a Missing account has not simply moved to paper. Only after approval does the app record the bills in the landlord's books or add tenant charges under the lease terms the landlord set, and nothing is sent to a tenant without the landlord's say.
Run it on every first of the month, per landlord
The app's scheduler sends one POST /o/{org}/sessions per landlord with the feature on, on the morning of the first in each landlord's time zone, with their agent id as agent, their properties, accounts and utility senders in input, and a request_id that is a UUID v5 of the landlord id and the month, so a retried job starts no second run.
Some utilities bill mid-month, so a landlord can press Check again on the fifteenth, and the app sends the same request with the dates up to that day; the Bills screen merges the two answers by message id.
The use case this job follows, with its automation and trigger: Run an agent per customer task.
Why run it on Rush?
A landlord's inbox holds tenants' messages, bank notices and everything else, so the sign-in matters more than the job. On Rush each landlord's Google sign-in stays in Rush's connection under their own agent at the read level; the company registers no Google app and stores no Google token, and a session's accounts names the Gmail address each run read, which lets the company show a landlord every run that opened their mail.
Each landlord's month is its own session on its own computer, with a record of every Gmail call and what its model calls cost, so the company can price the feature from what it costs per landlord, read with GET /o/{org}/sessions?agent=<agent id>. The first of the month is when every landlord's run starts at once, and runs past the key's max_concurrent wait as queued and start as slots free.
Frequently asked questions
Does the agent read all of a landlord's email?
It searches for messages from the utility senders the app lists, in last month's dates, and reads only those. The read level would allow more, so the prompt's search is what keeps the run to bills, and the transcript shows each message it opened.
Can it work out what each tenant owes?
No. How a utility bill is shared depends on each lease and on local rules, which the landlord knows and the agent does not. The agent lists the bills by property and unit, and the app applies the shares the landlord configured, after the landlord approves the list.
What about bills that only arrive on paper?
They are not in Gmail, so the agent cannot see them. The Missing list catches an account that used to email and stopped. Landlords with paper bills can scan them to their own inbox, and the next run picks them up.
What if a utility changes its sending address?
The search names senders, so a new address is missed until the app adds it. A landlord who sees a bill in the Missing list and finds it in their inbox under another address can add that sender in the app, and the next run includes it.