Guide · Tutorial · Automation

How to Automatically Extract Invoices from Gmail

By Othmane M., founder of DocuParse API

2026-07-21 · 3 min readLast updated: 2026-10-20

Most invoices arrive by email. Which means the most useful automation you can build is the one that watches your inbox: every invoice that lands gets read, extracted, and filed automatically, without you downloading a single attachment. This is the trigger step of no-code invoice automation, and it's the one that saves the most time because it removes the "download the PDF" step you do dozens of times a week.

The workflow

Four steps, identical whether you build it in n8n, Make, or Zapier:

  1. Trigger: a new email arrives in Gmail with an attachment (optionally filtered to a label like Invoices or a sender list).
  2. Grab the attachment: the PDF or image on the email.
  3. Extract: send the attachment to the parsing API, get back structured JSON.
  4. File it: append a row to a sheet, or create a bill in your accounting tool.

Setting it up

Filter first. Don't process every email — most aren't invoices. Create a Gmail label and a filter (e.g. attachments from known vendors, or emails matching "invoice"/"receipt"), and trigger only on that label. This keeps the automation cheap and clean.

The extraction step is two HTTP requests: submit the file, then fetch the result.

text · 10 lines
1. Submit
POST https://docuparseapi.com/api/v1/extract
Authorization: Bearer dex_live_...
Content-Type: multipart/form-data

file=<the email attachment>

2. Fetch the result (repeat until "status" is "completed" or "failed")
GET https://docuparseapi.com/api/v1/documents/{document_id}
Authorization: Bearer dex_live_...

The fetched result carries normalized fields in its data object (this is a real invoice):

json · 14 lines
{
  "document_type": "invoice",
  "document_number": "31293737",
  "invoice_id": "31293737",
  "receipt_id": null,
  "date": "2020-12-15",
  "due_date": null,
  "currency": "USD",
  "merchant": "Nunez Inc",
  "merchant_address": "6551 Janet Gardens, Michaelberg, KS 90952",
  "merchant_email": null,
  "customer": "Alvarez Inc",
  "line_items": [...]
}

The one thing to get right: passing the attachment as a file. In an email-triggered workflow the extraction step needs the attachment sent as binary multipart/form-data in the file field — not as a link, and not as text. Each platform handles email attachments a little differently, so if your first run returns an error instead of JSON, that's almost always the cause. The platform setup guides — n8n, Make, Zapier — show the exact configuration for sending the attachment through.

File the result. Map the JSON fields to your destination — a row in Google Sheets, a bill in QuickBooks or Xero, or a database entry in Notion.

Build it in your tool of choice

The step-by-step for each platform:

  • n8n — Gmail trigger, the file-handling setup, HTTP node, and destination mapping pre-built.
  • Make — visual Gmail-to-destination workflow.
  • Zapier — the simplest email trigger to start with.

Not sure which platform? See n8n vs Make vs Zapier for invoices. Processing a backlog rather than a live inbox? See automating invoice processing at scale.

The result

Once it's live, an invoice hits your inbox and shortly after the data is filed — while you're doing something else. Over a month that's hours of downloading-and-typing you never do again.

You can build the whole thing on the free tier (sign up) — 20 documents a month, no credit card, enough to automate a real inbox. Or see the extraction on a real document first.

More from the blog

All posts →