> ## Documentation Index
> Fetch the complete documentation index at: https://docs.parzo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# n8n

> Automate invoice extraction with n8n workflows.

## Overview

Parzo works natively with n8n via HTTP Request nodes. You can build powerful invoice automation workflows without writing any code.

## Prerequisites

* An n8n instance (self-hosted or n8n.cloud)
* A Parzo API key — get one free at [parzo.dev](https://parzo.dev)

***

## Basic workflow

### Step 1 — Store your API key

In n8n, go to **Credentials → Add Credential → Header Auth** and set:

* **Name:** `Parzo API`
* **Header name:** `X-API-Key`
* **Header value:** `inv_your_key_here`

### Step 2 — Submit the invoice

Add an **HTTP Request** node:

* **Method:** `POST`
* **URL:** `https://api.parzo.dev/v1/extract/invoice`
* **Authentication:** Header Auth → Parzo API
* **Body Content Type:** Form-Data Multipart
* **Body Parameter name:** `file` — set to the binary PDF attachment

### Step 3 — Wait and poll

Add a **Wait** node set to **5 seconds**.

Then add another **HTTP Request** node:

* **Method:** `GET`
* **Authentication:** Header Auth → Parzo API
* **URL:** build the URL using the job\_id from the previous step — for example `https://api.parzo.dev/v1/jobs/` followed by the job\_id expression in n8n

### Step 4 — Check if completed

Add an **IF** node:

* **Field:** `status`
* **Operation:** equals
* **Value:** `completed`
* **True branch** → process the result
* **False branch** → loop back to the Wait node

### Step 5 — Use the data

The extracted fields are available in the result object. Map these paths in your downstream nodes:

* Vendor name: `result.vendor.name`
* VAT number: `result.vendor.vat_number`
* Invoice number: `result.invoice.number`
* Invoice date: `result.invoice.date`
* Total: `result.financials.total`
* Currency: `result.financials.currency`
* Tax amount: `result.financials.tax_amount`

***

## Complete email-to-sheets workflow

Connect these nodes in order:

1. **Gmail Trigger** — trigger on new email, filter by `has:attachment filename:pdf`
2. **HTTP Request** — POST to `https://api.parzo.dev/v1/extract/invoice` with the PDF attachment as `file`
3. **Wait** — 5 seconds
4. **HTTP Request** — GET the job status using the job\_id from step 2
5. **IF** — check if status equals `completed`
6. **Google Sheets** — append a row mapping these fields:
   * Vendor: `result.vendor.name`
   * Invoice number: `result.invoice.number`
   * Date: `result.invoice.date`
   * Total: `result.financials.total`
   * VAT: `result.financials.tax_amount`
   * Currency: `result.financials.currency`

## Webhook instead of polling

For production workflows, use webhooks to avoid polling loops.

In your Parzo dashboard, set the webhook URL to your n8n webhook endpoint. Then replace the Wait + HTTP Request loop with a single **Webhook** node that receives the result automatically.

<Note>
  Webhooks are available on Starter plan and above.
</Note>

## Tips

<AccordionGroup>
  <Accordion title="Handle errors gracefully">
    Add an **IF** node after getting the result to check for validation flags.
    If the length of `result.validation_flags` is greater than zero, route to a Slack notification or a manual review sheet.
  </Accordion>

  <Accordion title="Process multiple attachments">
    Use a **Split In Batches** node before the HTTP Request to process each PDF attachment separately.
  </Accordion>

  <Accordion title="Store results in Notion">
    Replace the Google Sheets node with a **Notion** node using **Create Database Item** and map the same fields.
  </Accordion>
</AccordionGroup>
