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 DocuParse API.
What We're Building
A workflow that:
- Triggers when a new invoice arrives (email attachment, Google Drive, or manual trigger)
- Calls DocuParse API 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 DocuParse API account — sign up free at docuparseapi.com
- A Google account (for Google Sheets output — or substitute any other destination node)
Step 1: Get Your API Key
- Sign up at docuparseapi.com
- Go to Dashboard → API Keys
- Create a new key and copy it immediately (shown only once)
Don't have a DocuParse API key yet?
Get 20 documents/month — free forever — no credit card.
Sign up — get a free API keyStep 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 (DocuParse API 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 }}.
Name this node Submit Document. It returns a document_id, not the extracted fields, so add three more nodes to fetch the result:
- A Wait node — wait 5 seconds so extraction can finish.
- An HTTP Request node named Get Result:
Method: GET
URL: https://docuparseapi.com/api/v1/documents/{{ $('Submit Document').item.json.document_id }}
Authentication: Header Auth (same credential)
- An IF node named Completed? — condition:
{{ $json.status }}equalscompleted. True → map fields. False → back to the Wait node (add a second IF that stops with an error when status equalsfailed).
Your Submit Document node should look like this. The Get Result node then calls GET https://docuparseapi.com/api/v1/documents/{id}.
Node 3: Parse the Response
Add a Set node after the Completed? true branch to map the fields you need:
merchant → {{ $json.data.merchant }}
total → {{ $json.data.total }}
tax → {{ $json.data.tax }}
currency → {{ $json.data.currency }}
date → {{ $json.data.date }}
invoice_id → {{ $json.data.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
In the Manual Trigger test, attach a file as binary property "data". In production, replace the trigger with Gmail, Google Drive or a webhook trigger.
Handling Errors in n8n
The Failed? IF node after Get Result checks the document status:
- Condition:
{{ $json.status }}equalsfailed - True branch: stop with an error, or send a notification (Slack, email)
- False branch: back to the Wait node
If the Submit Document request itself fails, its response carries {{ $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 DocuParse API, wait, then fetch the result with
GET /api/v1/documents/{id} - IF: Check
status === "completed" - 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.