Please find invoice 2291 attached. Payment is due December 15.
One address for every bill.
Vendors send to your agent's address, it reads each PDF as text and books it, and senders you never approved can't get in.
// Read the PDF, then answerGET /v1/messages/em_4Tq1Lz6M/attachments/att_9Lw3/text200 { "text": "# Invoice 2291 … Total due $1,840.00" }POST /v1/messages/em_4Tq1Lz6M/reply{ "text": "Thanks, Mara. Scheduled for December 14." }202 { "status": "sent" }
norbeck-ap
Norbeck accounts payable
Thanks, Mara. Invoice 2291 is approved and scheduled for payment on December 14.
Norbeck Goods AP · norbeck-ap
{ "type": "email.received", "data": { "inbox": { "address": "norbeck-ap@blueping.dev " }, "message": { "id": "em_4Tq1Lz6M", "from": { "name": "Mara Quinn" }, "subject": "Invoice 2291 for November", "attachments": [ { "id": "att_9Lw3", "filename": "invoice-2291.pdf" } ] } }}
Mara's invoice reaches norbeck-ap@blueping.dev, one call reads the PDF as text, and the agent books it and tells her when it will be paid.
How can an AI agent collect invoices and receipts from email?
Give vendors one address your agent owns, read each invoice's attachment as text with GET /v1/messages/{id}/attachments/{attachment_id}/text, and book the amount in your accounting system. With receive allow rules for your vendors' domains, only senders proven by DMARC or SPF get in, which shuts the door on lookalike and forged invoices before the agent reads a word.
Where invoices get lost today
Norbeck, a design studio of 30 people, pays about 120 vendor invoices and software receipts a month. They used to arrive in four people's inboxes, as PDFs, CSV exports and the odd photo. At month end someone chased the missing ones, typed totals into the accounting tool, and checked that the bank details on a new invoice matched the old ones.
That last check is where money goes missing. Someone who learns a vendor's name sends an invoice from a lookalike domain with new bank details. In a crowded inbox it reads like any other invoice, and an agent reading that inbox through OAuth would read it the same way.
Now vendors send to norbeck-ap@blueping.dev. The agent reads every attachment as text, with no PDF parser of its own, and allow rules keep everyone but proven vendors out of the inbox.
From a vendor's email to a booked invoice
The agent books and asks; Blueping receives, turns away unknown senders, and reads the files.
Create the accounts payable inbox
One inbox with a
display_nameyour vendors recognize. Send its address to each vendor as your new billing contact.Call: POST
/v1/inboxeswithclient_idanddisplay_nameAnswer:
201withidandaddressChecked: The plan's inboxes and storage; receiving never counts as a send
Let only your vendors in
One receive allow rule per vendor domain, written
@harborview-hosting.example. With allow rules in place, mail from any other sender is turned away before it is stored, and an allowed domain counts only when the sender is proven.Call: POST
/v1/inboxes/{id}/ruleswithdirection: receive,action: allowandvalueAnswer:
201with the rule, or200with the one already thereChecked: DMARC must pass for the From address, or SPF for the envelope; 500 rules at most per inbox
Find what is new
The agent lists recent mail and skips what it already labeled
booked. Each message lists itsattachmentswith name, type and size.Call: GET
/v1/inboxes/{id}/messages?limit=50Answer:
datawithattachments,labelsand the sender'sauthChecked: Messages over 25 MB never arrive; everything else arrives whole
Read each attachment as text
One call per file returns what it says: CSV, PDF, Word and Excel files as Markdown, text and JSON as they are. The model reads the vendor, the invoice number, the total and the due date from that text.
Call: GET
/v1/messages/{id}/attachments/{attachment_id}/textAnswer:
text,truncatedand asafetyresult for the fileChecked: Cut at 100,000 characters; a file whose text speaks to a model comes back
suspiciousBook it, or ask for what is missing
The agent sends the invoice to your accounting system and labels the message
booked. An email with no file gets a reply in the thread asking for the PDF.Call: PATCH
/v1/messages/{id}, or POST/v1/messages/{id}/replyAnswer: The message's
labels, or202with the replyChecked: A reply to a vendor whose mail passed DMARC never counts toward the ramp of new recipients
Step 4's answer, whole, for a PDF invoice:
{
"id": "att_5Gh2Jk8Lm1Np4Qr7",
"message_id": "em_9PzR4fYc1KwM6tDq3VxB",
"filename": "INV-2026-1104.pdf",
"content_type": "application/pdf",
"size": 48213,
"text": "# Invoice INV-2026-1104\n\nHarborview Hosting\n\n| Item | Amount |\n| --- | --- |\n| Hosting, November | 1,200.00 |\n| Support plan | 40.00 |\n| Total | 1,240.00 |",
"truncated": false,
"safety": { "verdict": "clear", "reasons": [] }
}Collect and book invoices in Python and Node.js
The program sets the allow rules, then books every new invoice once. book() stands for your accounting system's API, and the pattern for the total stands for your model, which reads a real invoice better than one regular expression.
# collect_invoices.py: read each vendor invoice's attachment as text and book it. Run it every hour.
# pip install requests
import os
import re
import requests
API = "https://blueping.dev/v1"
VENDORS = ["@harborview-hosting.example", "@quillmark.example", "@northfield-supply.example"]
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['BLUEPING_API_KEY']}"
def book(vendor, filename, total):
# Your accounting system's API takes the invoice here.
print("booked", vendor, filename, total)
inbox = session.post(f"{API}/inboxes", json={"client_id": "accounts-payable", "display_name": "Norbeck Accounts Payable"}).json()
for vendor in VENDORS: # proven senders from these domains get in; the same rule again changes nothing
session.post(f"{API}/inboxes/{inbox['id']}/rules", json={"direction": "receive", "action": "allow", "value": vendor})
page = session.get(f"{API}/inboxes/{inbox['id']}/messages", params={"limit": 50}).json()
for message in reversed(page["data"]):
if message["direction"] != "in" or {"booked", "asked"} & set(message["labels"]):
continue
vendor = message["from"]["address"].split("@")[1]
if not message["attachments"]:
session.post(
f"{API}/messages/{message['id']}/reply",
json={"text": "Thank you. Could you send the invoice as a PDF or CSV attachment? We book from the file."},
headers={"Idempotency-Key": f"ask-{message['id']}"},
)
session.patch(f"{API}/messages/{message['id']}", json={"add_labels": ["asked"]})
print("asked", vendor, "for the file")
continue
for file in message["attachments"]:
read = session.get(f"{API}/messages/{message['id']}/attachments/{file['id']}/text").json()
if "error" in read or read["safety"]["verdict"] != "clear":
print("for a person:", vendor, file["filename"])
continue
total = re.search(r"(?i)total[^0-9]{0,20}([0-9][0-9,]*\.[0-9]{2})", read["text"])
book(vendor, file["filename"], total.group(1) if total else "no total found")
session.patch(f"{API}/messages/{message['id']}", json={"add_labels": ["booked"]})// collect-invoices.mjs: read each vendor invoice's attachment as text and book it. Run it every hour.
// Node.js 18 or later, nothing to install.
const API = "https://blueping.dev/v1";
const VENDORS = ["@harborview-hosting.example", "@quillmark.example", "@northfield-supply.example"];
const headers = { Authorization: `Bearer ${process.env.BLUEPING_API_KEY}`, "Content-Type": "application/json" };
const call = async (method, path, body, extra = {}) =>
(await fetch(API + path, { method, headers: { ...headers, ...extra }, body: body && JSON.stringify(body) })).json();
// Your accounting system's API takes the invoice here.
const book = (vendor, filename, total) => console.log("booked", vendor, filename, total);
const inbox = await call("POST", "/inboxes", { client_id: "accounts-payable", display_name: "Norbeck Accounts Payable" });
for (const vendor of VENDORS) {
// proven senders from these domains get in; the same rule again changes nothing
await call("POST", `/inboxes/${inbox.id}/rules`, { direction: "receive", action: "allow", value: vendor });
}
const page = await call("GET", `/inboxes/${inbox.id}/messages?limit=50`);
for (const message of page.data.reverse()) {
if (message.direction !== "in" || message.labels.some((label) => label === "booked" || label === "asked")) continue;
const vendor = message.from.address.split("@")[1];
if (!message.attachments.length) {
await call("POST", `/messages/${message.id}/reply`, { text: "Thank you. Could you send the invoice as a PDF or CSV attachment? We book from the file." }, { "Idempotency-Key": `ask-${message.id}` });
await call("PATCH", `/messages/${message.id}`, { add_labels: ["asked"] });
console.log("asked", vendor, "for the file");
continue;
}
for (const file of message.attachments) {
const read = await call("GET", `/messages/${message.id}/attachments/${file.id}/text`);
if (read.error || read.safety.verdict !== "clear") {
console.log("for a person:", vendor, file.filename);
continue;
}
const total = read.text.match(/total[^0-9]{0,20}([0-9][0-9,]*\.[0-9]{2})/i)?.[1];
book(vendor, file.filename, total ?? "no total found");
}
await call("PATCH", `/messages/${message.id}`, { add_labels: ["booked"] });
}A file the reader can't turn into text, such as a photo of a paper receipt, answers 415 text_unavailable with the route that downloads it: the program sends it to a person, and a vision model of yours can read it instead.
Setting the rules on every run costs three quick calls and keeps the program self-contained; a rule that exists already is answered with 200 and left as it is.
Ask for the month's invoices in plain words
With the MCP server connected, a finance lead can get the month's table from Claude or Cursor without writing code, and keep the booking itself in the accounting tool.
In my Norbeck accounts payable inbox, find this month's invoices, read each attached invoice, and give me a table of vendor, invoice number, amount and due date. Label each one booked once it is in the table, and list any email that came without a file.| Tool | What it does here |
|---|---|
search_messages | Finds the month's invoices by words such as invoice or receipt. |
read_message | Reads an email whole when the amount is in the body. |
read_attachment | Returns a PDF, Word, Excel or CSV file's text. |
label_message | Marks each invoice booked. |
list_address_rules | Shows which vendors the inbox accepts. |
read_attachment returns the file's text with untrusted: true and its own safety result, and a held message's files open only when you ask for them.
Book invoices as they arrive
An hourly pass is enough for month-end. For a live view of what you owe, subscribe to email.received, check the signature as Webhooks shows, and hand each event to the handler below. It reads every file of the new message as text and books it at once.
# invoice_hook.py: the part of your webhook server that books each invoice as it lands.
# Check the Blueping-Signature header before calling handle(): /docs/webhooks#verify has the code.
import os
import re
import requests
API = "https://blueping.dev/v1"
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['BLUEPING_API_KEY']}"
def handle(event):
if event["type"] != "email.received":
return
message = event["data"]["message"]
vendor = message["from"]["address"].split("@")[1]
for file in message["attachments"]:
read = session.get(f"{API}/messages/{message['id']}/attachments/{file['id']}/text").json()
if "error" in read or read["safety"]["verdict"] != "clear":
print("for a person:", vendor, file["filename"])
continue
total = re.search(r"(?i)total[^0-9]{0,20}([0-9][0-9,]*\.[0-9]{2})", read["text"])
print("booked", vendor, file["filename"], total.group(1) if total else "no total found") # your accounting API here
session.patch(f"{API}/messages/{message['id']}", json={"add_labels": ["booked"]})The handler labels each invoice booked, the label the hourly pass checks, so the pass skips what the handler already booked.
How the inbox blocks invoice fraud
Invoice fraud works by looking like a vendor. The inbox checks what a person can't see in a crowded mailbox.
Lookalike domains never arrive
With allow rules for your vendors' domains, harborview-hostlng.example matches no rule and is turned away while the sending server is still connected. Nothing is stored, so nothing reaches the agent.
A forged vendor fails the proof
An allow rule counts only for a proven sender: the From address when DMARC passes, the envelope when SPF passes. Mail that merely claims billing@harborview-hosting.example is refused like any stranger's.
Bank details change only with a person
New payment details in an invoice are a decision for your finance team. Tell the model to stop and ask whenever an invoice's bank details differ from the last one.
Files can carry instructions too
The text of each attachment carries its own safety result. A PDF whose text, white on white or not, tells a model to ignore its instructions comes back suspicious, and the program sends it to a person.
A file that could run never runs
An attachment always downloads: a type a browser could execute comes as application/octet-stream, so opening one by mistake shows bytes.
What 120 invoices a month need
A hundred and twenty invoices a month come in as PDFs and CSVs of about 200 KB each, under 100 MB for 90 days of mail. The agent sends only the occasional request for a missing file.
Free fits this setup: 3 inboxes, 3,000 sends a month and 100 a day, and 3 GB of storage, at no cost. Free adds a one-line footer, Sent with Blueping, to each email it sends; paid plans send without it.
Receiving is never counted, and each recipient of a send counts once. Every limit is on Limits, and every price on Pricing.
The API referenceWebhooksThe MCP serverBlueping vs AgentMailAll use cases
Last checked against the API on .
Questions about invoices
What builders ask before they set it up. The docs answer the rest.
Does the agent read the PDF itself?
It asks Blueping for the file's text: PDF, Word, Excel and CSV files come back as Markdown, text files and JSON as they are, up to 100,000 characters. Your model reads that text; no PDF library is needed on your side.
What about a photo of a paper receipt?
Images answer 415 text_unavailable with the route that downloads the file. Send it to a model that reads images, or to a person.
Can vendors send to it right away?
Yes. The inbox receives the moment it exists. With allow rules, add each vendor's domain before you share the address, or start without rules and add them once the list is known.
How long are invoices kept?
On Free, 90 days, with their files, then deleted. On a paid plan, until you delete them, within its storage. Download what your accounting records need to keep, or save the text the agent read.
Can the agent answer a vendor?
Yes, in the thread, with POST /v1/messages/{id}/reply. Answering a vendor whose mail passed DMARC never counts toward the ramp of new recipients.
What if the same invoice arrives twice?
A delivery the vendor's mail server retries is kept once. An invoice the vendor sends again is a new email, and both copies are stored: search the inbox for the invoice number with q before booking, and the earlier copy shows up with its booked label.
Can it read statements with many lines?
A CSV or Excel statement comes back as a Markdown table, which a model reads line by line. Past 100,000 characters the text is cut and says so in truncated.
Can the agent find an old invoice?
Yes. GET /v1/search?q=invoice 2291 finds it in every inbox by its words, with filters by sender and dates. On a paid plan, search reads the text of attached PDFs and spreadsheets too.
More agents at work
- Buys parts for Halden Robotics,halden-purchasing
@blueping.dev. The step before the invoice: quotes and purchase orders with suppliers. - Answers Larkspur's order emails,larkspur-orders
@blueping.dev. The same attachment reading on the selling side: return labels and receipts. - Assists Olderwick's partners,olderwick-assistant
@blueping.dev. Receipts a busy person forwards, filed by the same agent.
Book every invoice on arrival
One address, vendors you approve, and attachments read as text.