Poll and download received invoice PDFs with KSeF Gateway to disk storage
Quick overview This workflow runs every 20 minutes to poll a self-hosted KSeF Gateway for newly received KSeF invoices, maintains a cursor checkpoint in n8n static data, downloads each new invoice PDF via the gateway API, and saves the files to local disk.
How it works Runs every 20 minutes on a schedule. Reads the last successful polling checkpoint from the workflow’s static data and calls the KSeF Gateway /ksef/invoices/received/new endpoint with the since cursor. If the gateway response is unsuccessful, records the error details for alerting and leaves the checkpoint unchanged so the next run retries the same window. If the response is successful, stores the returned nextSince value as the new checkpoint. If new invoices are returned, processes each invoice summary individually. Downloads each invoice PDF from the KSeF Gateway /ksef/invoice/{ksefNumber}/pdf endpoint and saves it to the configured local folder. Outputs invoice metadata (number, seller, amount, and saved file path) as a placeholder where you can plug in notifications (Slack, email, or Discord).
Setup Deploy and configure a self-hosted KSeF Gateway (https://github.com/jurczykpawel/ksef-gateway) with a token or certificate that has the InvoiceRead permission. Set the gateway base URL, your NIP, and the invoice output directory in the Configuration step, and ensure the directory is writable by the n8n host. Provide the KSeF Gateway API key in the configuration so the workflow can authenticate to the gateway endpoints. If you want alerts, connect your preferred notification service to the final “Notify” step and map the provided invoice fields.
Related Templates
AI Email Classifier & Auto-Delete for Gmail (SPAM/OFFER Cleaner)
This workflow is designed for freelancers, solopreneurs, and business owners who receive a high volume of irrelevant mes...
Generate Product Ad Copy & CTAs with GPT-4 for Slack and Airtable
⚡ AI Copywriter Pro: Instant Ad Copy & CTA Generator Transform product details into compelling marketing copy in second...
Generate Food Recipes from Gmail & Form Requests with Ollama & Llama 3.2
This n8n template demonstrates how to create an intelligent food recipe assistant that accepts requests via Gmail and we...
🔒 Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments