What the agent does
This is for a company that sells bookkeeping software to small businesses: a painting contractor, a hair salon, a café. The owner snaps every receipt with their phone into a Google Drive folder called Receipts, and at month end the owner or their bookkeeper types each one into the books. The software company saves one agent as a template with "connections": ["google-drive"] and instructions to read receipts and never change or move an original, then makes one agent from it for each business with POST /o/{org}/agents {"template": "<template id>", "name": "receipts-<business id>"}, storing the agent id on that business.
The owner connects Drive once from the software's settings page. The backend calls POST /o/{org}/agents/{agent}/connections {"type": "app", "name": "google-drive"} and opens the authorize_url in a popup, where the owner signs in on Google's page. Rush's Google Drive app asks for drive.readonly, drive.file and spreadsheets: reading the owner's files, and creating and editing spreadsheets. The software company registers no Google app and stores no token; the owner can remove the access from their Google account at any time.
On a run the agent calls the Drive API's files.list with a q of '<folder id>' in parents and trashed = false and (mimeType contains 'image/' or mimeType = 'application/pdf') and createdTime > '2026-10-01T00:00:00', passing each nextPageToken back as pageToken until the list ends. It downloads each file with files.get and alt=media and reads the receipt itself: the vendor, the date, the total, the tax shown, the payment card's last four digits when printed, and the currency. It sorts each into one of the business's own expense categories, which the backend passes in the prompt, and marks it uncertain when the receipt could fit two.
It flags what a bookkeeper would catch: a photo too blurred to read a total, the same vendor, date and total twice (two photos of one receipt), line items that do not add up to the total, a receipt with no date, and a currency other than the business's. Then it creates a spreadsheet with the Sheets API, Expenses 2026-10 (draft), and adds one row per receipt with spreadsheets.values.append, valueInputOption=USER_ENTERED and insertDataOption=INSERT_ROWS, each row linking to its photo. It returns the same rows as JSON for the software to import. It never edits, renames or moves a receipt, and it posts nothing to the books.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "<agent id>",
"input": "Read receipts for October 2026 from the Google Drive folder with id 1AbCdEfGhIjKlMnOpQrStUvWxYz. List files with files.list, q: '1AbCdEfGhIjKlMnOpQrStUvWxYz' in parents and trashed = false and (mimeType contains 'image/' or mimeType = 'application/pdf') and createdTime > '2026-10-01T00:00:00' and createdTime < '2026-11-01T00:00:00', following nextPageToken. Download each with alt=media and read: vendor, date, total, tax, card last 4 if printed, currency. Business currency is USD. Categories: Materials, Fuel, Tools and equipment, Meals, Software, Vehicle repairs, Other. Give each receipt one category and set uncertain true when two could fit. Flag: unreadable, likely_duplicate (same vendor, date and total), lines_do_not_add_up, no_date, foreign_currency. Create a spreadsheet named 'Expenses 2026-10 (draft)' and append one row per receipt with spreadsheets.values.append (USER_ENTERED, INSERT_ROWS): date, vendor, category, total, tax, card, flags, link to the file. Return only JSON: {spreadsheet_url, receipts: [{file_id, date, vendor, category, uncertain, total, tax, currency, card_last4, flags}]}. Do not edit, rename, move or delete any existing file."
}- 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, with your repository as the resources URL. 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 answer is JSON in the session's result and in the run.completed webhook, and the draft spreadsheet sits in the owner's own Drive. The software shows the receipts as a list to review, with the flagged ones first, and the bookkeeper or the owner accepts, fixes or rejects each before anything is recorded in the books.
What the reviewer checks: every row marked uncertain, since the category is a guess between two of the business's own; likely duplicates, which are sometimes two genuine purchases at the same store on the same day; and totals on faded thermal receipts. The category is the business's bookkeeping label, not a judgment about what is deductible, which stays with the owner's accountant. The session's accounts names the Google account the run read, and the transcript shows each Drive and Sheets call.
Run it on every month end, per business
The company's scheduler sends one POST /o/{org}/sessions per connected business on the second day of each month, with that business's agent id as agent, the folder id, the month and its categories in input, and a request_id that is a UUID v5 of the business id and the month, so a retried job starts no second run. Runs past the key's concurrent limit are created queued and start as earlier ones finish.
Some owners prefer to clear receipts weekly. The same request with a seven-day window, started from a button in the software, gives them a shorter sheet to review while the purchases are still fresh.
The use case this job follows, with its automation and trigger: Run an agent per customer task.
Why run it on Rush?
A receipt-scanning service reads a photo but does not know the business's own categories, its currency or which two photos are the same receipt. The agent reads the whole month at once with those rules in front of it, and each business's Google account is connected to that business's agent only, so a run for the salon never sees the café's Drive.
The company keeps one template. Adding a category rule or a new flag is one PATCH to the template that reaches every business's next run. GET /o/{org}/sessions?agent=<agent id> lists one business's runs and their total_cost_usd, what each run's model calls cost, so the company can add up the feature's model cost per customer; compute comes from the same credits but is not on the session.
Frequently asked questions
Does the business owner need a Rush account?
No. They sign in to Google once from the bookkeeping software's settings. The agent, its runs and the bill belong to the person who created the software company's API key.
Can the agent see the rest of the owner's Drive?
The drive.readonly permission lets it read any file the owner can, so the template's instructions and each prompt limit it to the one folder id the owner picked. The transcript shows every file it opened, which the company can audit.
Will it record the expenses in the books?
No. It writes a draft sheet and returns JSON. The software imports only the rows a person accepts, because a wrong amount in the books is harder to find later than on a review screen.
Some owners email receipts instead. What then?
Rush lists Gmail as its own app. The company can save a second template that names Gmail with "access": "read", so each owner's sign-in asks only to read mail, and point it at the label the owner forwards receipts to.