> ## Documentation Index
> Fetch the complete documentation index at: https://foliant-help.iforiti.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Send invoices to KSeF (Poland)

> Connect Foliant to KSeF, Poland's national e-invoicing system, so your invoices to businesses are issued through KSeF with their KSeF number and QR code.

KSeF (Krajowy System e-Faktur) is Poland's national e-invoicing system. An invoice to a business exists only once KSeF has accepted it and given it a KSeF number. With KSeF connected, Foliant sends your invoices to businesses to KSeF as they're issued. Each PDF then shows its KSeF number under a QR code your customer can scan to check the invoice in KSeF.

## Which documents go to KSeF

* **Invoices to businesses:** an order with a company, or with the customer's company name or VAT number (NIP).
* **Credit notes** for those invoices. Foliant sends them as corrective invoices (faktura korygująca) that name the invoice and its KSeF number.
* **Invoices to consumers** are issued as before, without KSeF.

Foliant writes each invoice in the KSeF format (FA(3)), with Polish VAT rates. An invoice in another currency also shows its VAT in złoty, at the National Bank of Poland rate.

> [!NOTE]
>
> Foliant sends your invoices as your store records them. You remain responsible for your invoices and VAT filings: if you're unsure how a sale should be invoiced, ask your accountant.

## Before you start

* **Your store's details:** in **Settings › Tax & legal**, your VAT number must be your Polish NIP (with or without `PL`). KSeF only accepts invoices from the NIP the connection is for.
* **Locked invoices:** KSeF works only with **Locked invoices** turned on, in **Settings › Documents & printing**. See [Locked invoices](https://foliant-help.iforiti.com/invoices-and-numbering/locked-invoices.md).
* **A KSeF token:** create one in KSeF (Aplikacja Podatnika KSeF) for your NIP, with permission to issue invoices (wystawianie faktur). Copy it: KSeF shows it only once.

## Connect KSeF

1. In Foliant, go to **Settings › Integrations**.
2. On **KSeF (Poland)**, click **Connect**.
3. Enter your **NIP** and paste your **KSeF token**.
4. Click **Connect**.

Foliant signs in to KSeF to check the NIP and the token. If KSeF refuses the token, Foliant says why next to the field. Create a new token in KSeF and paste it again.

**KSeF environment** (under **Show advanced settings**) is **Production** unless you're trying the connection with a test token. Test and Demo invoices aren't real invoices.

## What happens when an invoice is issued

1. Foliant gives the invoice its number and sends it to KSeF.
2. KSeF usually accepts it within seconds. Foliant then makes the PDF with the KSeF number and the QR code, and locks it like any issued invoice.
3. Your customer gets that PDF, by email, download or in their account.

While KSeF hasn't accepted an invoice yet, it keeps its number but has no PDF:

* **Emails** that include it wait and go out once KSeF has accepted it.
* **Downloads and exports** leave it out until then.
* **The print page** shows a notice in its place. Print it again once KSeF has accepted it: a printed invoice must show its KSeF number and QR code.

If KSeF can't be reached, Foliant keeps trying for you.

To put the KSeF number and QR code somewhere specific in your template, use `{{ document_clearance_qr }}` and `{{ document_clearance_number }}`. Otherwise Foliant adds them at the end of the invoice.

## If KSeF doesn't accept an invoice

KSeF can refuse an invoice, for example when a customer's NIP is wrong. The invoice isn't issued, and you get an inbox message with KSeF's reason.

1. Go to **Issued invoices**. The **Waiting for KSeF** card lists the invoice as **Not accepted**, with **KSeF's reason**.
2. Fix the cause: the customer's details on the order in Shopify, or your details in **Settings › Tax & legal**.
3. Click **Send again**.

The invoice keeps its number, so your invoice series has no gaps.

## Download what KSeF has

On **Issued invoices**, an invoice issued through KSeF shows **KSeF:** and its number under the invoice number. Its row has two more downloads:

* **Download KSeF invoice (XML)**: the invoice exactly as KSeF accepted it.
* **Download KSeF receipt (UPO)**: KSeF's official receipt for it (Urzędowe Poświadczenie Odbioru). KSeF makes it a few minutes after accepting the invoice.

Every send is also listed in the KSeF integration's **Activity**. See [Integration activity](https://foliant-help.iforiti.com/integrations/integration-activity.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.