# How Can Bill-Pay Software Pick Up Vendor Invoices From Each Customer's Outlook? One Agent per Business, With Read-Only Mail Access

Bill-pay software makes one read-only agent per business, signed into its Outlook, that reads each morning's vendor invoice emails and drafts the bills to approve.

[Run this on Rush](https://cloud.getrush.ai/run/capture-vendor-invoices-from-the-inbox/outlook/). Opens the console with this prompt ready to send. Connect Outlook there first.

## What the agent does

This is for a company that sells bill-pay software to small businesses: restaurants, building contractors, dental offices, a family-run hardware store. Its customers' vendors still email invoices as PDF attachments to an address like accounts@ or to the owner's own mailbox, and someone has to forward each one into the software or type it in. Invoices that sit unread are paid late, and duplicates paid twice. The software saves one agent as a template that names Outlook with read access only, and makes one agent from it per customer, signed into that customer's own mailbox, so each morning's invoices arrive in the software as draft bills for a person to approve.

The company connects its own Outlook first and saves the template with `POST /o/{org}/agents`, naming `{"name": "outlook", "access": "read"}` in `connections`. Rush's quickstart says each customer is then asked for that level alone, Outlook's `Mail.Read` and `Contacts.Read`, and not for permission to send. When a customer turns the inbox feature on, the backend calls `POST /o/{org}/agents {"template": "<template id>", "name": "ap-inbox-<customer id>"}`, then `POST /o/{org}/agents/{agent}/connections {"type": "app", "name": "outlook"}`, and opens the `authorize_url` in a popup. The customer signs in on Microsoft's own page. The software stores the agent id and registers no Microsoft app.

On a run the agent calls Microsoft Graph's `GET /me/messages` with a `$filter` on `receivedDateTime` for the window in the request and `hasAttachments eq true`, a `$select` of the subject, sender, received time and attachment flag, and `$top` up to 1,000, following `@odata.nextLink` until it ends. Graph's reference says that when `$filter` and `$orderby` are combined, the properties in `$orderby` must come first in `$filter`, or the call fails with `InefficientFilter`, so the agent filters on `receivedDateTime` first. For each message it calls `GET /me/messages/{id}/attachments` and reads each `fileAttachment`'s `name`, `contentType`, `size` and `contentBytes`.

It opens each PDF attachment and keeps the ones that are invoices, not statements, quotes, delivery notes or marketing. From each invoice it reads the vendor's name, the invoice number, the invoice date, the due date, the total, the currency and any purchase order number, and it notes the page it read them from. It skips messages from senders on the customer's ignore list in the request. It writes nothing back to the mailbox: no reply, no forward, no moved message, no read flag.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "<agent id>",
  "input": "Find vendor invoices received in this Outlook mailbox from 2026-11-19T06:00:00-05:00 to 2026-11-20T06:00:00-05:00. Call GET /me/messages with $filter receivedDateTime ge 2026-11-19T11:00:00Z and receivedDateTime lt 2026-11-20T11:00:00Z and hasAttachments eq true, $select id,subject,from,receivedDateTime,hasAttachments, $top 200, following @odata.nextLink. Skip messages from these senders: newsletters@supplier.example, no-reply@bank.example. For each message call GET /me/messages/{id}/attachments and read each PDF fileAttachment. Keep only invoices (not statements, quotes, credit notes or delivery notes; list those separately). From each invoice read vendor name, vendor email (the sender), invoice number, invoice date, due date, total, currency, PO number, and the attachment name. Return only JSON: {invoices: [{message_id, received_at, vendor, vendor_email, invoice_number, invoice_date, due_date, total, currency, po_number, attachment, unsure_fields: [string]}], other_documents: [{message_id, attachment, kind}]}. Use null for a value the document does not show; never guess one. Read only: never send, reply, forward, move, delete, or mark any message."
}
```

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

The agent turns each vendor invoice in the inbox into an entry with the vendor, invoice number, dates, total and PO number, ready for a draft bill. The answer is JSON in the session's `result` and in the `run.completed` webhook the software's API key sends, and each entry also carries the message it came from, the currency, and a list of any field the agent was unsure of. Statements, quotes and credit notes come back in a separate list, so nothing is silently dropped. The software creates a draft bill for each invoice, links it to the original email, and checks the vendor and invoice number against bills it already has before showing it.

What the customer checks before approving a bill: the total and due date against the PDF, which the software shows side by side; anything in `unsure_fields`, such as a handwritten total or a scanned page; and a new vendor's bank details, which the agent does not read: a change of bank details that arrives by email is something a person confirms with the vendor by phone. Payment happens only when a person approves it in the software.

## Run it on every weekday morning, per customer

The software's scheduler sends one `POST /o/{org}/sessions` per customer at six in the morning in that customer's time zone, with the customer's agent id as `agent`, the last 24 hours in `input`, and a `request_id` that is a UUID v5 of the customer id and the date, so a retried job does not draft the same bills twice. On Monday the window starts on Friday morning.

A software company with two thousand customers starts two thousand runs across the morning. Runs past the API key's concurrent limit wait `queued` and start as earlier ones finish, so the scheduler sends them all and reads each result from its webhook.

## Why run it on Rush?

Each customer signs in on Microsoft's own page and grants mail reading, not sending, and that sign-in belongs to the customer's agent alone: no run can read another customer's mailbox. The session's `accounts` names the mailbox each run read, and `GET /o/{org}/sessions?account=<email>` lists every run that touched one, which is what a customer's IT person asks for. The quickstart notes that Microsoft issues a token with every Outlook permission a person has ever granted Rush, so the template's prompt also forbids sending in words.

Each run has its own computer, where the PDFs are opened and read, and a record of every Graph call. When a bill comes out wrong, the software opens the session and sees which email and attachment it was read from. `GET /o/{org}/sessions?agent=<agent id>` lists one customer's runs with their `total_cost_usd`, so the company can see what the inbox feature costs per customer.

## Frequently asked questions

### What about invoices sent as a link rather than an attachment?

Some billing systems email a link to a portal instead of a PDF. With read access the agent can see the message but cannot sign in to the vendor's portal, so the prompt can ask it to list those messages with the vendor and the link, and a person downloads the invoice.

### Can the agent read a shared accounts@ mailbox?

Graph's reference says an app with delegated permissions can read another user's folder when it has been shared with the person who signed in. The simpler setup is for the customer to sign in as the accounts@ mailbox itself, so the agent's connection is that mailbox.

### Does the agent catch duplicate invoices?

Within one run it reports the same invoice number from the same vendor once, and notes the second email. Duplicates across days are the software's job, since it holds every bill already captured and can match on vendor, invoice number and total.

### What if a customer disconnects Outlook?

The agent's `missing_connections` lists Outlook again and new runs are refused `422 CONNECTION_NOT_READY` before a computer starts. The software reads that from `GET /o/{org}/agents/{agent}` and asks the customer to reconnect, while invoices keep arriving in the mailbox as before.

## More Outlook jobs

- [How Does Estimating Software Collect Each Estimator's Subcontractor Bids From Outlook Before Bid Day?](https://getrush.ai/run/compare-subcontractor-bids-before-bid-day/outlook/)
- [Which Candidates Emailed Us and Never Heard Back? A Recruiting App's Daily Check of Each Recruiter's Outlook](https://getrush.ai/run/find-candidates-waiting-on-a-reply/outlook/)
- [Which Customer Quote Requests Have We Not Answered? A Wholesale Distributor's Morning Check of Each Sales Rep's Outlook](https://getrush.ai/run/find-quote-requests-with-no-reply/outlook/)

## More jobs like this: Run an agent per customer task

- [Was It Slow on Our Side? A SaaS Support Team Checks Each Slowness Ticket Against Honeycomb](https://getrush.ai/run/check-a-customers-slowness-complaint/honeycomb/)
- [Check Each Brokerage's Deal Folders in Google Drive for Missing Documents](https://getrush.ai/run/check-deal-files-for-missing-documents/google-drive/)
- [Did Any Client Site Throw Errors Last Week? How Care-Plan Software Checks Each Web Designer's Netlify Sites](https://getrush.ai/run/check-each-client-sites-errors-weekly/netlify/)

## Keep reading

- [Connect Outlook to Rush once, then name it on any run](https://getrush.ai/integrations/outlook/)
- [Start your first run from the developer API quickstart](https://getrush.ai/docs/quickstart/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
