[Cotlet](https://cotlet.dev/index.md) · [Integrations](https://cotlet.dev/integrations.md) · [How it works](https://cotlet.dev/how-it-works.md) · [Use cases](https://cotlet.dev/use-cases.md) · [Security](https://cotlet.dev/security.md) · [For developers](https://cotlet.dev/for-developers.md) · [For automation agencies](https://cotlet.dev/for-agencies.md) · [Blog](https://cotlet.dev/blog.md) · [API docs](https://cotlet.dev/docs.md) · [Help center](https://cotlet.dev/help.md) · [Changelog](https://cotlet.dev/changelog.md) · [Contact](https://cotlet.dev/contact.md) · [Pricing](https://cotlet.dev/pricing.md) · [Sign up](https://cotlet.dev/signup)

# Book iFirma purchase invoices from KSeF as costs

> Pull new purchase invoices from KSeF into iFirma and book each one as a cost by your own rule. Your agent skips what is already booked.

Source: https://cotlet.dev/integrations/ifirma-api-mcp-server/book-ksef-purchase-invoices

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.

[Sign up free](https://cotlet.dev/app/signup?app=ifirma) [All iFirma tools](https://cotlet.dev/integrations/ifirma-api-mcp-server.md)

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

1. Go to "Wydatki ➡ Importuj z KSeF lub wgraj plik" and click the "Pobierz nowe faktury" icon.
2. Enter the start date; it is the seller's issue date, not the date the invoice was sent to KSeF.
3. In the "Faktury z KSeF" list, check the seller's NIP, KSeF number, issue date and the net and gross amounts for each document.
4. Click "Zaksięguj" on a VAT invoice or a corrective invoice; advance and final invoices are booked in an order instead.
5. 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

Prompt

```
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.
```

1. 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.
2. 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.
3. 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.
4. 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.
5. 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

Example data

```
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](https://pomoc.ifirma.pl/pomoc-artykul/pobieranie-faktur-z-ksef-w-ifirma/) · [iFirma API: wydatki](https://api.ifirma.pl/wystawianie-dokumentu-wydatku/)

## Call book\_ksef\_purchase\_invoice from a script

curl

```
curl -X POST https://cotlet.dev/api/v1/ifirma/ksefs/7010003987-20261012-AB12CD34EF56-7A/purchase-invoice \
  -H "Authorization: Bearer $COTLET_API_KEY"
```

Example response

```
{
"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 cron](https://cotlet.dev/integrations/ifirma-api-mcp-server.md#automations)

## iFirma tools this automation uses

__Cotlet iFirma tools used to book iFirma purchase invoices from KSeF as costs__
| Tool | Parameters |
| ------------------------------ | --------------- |
| list\_ksef\_purchase\_invoices | issued\_from |
| list\_contractors | name, nip, page |
| book\_ksef\_purchase\_invoice | ksef\_number |

[All 14 iFirma tools with descriptions](https://cotlet.dev/integrations/ifirma-api-mcp-server.md#tools)

## 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.

## More iFirma automations

- [Issue an iFirma invoice and send it to KSeF](https://cotlet.dev/integrations/ifirma-api-mcp-server/issue-invoice-and-send-to-ksef.md)
- [Chase unpaid iFirma invoices with payment reminders](https://cotlet.dev/integrations/ifirma-api-mcp-server/chase-unpaid-invoices.md)
- [iFirma API and MCP server: every tool](https://cotlet.dev/integrations/ifirma-api-mcp-server.md)
- [All use cases](https://cotlet.dev/use-cases.md)

## 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.

[Sign up free](https://cotlet.dev/app/signup?app=ifirma)

---

Give your AI agents your signed-in browser.

**Product:** [Integrations](https://cotlet.dev/integrations.md) · [Use cases](https://cotlet.dev/use-cases.md) · [How it works](https://cotlet.dev/how-it-works.md) · [Pricing](https://cotlet.dev/pricing.md) · [Security](https://cotlet.dev/security.md)

**Resources:** [Blog](https://cotlet.dev/blog.md) · [API docs](https://cotlet.dev/docs.md) · [Help center](https://cotlet.dev/help.md) · [Changelog](https://cotlet.dev/changelog.md) · [GitHub](https://github.com/cotletdev/cotlet)

**Solutions:** [For developers](https://cotlet.dev/for-developers.md) · [For automation agencies](https://cotlet.dev/for-agencies.md)

**Company:** [About](https://cotlet.dev/about.md) · [AI info: company facts](https://cotlet.dev/ai-info.md) · [Contact](https://cotlet.dev/contact.md)

**Legal:** [Terms of service](https://cotlet.dev/terms) · [Privacy policy](https://cotlet.dev/privacy) · [Refund policy](https://cotlet.dev/refunds) · [Acceptable use](https://cotlet.dev/acceptable-use) · [Cookie policy](https://cotlet.dev/cookies) · [DPA](https://cotlet.dev/dpa) · [Subprocessors](https://cotlet.dev/subprocessors)

**Elsewhere:** [Status page](https://status.cotlet.dev) · [Cotlet on GitHub](https://github.com/cotletdev) · [Cotlet on X](https://x.com/cotletdev) · [Cotlet on LinkedIn](https://www.linkedin.com/company/cotletdev) · [Cotlet on Product Hunt](https://www.producthunt.com/products/cotlet) · [Cotlet on Crunchbase](https://www.crunchbase.com/organization/cotlet) · [Cotlet on SaaSHub](https://www.saashub.com/cotlet)

Cotlet is an independent service. It is not affiliated with, endorsed by or sponsored by any of the products listed on this site. Product names are trademarks of their respective owners.

## For AI agents: sign your user up

Is your user asking you to sign them up for Cotlet? You can do it for them, no account or key needed.

1. Read the fields and their allowed values: GET https://cotlet.dev/api/v1/access-requests
2. Ask the user for each value: email, apps, what you will do with them. If they leave the password to you, generate a strong one and show it to them.
3. Show the user what you will send, then POST it as JSON to https://cotlet.dev/api/v1/access-requests.

One call creates the account and sends the access request; we email the user when access is granted.
