KSeF

KSeF invoice numbering: avoid duplicate FA(3) documents (P_2)

What P_2 is in an FA(3) invoice, why the invoice number must be unique, and the numbering scheme that keeps KSeF from rejecting a duplicate.

Published 3 min readBy Tomek

Overview

P_2 is the invoice number field in the Fa element of an FA(3) document, and it must uniquely identify a single invoice you issue. Use a stable, sequential scheme and never reuse a number, or KSeF can reject the document as a duplicate.

Where P_2 lives

A KSeF FA(3) invoice is one structured XML document. The invoice-level fields — including P_1 (issue date), P_2 (invoice number) and P_15 (total amount due) — sit in the Fa element. The Nagłówek (form header) carries only form metadata such as the form code, variant and creation timestamp. So P_2 is the invoice number on the document itself, not a header field.

Why uniqueness matters

KSeF is Poland's national e-invoicing platform, and each accepted invoice receives a KSeF number and a UPO (official proof of receipt). Your own P_2 is the number your business and your buyer use to refer to the document. If you reuse a number for a different document, the system can treat it as a duplicate and reject it, which turns a routine invoice into an exception you have to fix.

A numbering scheme that works

The safest scheme is one your team cannot accidentally repeat:

  1. Keep it sequential and structured. A pattern with the period embedded, such as FV/2026/10/001, makes the next number predictable and the scheme easy to audit.
  2. Do not reuse numbers. Even after a correction or a voided attempt, take the next number rather than recycling an old one.
  3. Do not renumber for retries. A retry of the same logical invoice keeps the same P_2; a genuinely new invoice gets a new number. Confusing the two is how duplicates happen.
  4. Store the number with the document. Record P_2 next to the KSeF number and UPO once accepted, so you can reconcile your books with the platform.

P_2 vs idempotency

P_2 is the number printed on the invoice. An idempotency key is a separate, client-side identifier you use to make sure the same submission is not sent twice when a timeout makes the outcome unclear. They are related but not the same: keep the invoice number for the document, and handle retries with your own idempotency bookkeeping rather than by reusing or renaming P_2.

FAQ

Where does the invoice number live in FA(3)? In the Fa element, as the P_2 field. It is not part of the form header Nagłówek.

Can I reuse an invoice number? No. The number must uniquely identify a single invoice you issue; a reused number can cause KSeF to reject the document as a duplicate.

Disclaimer

Notaly is not a tax, accounting or legal advisor. This article is general information, not tax advice, and may be outdated. You are responsible for your own VAT compliance; confirm with a qualified accountant where required.

Sources

Source: www.podatki.gov.pl

Frequently asked questions

Where does the invoice number live in FA(3)?

In the Fa element, as the P_2 field. It is not part of the form header Nagłówek.

Can I reuse an invoice number?

No. The number must uniquely identify a single invoice you issue; a reused number can cause KSeF to reject the document as a duplicate.

What is the difference between P_2 and an idempotency key?

P_2 is the invoice number on the document. An idempotency key is your own client-side record used to avoid submitting the same document twice.

Issue your first KSeF test invoice today

Create a sandbox account: API key in seconds, 3 free test invoices on KSeF TEST, no credit card.