FIELD NOTE / AUTOMATION / BOOKKEEPING

Accounts payable · Meta ads · Graph API · Chrome extension (MV3)

Meta charges the card almost every day. It never emails a receipt.

2026-11-13  ·  ~7 min read  ·  by Gal Tidhar

I build the systems a business runs its money through, and every one of them rests on the same assumption: the invoice arrives by email. Point the mailbox at the system, let a model read the PDF, have a human approve the draft. That works for every supplier that still sends invoices. It quietly breaks for the platforms that don't. Meta ads, paid by card, is the cleanest example I've hit: a charge almost every day, and not one receipt in the inbox in a year. This is everything I tried, why the answer ended up being a tiny Chrome extension, and why nothing about it is specific to Meta.

Flow: Meta's API lists every charge without a PDF; the system asks which charges have no receipt; an extension in a browser already logged in downloads each PDF; it checks the file starts with %PDF; bookkeeping reads it into a draft.

The problem: the document lives behind a login

For a card-paid ad account, Meta bills the card whenever spend crosses a threshold, and on a busy account that becomes a charge every day or two. Each charge has a receipt, a proper PDF with the amount, the transaction id, a reference number and an invoice number. It sits on the billing page in Business Manager. Someone has to log in and download it. If nobody does, the accountant notices at month end, and then someone downloads a month of them by hand.

For the customer I built this for, the account went from a charge every week or two to a charge almost every day around mid-year. That was 89 charges between January and November. Nobody is downloading 89 receipts.

What I tried, in order

1. The Graph API

The API knows every charge. The ad account's /activities edge, filtered to ad_account_billing_charge events, returns the amount (in the currency's minor unit), the time and a transaction_id. What it doesn't return is the document.

  • /act_<id>/transactions, the edge that used to list billing transactions, now answers (#100) nonexisting field.
  • /<business>/business_invoices exists and even returns download links, but it covers only accounts on Meta's monthly invoicing (a credit line you apply for). For a card-paid account it returns an empty list.
  • The official Python SDK has no receipt, charge or transaction edge on the ad account at all. I read through it to make sure.
  • The transaction_id isn't a Graph object you can fetch.

So the API is a perfect list of what should have a receipt, and nothing more.

2. Email

Meta's help pages say receipts go to the email associated with the ad account. I checked the ad account's contact email (mine, as it happens), checked that the "billing and payments" email notification was on, and searched a year of that Gmail, spam included. Zero ad receipts. WhatsApp Business receipts from Meta arrive in the same inbox just fine, so it isn't a deliverability problem. For this card-paid account, the email route simply doesn't exist.

3. The PDF link, from a server

The billing page's "download" builds a URL like this:

https://business.facebook.com/ads/manage/billing_transaction/
  ?act=<account id>&txid=<transaction id>&pdf=true&print=false
  &source=billing_summary&tx_type=3

Both ids are exactly the ones the API gives you. Fetched from a server with an API token, it returns a login page. Fetched from a browser tab where you are logged in to Facebook, it returns the PDF, around a megabyte. The same URL on www.facebook.com fails on CORS; business.facebook.com works. And, importantly, this URL did not ask for the passkey re-authentication that the billing hub UI asks for when it smells automation.

The receipt exists only where the user is already logged in.

4. A list with links (what I built first)

I had said, out loud, that I wasn't building a browser extension. An extension is software installed on other people's machines that you then debug remotely. So the first version was the honest minimum: the system pulls the charges from the API, matches each one to a document it already has (amount within one unit, date within three days), and shows a "missing receipts" list with a download link per charge and a drop zone next to it. Click, download, drag.

The first time it ran against the real account it showed 60 missing receipts out of 61. Nobody is doing click, download, drag sixty times. Not the customer, not me. I built the extension the same day.

The extension

It's a Manifest V3 extension with host permission for business.facebook.com and for the system's own domain, and nothing else. It is installed in the Chrome of someone who is already logged in to Facebook as an admin of the ad account. Setup is pasting one code from the system's settings page, which carries the system URL and a key (the server stores only its hash).

The loop:

  1. Every hour (and on browser start, and on "run now"), ask the system: which charges have no receipt yet? The system answers from the API, so the to-do list is always complete.
  2. For each, build the receipt URL from the account id and transaction id, and fetch it with credentials: 'include', from the extension's background worker. No tab opens. The browser's existing Facebook session is the only credential.
  3. Check the first five bytes are %PDF-. Logged out, no access to that ad account, or a security check: all of those come back as an HTML page with status 200. Checking the status code would happily upload a login page as a receipt.
  4. Post the PDF to the system, which files it like any invoice that arrived by email: read it, recognise the supplier, amount and date, create a draft for a human to approve.

Three receipts per run, and while there's a backlog the next run starts two minutes later, so months of receipts of months drain in the background without one long-running worker that Chrome would kill.

The security part I thought hardest about

An extension that fetches things with your Facebook cookies and sends them to a server is exactly the shape of malware, so the design has to make the server unable to abuse it:

  • The extension builds the URL itself. The server only ever sends two numeric ids, and the extension validates them as digits before it puts them into a fixed billing-receipt URL. Even someone in full control of the server can't make it fetch anything else your Facebook session can see.
  • The upload destination is pinned. Not "any subdomain of the hosting platform", because anyone can register one of those; a setup code pointing anywhere else is rejected.
  • No password, no token from Facebook is stored anywhere. If the user logs out, it stops trying that account and retries on the next run.

Why this is generic

Strip the names and the pattern is: the API is the to-do list, the browser is the key. Any supplier where (a) some API or export tells you that a charge happened, and (b) the document is a URL that works for a logged-in user, fits the same extension as one more source: a list endpoint on the server and a URL builder in the extension. Cloud consoles, ad platforms, SaaS billing portals, the long tail of suppliers whose "invoice" is a download button. The setup code, the popup, the upload and the PDF check are shared.

It isn't a new idea. I found at least one commercial expense tool that also collects platform invoices through a browser extension, for the same reason: there's no API to do it with. I didn't find anyone doing it with a token alone.

The other routes, honestly

  • Monthly invoicing with Meta. The only fully server-side route: invoices are emailed and available through business_invoices. You have to apply and be approved; the criteria aren't public.
  • A browser robot clicking through Business Manager. Fragile, and the billing hub asks for a passkey in exactly that situation.
  • Meta's "download all transactions" PDF. One PDF for a date range, by hand, once a month. Better than sixty clicks, still a human, and one PDF for many charges is harder to match to each payment.

What I'd do again, and not

Again: start from the list of what's missing, not from the documents. The API was useless for the PDF and perfect for knowing which PDFs should exist, and that list is also what makes the result auditable. Every charge either has a document or shows up as missing.

Not again: assume the extension would be the hard part. The browser fetch was ten lines. The work was in the boring parts around it: an MV3 worker that Chrome stops after about thirty seconds of quiet, a run lock that a killed worker leaves behind, retries that don't let a few stubborn receipts block the rest, and the Chrome Web Store review.