iFirma automation · runs weekly
Book iFirma purchase invoices from KSeF as costs
Suppliers now send invoices through KSeF, and each one still has to be downloaded and booked as a cost by hand before it counts in your records.
Cotlet does it in your own iFirma account with list_ksef_purchase_invoices, list_contractors and book_ksef_purchase_invoice, called by your AI agent, an n8n workflow or a script.
Hosted · nothing to install or maintain
Can iFirma do this on its own?
iFirma's API documents four expense endpoints that add a cost document with its KSeF number (checked 14 Oct 2026), but no call downloads invoices from KSeF or books them from the "Faktury z KSeF" list. Automatic download exists in the app under "KSeF ➡ Konfiguracja" and still leaves the booking to you.
How you do it in iFirma today
- Go to "Wydatki ➡ Importuj z KSeF lub wgraj plik" and click the "Pobierz nowe faktury" icon.
- Enter the start date; it is the seller's issue date, not the date the invoice was sent to KSeF.
- In the "Faktury z KSeF" list, check the seller's NIP, KSeF number, issue date and the net and gross amounts for each document.
- Click "Zaksięguj" on a VAT invoice or a corrective invoice; advance and final invoices are booked in an order instead.
- Booked documents appear in "Wydatki ➡ Lista wydatków". What repeats: the download and the booking click, for every supplier invoice.
How to book iFirma purchase invoices from KSeF as costs
List the purchase invoices that arrived in KSeF since last Monday and are not booked yet. Book the ones from suppliers I already have as contractors and show me the rest. - 01
Download from the last date
list_ksef_purchase_invoices fetches new documents from the date you give, so a week of invoices is read as one batch. Documents already booked are skipped by iFirma itself.
- 02
Match the seller to your contractors
Each seller NIP is looked up with list_contractors. A supplier you already have is booked straight away; an unknown one goes to the "for you" list.
- 03
Sort by document type
VAT and corrective invoices can be booked directly. Advance and final invoices need an order, so the agent lists them instead of booking.
- 04
Book the matches
book_ksef_purchase_invoice books one document by its KSeF number. By default it waits for your OK, because a booked cost goes into your tax records.
- 05
Report both lists
You get what was booked with amounts and what is left, so only the odd suppliers need a decision.
What you get back
New in KSeF since 2026-10-07: 5
Booked 3:
- Harbor Print Ltd, FV 118/2026: net 650.41, gross 800.00 PLN
- Cloud Hosting SA, 2026/10/771: net 81.30, gross 100.00 PLN
- Office Supply Sp. z o.o., 55/10/2026: net 243.90, gross 300.00 PLN
Left for you 2:
- unknown supplier NIP 5252248481, advance invoice
- Lime Courier, final invoice (needs an order) Other ways to ask
- Every Monday, list new KSeF purchase invoices and book only those under 500 PLN gross.
- Show me everything that arrived in KSeF this month grouped by supplier, and book nothing.
- Book the invoices from Harbor Print Ltd and tell me about any corrective invoices.
What iFirma allows, and what to know first
- The start date of a KSeF download is the seller's issue date, not the date it was sent to KSeF.
- A document whose KSeF number is already in tax records or the expense list is not downloaded again.
- A VAT invoice offers "Zaksięguj" or adding to a collective expense, and a corrective invoice offers "Zaksięguj".
- Removing a document from the "Faktury z KSeF" list stops it being downloaded again unless the import period covers its issue date.
- Downloading from KSeF is available in the Księgowość internetowa package and in the faktura plus and darmowa faktura packages.
book_ksef_purchase_invoice asks for your OK by default. To run it weekly without you, switch confirmation off for that tool in your dashboard.
Sources: iFirma Help: Faktury zakupowe z KSeF · iFirma API: wydatki
Call book_ksef_purchase_invoice from a script
curl -X POST https://cotlet.dev/api/v1/ifirma/ksefs/7010003987-20261012-AB12CD34EF56-7A/purchase-invoice \
-H "Authorization: Bearer $COTLET_API_KEY" {
"ksef_number": "7010003987-20261012-AB12CD34EF56-7A",
"booked": true,
"seller_number": "FV 118/2026",
"gross": 800
} MCP: add https://cotlet.dev/mcp/v1 with the same key; the call is ifirma_write → book_ksef_purchase_invoice. Example data.
Schedule it in n8n, Make, Zapier or croniFirma tools this automation uses
| Tool | Parameters |
|---|---|
| list_ksef_purchase_invoices | issued_from |
| list_contractors | name, nip, page |
| book_ksef_purchase_invoice | ksef_number |
Frequently asked questions
Is it safe to connect iFirma to Cotlet?
Yes. You sign in to iFirma yourself, in your own Cloud Browser in the EU, and we never save your password. Your agents only get iFirma once you enable it, every background request is listed, and the browser profile is stored encrypted with AES-256-GCM, the cipher 1Password uses for its vaults. The AI model never sees a login, posts and messages wait for your OK, and Disable for agents cuts access in one click. Independent scanners grade cotlet.dev A+ on Qualys SSL Labs, securityheaders.com and Mozilla Observatory; live results are on https://cotlet.dev/security.
Give your agent access to iFirma.
Free 7-day trial with 2,000 credits, no card needed. Cotlet is independent and not affiliated with iFirma.