# Sync and validate invoices with KSeF 2.0: n8n workflow template

> Started by a clock, and works across n8n data table. 27 steps, 2 branches, 3 loops or waits: large, and worth reading before you trust it with anything live.

Source: https://millionrounds.com/workflow/sync-and-validate-invoices-with-ksef-2-0 (Millionrounds; every figure on the page links to its filing or article)

[Automation library](https://millionrounds.com/workflows) · [Money admin](https://millionrounds.com/workflows?category=Money+admin#library)

# Sync and validate invoices with KSeF 2.0

Started by a clock, and works across n8n data table. 27 steps, 2 branches, 3 loops or waits: large, and worth reading before you trust it with anything live.

Large

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fsync-and-validate-invoices-with-ksef-2-0)

**27 steps** Large: read it before trusting it with anything live

**2** Branches: places the flow splits

**3** Loops or waits

**1** Service it connects to

## The flow

Starts it 2 Logic 9 Service 16

The steps in the order they run, from what starts it.

- 1 **Create Tables** Manual trigger *Starts it*
- 2 **Start Sync Schedule** Schedule trigger *Starts it*
- 3 **Split Out** Split Out *Logic*
- 4 **Get Organizations** Data Table *Service*
- 5 **Get Table KSEF_Config** Data Table *Service*
- 6 **Get table KSEF_Audit_Log** Data Table *Service*
- 7 **Loop Organizations** Split In Batches *Logic*
- 8 **If** If *Logic*
- 9 **If1** If *Logic*
- 10 **Get Auth Challenge** Http Request *Service*
- 11 **Create KSEF_Config** Data Table *Service*
- 12 **Create KSEF_Audit_Log** Data Table *Service*
- 13 **Get MF Public Key** Http Request *Service*
- 14 **Write Configuration** Data Table *Service*
- 15 **Encrypt KSeF Token** Code *Logic*
- 16 **Init Session Token** Http Request *Service*
- 17 **Wait for Session Init** Wait *Logic*
- 18 **Check Session Status** Http Request *Service*
- 19 **Redeem Session Token** Http Request *Service*
- 20 **Fetch Invoice List** Http Request *Service*
- 21 **Split Invoice Items** Code *Logic*
- 22 **Loop Over Items** Split In Batches *Logic*
- 23 **Retrive XML** Http Request *Service*
- 24 **Extract from File** Extract From File *Service*
- 25 **XML** Xml *Logic*
- 26 **Check WhiteList** Http Request *Service*
- 27 **Upsert row(s)** Data Table *Service*

## How it's built

- **Starts on:** A clock
- **Steps:** 27, with 2 branches, 3 loops or waits
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** n8n data table
- **Model:** None. This is plumbing, not judgement

## Questions

What does it need to run?

An n8n account. You connect your own accounts after importing it; none are included.

What starts it?

It starts on a clock.

Does it use AI?

No. Every step is fixed logic or a call to a service, so it does the same thing every time.

How long does it take to set up?

Take your time. At 27 steps it is large: read it before trusting it with anything live.

How do I import it?

Copy the workflow, open a new workflow in n8n and paste. The steps appear on the canvas, ready for your own accounts.

**Before you run it**

Nothing here has been tested by us. It is somebody's working automation, read and described from its own steps. Treat the connections it wants as a list of accounts it will touch, and read the 27 steps before you point it at anything that matters.

## Run it in n8n

- **Create your n8n account** Free to start. n8n is where the workflow runs. [Create an n8n account ↗](https://millionrounds.com/n8n)
- **Download the workflow** Free with a Millionrounds account. [Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fsync-and-validate-invoices-with-ksef-2-0)
- **Paste it into n8n** Open a new workflow in n8n and paste. Then connect your own accounts.

Stored with the author's traces removed: canvas notes, instance identifiers, saved credential names and any live document they had left behind.

## Connects to

Each opens the other workflows that use it.

[n8n data table](https://millionrounds.com/workflows?service=n8n+data+table#library)

## Workflows like it

Also money admin, with the same services where possible, closest in size first.

- [**Automate invoice creation & smart reminders with Jotform** 27 steps · calls a model · Outlook, n8n data table](https://millionrounds.com/workflow/automate-invoice-creation-and-smart-reminders-with-jotform)
- [**Generate invoices and send AI-summarized reminders** 27 steps · calls a model · Email, n8n data table](https://millionrounds.com/workflow/generate-invoices-and-send-ai-summarized-reminders)
- [**Run bounded dunning for Lago payment failures** 25 steps · Email, n8n data table](https://millionrounds.com/workflow/run-bounded-dunning-for-lago-payment-failures)
- [**Generate invoices and send AI-powered reminders with Jotform** 23 steps · calls a model · Email, n8n data table](https://millionrounds.com/workflow/generate-invoices-and-send-ai-powered-reminders-with-jotform)
- [**Automate SaaS operations with OpenAI** 33 steps · calls a model · Gmail, n8n data table](https://millionrounds.com/workflow/automate-saas-operations-with-openai)
- [**GPT 4.1-mini proposal to payment lifecycle management** 33 steps · calls a model · Gmail, n8n data table](https://millionrounds.com/workflow/gpt-4-1-mini-proposal-to-payment-lifecycle-management)
