blinking
← All articles
Automatyzacja AI12 October 2026· 9 min read

Automatic Download of Purchase Invoices from KSeF: How It Works and What to Set Up

How to pull purchase invoices from KSeF automatically: three approaches, permissions, token vs certificate, common traps and realistic set-up time.

Purchase invoices can be pulled from KSeF automatically in three ways: through the KSeF module of your accounting software, through your accountant, who downloads them on your behalf, or through your own automation connected to the official API (n8n, Make, a script). The first is simplest, the third gives the most control: an invoice goes straight to the person who approves it, and only then to accounting.

Since February 2026, suppliers no longer have to email you invoices. The invoice lives in KSeF, the Polish national e-invoicing system, and that is where you collect it. Below I explain how downloading works technically and organisationally, what I watch for during implementations, and when automation is not worth it. For the wider picture (deadlines, penalties, the transition period) see my guide to KSeF in 2026.

This reflects the situation in October 2026, based on my own practice and the Ministry of Finance documentation. The KSeF API keeps evolving, so I always check the current specification before a project.

What "downloading an invoice from KSeF" actually means

KSeF does not send you the invoice. The seller submits it to the system, the system assigns a KSeF number, and from that moment the invoice is available to the buyer, which is you. You receive it when you ask for it. There is no inbox that rings when a new invoice arrives, so someone or something has to ask regularly: are there any new invoices where I am the buyer?

The answer is an XML file (the FA structure), not a PDF. A readable PDF has to be generated from that XML afterwards. This matters: XML is unreadable to a person but ideal for automation, because every amount, tax ID and line item sits in a fixed field.

Three ways to download purchase invoices

ApproachHow it worksAdvantageDrawback
Accounting software moduleThe software (Comarch, enova, wFirma, Fakturownia, etc.) queries KSeF itselfSimplest, often included in the subscriptionNo approval workflow of your own, limited flexibility
Accountancy firmYour accountant gets permissions and downloads invoices on their sideNo work on your sideYou see invoices later and have no say in approval
Your own automation (API)n8n or Make queries KSeF every few hours, stores the invoices and triggers the next stepsFull control, approvals, notifications, integrationsNeeds implementation and upkeep

In my experience, small businesses with a dozen or so invoices a month usually stay with the first or second option, and rightly so. The third makes sense when volumes are high, more than one person approves invoices, or invoices must reach several systems at once.

How downloading through the API works

The outline is the same whatever the tool:

  1. Authentication. The system proves it is allowed to act for your company, using a KSeF token or a certificate (more below).
  2. Query. The automation asks for invoices where your tax ID is the buyer, within a given time window.
  3. Download the XML. For each invoice found, it fetches the content.
  4. Remember the starting point. After each run I store how far I got, so the next run continues from there rather than from scratch. Without this you get duplicates or gaps.
  5. Further processing. Read the XML fields, generate a PDF preview, save to a sheet or database, send for approval.

The most common mistake I see in amateur scripts is step 4. Someone sets "fetch invoices from the last 24 hours", then a weekend outage of the automation leaves an invoice nobody downloaded. So I use a time window with an overlap of a few minutes and de-duplicate on the KSeF number.

Token or certificate

This question comes up in almost every project.

  • A KSeF token is simpler: you generate it in the application, choose the permissions and paste it into the automation. Good for getting started and for small projects.
  • A KSeF certificate is the more corporate option: it ties access to a specific certificate, is easier to manage across several systems, and can be revoked without touching the others.

Whichever you choose, the rule is the same: grant read-only access to invoices. An automation that downloads costs does not need the right to issue invoices in your name. I always price this separately and ask who in the company owns the access, because a token generated on the personal account of an employee who leaves in six months is a classic time bomb.

What happens after the download is where the value is

Downloading the XML alone achieves little. The savings appear in the following steps, which can be automated:

  • Reading the data: seller, tax ID, invoice number, net/VAT/gross amounts, due date, bank account.
  • A PDF preview for whoever approves the cost.
  • Preliminary coding: a supplier's tax ID can suggest a cost category or cost centre (fuel, hosting, materials).
  • Approval: a notification by email or chat to the right person, with approve and reject buttons.
  • Hand-off to accounting, including who approved and when.

The full scope is described on the page about KSeF and invoice workflow automation. The point here is that downloading is the foundation, while approval is where a company really saves time.

Three observations from implementations

First: there are more invoices than the owner thinks. On the first run, an automation often surfaces invoices from forgotten suppliers: subscriptions, minor services, invoices from counterparties who have already switched to the new system. It is worth running a one-off back-import to compare with what accounting holds.

Second: the technology is rarely the main problem. Most time goes on deciding who is responsible for an invoice nobody wants to approve ("that's not ours", "we never ordered it"). An automation can remind someone after three days, but a person still has to decide.

Third: not everything is in KSeF. Foreign supplier invoices, receipts, tickets and bills from private individuals still arrive by email or on paper. If you automate only KSeF, you end up with two workflows. For larger firms I therefore add AI-based OCR for such documents and route them through the same path.

An example scenario

This is an illustrative scenario, not a real client. A trading company with 8 people receives around 90 purchase invoices a month. Today the accountant downloads them once a week, and the owner learns about a transport invoice only at month-end close.

After implementation, the automation fetches new invoices every few hours. A fuel invoice goes to the fleet manager, a marketing invoice to the owner, the rest straight to accounting. The administrator's workload drops by roughly several hours a month, but more important is that no invoice waits for weeks for a decision. I broke down the costs of such a project in how much KSeF implementation costs.

Pitfalls worth knowing

  • API changes. The Ministry keeps developing KSeF, and some integrations built on an older version had to be rewritten. Ask the supplier who fixes the automation after such a change.
  • Expiring access. Tokens and certificates have an expiry date. A good automation warns in advance; a bad one stops on Friday evening.
  • No monitoring. Downloading that silently stops working is worse than manual work. I set an alert if there has been no successful run for a set number of hours.
  • Data in the wrong place. Invoices contain personal and commercial data. I ask where the automation server sits and recommend the EU or your own server.
  • Ownership. The admin account for n8n or Make should belong to you, not the contractor.

How long it takes

Downloading from KSeF with hand-off to software you already use takes 1–3 weeks, of which the API integration itself is a few days. The rest is agreeing approval rules. Among clients in Swarzędz and Kórnik I have discussed such projects with, a simple workflow with two approvers was usually enough.

FAQ

Do I have to download invoices from KSeF by hand?

No. You can use a module in your accounting software, authorise your accountant, or set up your own automation through the API. Logging in manually is the slowest option.

Is a KSeF invoice a PDF?

No, it is an XML file in a defined structure. A PDF is only a visualisation generated by software or the automation.

Does the automation need permission to issue invoices?

No. Read-only access is enough for downloading costs. The narrower the permission, the lower the risk if a token leaks.

What about invoices that are not in KSeF?

Foreign invoices, receipts and some documents from farmers or private persons need to be handled separately, for example with AI-based OCR and a shared approval path.

Can I start simple and expand later?

Yes, and I often advise it. Start with the module in your software and add automation once you see that invoice approval takes your team real time.

Summary

Downloading purchase invoices from KSeF is technically straightforward. The harder part is designing what happens next: who sees the invoice, who approves it and when it reaches the accountant. Start by counting how many purchase invoices you handle each month and how many people touch them. If it is a few dozen or more and more than one person is involved, automation pays back.

If you would like to check which option suits your company, get in touch through the contact form. The initial conversation is free.

Need help with implementation?

Get in touch — free consultation, quote within 24h.