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:
- Triggers when a new invoice arrives (email attachment, Google Drive, or manual trigger)
- Calls DocuParseAPI to extract the invoice data
- 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
- Sign up at docuparseapi.com/signup
- Go to Dashboard โ API Keys
- 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 }}.
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
Handling Errors in n8n
Add an IF node after the HTTP Request to check for success:
- Condition:
{{ $json.success }}equalstrue - 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 planEXTRACTION_FAILEDโ the document couldn't be parsed; check the file qualityUNSUPPORTED_FILE_TYPEโ only PDF, JPG, PNG are supported
Real Workflow: Email Invoice โ Google Sheet
This is the most common use case for small businesses:
- Email Trigger (IMAP): Watch an email inbox for supplier invoices
- Filter: Check if the email has a PDF attachment
- HTTP Request: Send the attachment to DocuParseAPI
- IF: Check
success === true - Google Sheets: Append a new row with extracted fields
- 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.