Quick Overview
This workflow receives an order via webhook, builds an EN 16931 invoice payload and HTML, generates a ZUGFeRD/Factur-X (PDF/A-3 + embedded XML) e-invoice using PolyDoc, emails the PDF to the buyer, and returns the PDF in the webhook response.
How it works
- Receives an HTTP POST request with an
order object via an n8n webhook endpoint.
- Validates that the order contains at least one line item and includes either a due date or payment terms.
- Calculates line totals, VAT, and invoice totals, and renders a printable HTML invoice along with a structured invoice payload.
- Uses PolyDoc to generate a verified ZUGFeRD/Factur-X EN 16931 e-invoice PDF/A-3 from the HTML and invoice data.
- Sends the generated PDF to the buyer via email using SMTP.
- Returns the generated PDF as the webhook response, or returns a 422 JSON error if the order is invalid.
Setup
- Create and add a PolyDoc API credential for the PolyDoc node.
- Configure an SMTP credential for the Email Send node (or remove the email step if you only want to return the PDF).
- Copy the webhook URL and configure your source system to POST JSON to
/einvoice with the required order fields (seller, buyer, and lines, plus dueDate or paymentTerms).