Blog โ†’ How to Automate Invoice Parsing in n8n

How to Automate Invoice Parsing in n8n

2026-05-27 ยท 4 min read

๐Ÿ“ง Email Trigger

New invoice arrives

โ†’
๐Ÿ”— HTTP Request

DocuParseAPI extracts data

โ†’
โš™๏ธ Set Fields

merchant, total, date

โ†’
๐Ÿ“Š Google Sheets

New row appended

The complete workflow you'll build in this guide โ€” importable in one click

n8n is a workflow automation tool that connects apps and APIs without writing code. This guide shows how to build a workflow that takes an invoice file and automatically extracts the structured data using DocuParseAPI.

What We're Building

A workflow that:

  1. Triggers when a new invoice arrives (email attachment, Google Drive, or manual trigger)
  2. Calls DocuParseAPI to extract the invoice data
  3. Writes the extracted fields to Google Sheets (or any other destination)

Total setup time: 15โ€“20 minutes.

What You Need

  • n8n (cloud or self-hosted)
  • A DocuParseAPI account โ€” free at docuparseapi.com/signup
  • A Google account (for Google Sheets output โ€” or substitute any other destination node)

Step 1: Get Your API Key

  1. Sign up at docuparseapi.com/signup
  2. Go to Dashboard โ†’ API Keys
  3. Create a new key and copy it immediately (shown only once)

Don't have a DocuParseAPI key yet?

Get 20 documents/month โ€” free forever โ€” no credit card.

Get Your Free API Key โ†’

Step 2: Create the Workflow

Node 1: Trigger

For testing, use the Manual Trigger node. For production, replace with:

  • Email Trigger (IMAP): fires when a new email arrives with an attachment
  • Google Drive Trigger: fires when a new file appears in a folder
  • Webhook: fires when your app posts an invoice file

Node 2: HTTP Request (DocuParseAPI call)

Add an HTTP Request node with these settings:

Method: POST
URL: https://docuparseapi.com/api/v1/extract
Authentication: Header Auth
  Header Name: Authorization
  Header Value: Bearer YOUR_API_KEY_HERE
Body Content Type: Form-Data/Multipart
Body Parameters:
  Name: file
  Value: [binary data from previous node]
  Type: File

If your previous node outputs a file (e.g., an email attachment), set the file value to the binary output of that node using the expression: {{ $binary.data }}.

HTTP Request
MethodPOST
URLhttps://docuparseapi.com/ api/v1/extract
AuthenticationHeader Auth
Header NameAuthorization
Header ValueBearer โ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ข
Body TypeMultipart/Form-Data
Field Namefile
Field Value{{ $binary.data }}

Your HTTP Request node should look like this.

Node 3: Parse the Response

Add a Set node to extract the fields you need:

merchant: {{ $json.merchant }}
total: {{ $json.total }}
tax: {{ $json.tax }}
currency: {{ $json.currency }}
date: {{ $json.date }}
due_date: {{ $json.due_date }}
invoice_id: {{ $json.invoice_id }}

Node 4: Write to Google Sheets

Add a Google Sheets node:

  • Operation: Append
  • Sheet: your invoice tracking sheet
  • Map the fields from the Set node to your sheet columns

The Complete Workflow (JSON Import)

You can import this directly into n8n:

โฌ‡ Skip the setup โ€” import the complete workflow directly

Copy the JSON below and paste it into n8n:
n8n โ†’ New Workflow โ†’ โ‹ฎ (menu) โ†’ Import from JSON

json ยท 56 lines
{
  "name": "Invoice Parser โ€” DocuParseAPI",
  "nodes": [
    {
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [250, 300]
    },
    {
      "name": "Parse Invoice",
      "type": "n8n-nodes-base.httpRequest",
      "position": [500, 300],
      "parameters": {
        "method": "POST",
        "url": "https://docuparseapi.com/api/v1/extract",
        "authentication": "headerAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer {{ $credentials.headerAuth.value }}"
            }
          ]
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "name": "file",
              "value": "={{ $binary.data }}",
              "parameterType": "formBinaryData"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "name": "Extract Fields",
      "type": "n8n-nodes-base.set",
      "position": [750, 300],
      "parameters": {
        "values": {
          "string": [
            { "name": "merchant", "value": "={{ $json.merchant }}" },
            { "name": "total", "value": "={{ $json.total }}" },
            { "name": "currency", "value": "={{ $json.currency }}" },
            { "name": "date", "value": "={{ $json.date }}" },
            { "name": "invoice_id", "value": "={{ $json.invoice_id }}" }
          ]
        }
      }
    }
  ]
}

Handling Errors in n8n

Add an IF node after the HTTP Request to check for success:

  • Condition: {{ $json.success }} equals true
  • True branch: continue to Extract Fields
  • False branch: send a notification (Slack, email) with {{ $json.error.code }}

Common errors and what they mean:

  • LIMIT_EXCEEDED โ€” you've hit your monthly document limit; upgrade your plan
  • EXTRACTION_FAILED โ€” the document couldn't be parsed; check the file quality
  • UNSUPPORTED_FILE_TYPE โ€” only PDF, JPG, PNG are supported

Real Workflow: Email Invoice โ†’ Google Sheet

Gmail Trigger
โ†’
Filter
โ†’
HTTP Request
โ†’
IF success
โ†’
Google Sheets row
โ†’
Slack / Email

This is the most common use case for small businesses:

  1. Email Trigger (IMAP): Watch an email inbox for supplier invoices
  2. Filter: Check if the email has a PDF attachment
  3. HTTP Request: Send the attachment to DocuParseAPI
  4. IF: Check success === true
  5. Google Sheets: Append a new row with extracted fields
  6. Slack/Email: Send a notification that the invoice was processed

With this workflow, every supplier invoice that arrives in your inbox is automatically extracted and logged to a spreadsheet โ€” no manual data entry.

Next Steps

Your n8n workflow is ready. Your API key isn't.

Get 20 documents/month โ€” free forever.
No credit card. No expiry. Add your key and run the workflow.

Get Your Free API Key

More from the blog