Skip to content
Log in

JSON Invoice Fields to KSeF FA(3) XML

This guide details the mapping between the B2Brouter Invoice API fields, the corresponding Business Terms (BT) as defined by the European e-Invoicing standard (EN 16931), and the XML paths in the KSeF FA(3) format (Polish National e-Invoice System).

Its purpose is to help understand how invoice data submitted in JSON format via the Invoice API corresponds to the KSeF FA(3) XML structure. Only fields that are actually mapped during tax report generation are included.

BT IDBusiness TermAPI Field (B2Brouter)KSeF FA(3) XPath
BT-1Invoice Numberinvoice.numberFa/P_2
BT-2Invoice Issue Dateinvoice.dateFa/P_1
BT-3Invoice Type Codeinvoice.type_document Derived: defaults to VAT; KOR if amended invoice; ZAL if advance; UPR if simplifiedFa/RodzajFaktury
BT-5Invoice Currencyinvoice.currencyFa/KodWaluty
BT-7Tax Point Dateinvoice.tax_point_dateFa/P_6
BT-9Payment Due Dateinvoice.due_dateFa/Platnosc/TerminPlatnosci/Termin
BT-25Preceding Invoice Numberinvoice.invoice_references[reference_type=amend].number (v2026-04-20+) or invoice.amended_number (older versions)Fa/DaneFaKorygowanej/NrFaKorygowanej
BT-26Preceding Invoice Issue Dateinvoice.invoice_references[reference_type=amend].date (v2026-04-20+) or invoice.amended_date (older versions)Fa/DaneFaKorygowanej/DataWystFaKorygowanej
Exchange Rateinvoice.exchange_rateFa/KursWalutyZ
BT-10Buyer Referenceinvoice.buyer_referencePodmiot2/NrKlienta
BT-13Purchase Order Referenceinvoice.ponumberFa/WarunkiTransakcji/Zamowienia/NrZamowienia
BT-92Purchase Order Dateinvoice.order_dateFa/WarunkiTransakcji/Zamowienia/DataZamowienia
BT-14Sales Order Referenceinvoice.sales_order_referenceFa/DodatkowyOpis (key-value pair)
BT-16Despatch Advice Referenceinvoice.delivery_note_numberFa/WZ
Correction Effect Codeinvoice.amend_code_tax or tax_report_setting.credit_note_codeFa/TypKorekty (only for KOR types)
BT IDBusiness TermAPI Field (B2Brouter)KSeF FA(3) XPath
BT-9Payment Due Dateinvoice.due_dateFa/Platnosc/TerminPlatnosci/Termin
BT-81Payment Means Codeinvoice.payment_method (mapped to KSeF codes)Fa/Platnosc/FormaPlatnosci
BT-84Payee Financial Account IBANinvoice.bank_account.ibanFa/Platnosc/RachunekBankowy/NrRB
BT-84-0Payee Financial Account Numberinvoice.bank_account.number (fallback if no IBAN)Fa/Platnosc/RachunekBankowy/NrRB
BT-85Payee Financial Account Nameinvoice.bank_account.nameFa/Platnosc/RachunekBankowy/NazwaBanku
BT-86Payee Financial Account BICinvoice.bank_account.bicFa/Platnosc/RachunekBankowy/SWIFT
Paid FlagDerived: 1 when payable_amount = 0 and total > 0Fa/Platnosc/Zaplacono
Payment Date (when paid)invoice.due_date (when Zaplacono=1)Fa/Platnosc/DataZaplaty

Note: KSeF does not support card account details (BT-87, BT-88), direct debit mandates (BT-89), creditor references (BT-90), payment terms text (BT-20), or remittance information (BT-83).

This mapping is described for an issued invoice. If you want to map a received invoice, swap Podmiot1 and Podmiot2.

The Podmiot1 is automatically populated based on your account settings. This includes company name, NIP (Polish tax ID), and address.

BT IDBusiness TermAPI Field (B2Brouter)KSeF FA(3) XPath
Seller Country Prefixaccount.country (uppercased)Podmiot1/PrefiksPodatnika
BT-31Seller Tax Registration ID (NIP)account.tin_value (without country prefix)Podmiot1/DaneIdentyfikacyjne/NIP
BT-27Seller Party Nameaccount.namePodmiot1/DaneIdentyfikacyjne/Nazwa
BT-40Seller Address Countryaccount.country (uppercased)Podmiot1/Adres/KodKraju
BT-35Seller Address Streetaccount.addressPodmiot1/Adres/AdresL1
BT-37,38Seller Postal Code + Cityaccount.postalcode + account.cityPodmiot1/Adres/AdresL2
BT-29-0Seller GLNaccount.cin_value (if cin_scheme = 88)Podmiot1/Adres/GLN
BT-42Seller Contact Telephoneaccount.phonePodmiot1/DaneKontaktowe/Telefon
BT-43Seller Contact Emailaccount.emailPodmiot1/DaneKontaktowe/Email
Seller REGONaccount.routing_codes.cinX (scheme 8037)Stopka/Rejestry/REGON
Seller KRSaccount.routing_codes.cinX (scheme 8036)Stopka/Rejestry/KRS
Seller BDOaccount.routing_codes.cinX (scheme 8038)Stopka/Rejestry/BDO
BT IDBusiness TermAPI Field (B2Brouter)KSeF FA(3) XPath
BT-48Buyer Tax Registration IDinvoice.contact.tin_valuePL: Podmiot2/DaneIdentyfikacyjne/NIP
EU: Podmiot2/DaneIdentyfikacyjne/NrVatUE
Non-EU: Podmiot2/DaneIdentyfikacyjne/NrID
Buyer Tax Country (EU)invoice.contact.country (uppercased)Podmiot2/DaneIdentyfikacyjne/KodUE (EU only)
Buyer Tax Country (Non-EU)invoice.contact.country (uppercased)Podmiot2/DaneIdentyfikacyjne/KodKraju (non-EU only)
No Tax ID FlagDerived: 1 when contact.tin_value is blankPodmiot2/DaneIdentyfikacyjne/BrakID
BT-44Buyer Party Nameinvoice.contact.namePodmiot2/DaneIdentyfikacyjne/Nazwa
BT-55Buyer Address Countryinvoice.contact.country (uppercased)Podmiot2/Adres/KodKraju
BT-50Buyer Address Streetinvoice.contact.addressPodmiot2/Adres/AdresL1
BT-52,53Buyer Postal Code + Cityinvoice.contact.postalcode + invoice.contact.cityPodmiot2/Adres/AdresL2
BT-46-0Buyer GLNinvoice.contact.cin_value (if cin_scheme = 88)Podmiot2/Adres/GLN

KSeF supports multiple third-party roles via the Podmiot3 element. A Podmiot3 is generated when delivery information is present or when the invoice has a third_party object (available from v2026-04-20).

Role CodeB2Brouter third_party.roleDescription
2delivery_recipientDelivery recipient
3original_supplierOriginal entity (taken over/transformed)
4additional_buyerAdditional purchaser
5invoice_issuerInvoice issuer on behalf of taxpayer
6payerPayer on behalf of purchaser
7local_government_unit_issuerLocal government unit — issuer
8local_government_unit_recipientLocal government unit — recipient (JST)
9vat_group_member_issuerVAT group member — issuer
10vat_group_member_recipientVAT group member — recipient (GV)
11employeeEmployee

Delivery information is mapped to Podmiot3 with role code 2 when invoice.delivery_address is present. The delivery address is also duplicated under Fa/WarunkiTransakcji/Transport/WysylkaDo.

BT IDBusiness TermAPI Field (B2Brouter)KSeF FA(3) XPath
BT-70Delivery Party Nameinvoice.delivery_party_namePodmiot3/DaneIdentyfikacyjne/Nazwa
BT-71Delivery Location ID (GLN)invoice.delivery_location_id (if type is GLN/088)Podmiot3/Adres/GLN
BT-75Delivery Address Streetinvoice.delivery_addressPodmiot3/Adres/AdresL1 and Fa/WarunkiTransakcji/Transport/WysylkaDo/AdresL1
BT-77,78Delivery Postal Code + Cityinvoice.delivery_postalcode + invoice.delivery_cityPodmiot3/Adres/AdresL2 and Fa/WarunkiTransakcji/Transport/WysylkaDo/AdresL2
BT-80Delivery Countryinvoice.delivery_countryPodmiot3/Adres/KodKraju and Fa/WarunkiTransakcji/Transport/WysylkaDo/KodKraju
Third Party RoleFixed: 2 (Recipient)Podmiot3/Rola

Note: KSeF does not support delivery date (BT-72) or delivery period fields.

JST / GV / Other Roles (Roles 3–11) — v2026-04-20+

Section titled “JST / GV / Other Roles (Roles 3–11) — v2026-04-20+”
Business TermAPI Field (B2Brouter)KSeF FA(3) XPath
Third Party Nameinvoice.third_party.namePodmiot3/DaneIdentyfikacyjne/Nazwa
Third Party Tax IDinvoice.third_party.tin_valuePodmiot3/DaneIdentyfikacyjne/NIP (PL), NrVatUE (EU), or NrID (non-EU)
Third Party Addressinvoice.third_party.addressPodmiot3/Adres/AdresL1
Third Party Postal Code + Cityinvoice.third_party.postalcode + invoice.third_party.cityPodmiot3/Adres/AdresL2
Third Party Countryinvoice.third_party.countryPodmiot3/Adres/KodKraju
Third Party Roleinvoice.third_party.role → role codePodmiot3/Rola
JST flaginvoice.apply_to_local_government_unitPodmiot2/JST (1 when true, 2 when false)
GV flaginvoice.apply_to_vat_group_memberPodmiot2/GV (1 when true, 2 when false)

All attributes listed in the following table are properties of objects contained in the array: invoice.invoice_lines_attributes[]. The API Field column refers to keys within each invoice line object.

For regular invoices (VAT, KOR, UPR, ROZ), lines are rendered as FaWiersz elements. For advance payment invoices (ZAL, KOR_ZAL), lines are rendered as ZamowienieWiersz elements.

BT IDBusiness TermAPI Field (invoice line object)KSeF FA(3) XPath
BT-126Invoice Line IDpositionFa/FaWiersz/NrWierszaFa
BT-153Item NamedescriptionFa/FaWiersz/P_7
BT-130Billed Quantity (Unit Code)unit (check API Reference for code list)Fa/FaWiersz/P_8A
BT-129Billed QuantityquantityFa/FaWiersz/P_8B
BT-155Item Seller Identifierarticle_codeFa/FaWiersz/Indeks
BT-157Item Standard Identifier (GTIN)article_code2Fa/FaWiersz/GTIN
BT-146Price AmountpriceFa/FaWiersz/P_9A
-Discount Unit PriceDerived from line allowance_charges_attributes[]{allowance_charge_indicator: "allowance"} amount / quantityFa/FaWiersz/P_10
BT-131Line Net Amountextension_amount (if not provided, it will be calculated)Fa/FaWiersz/P_11
Line Tax AmountComputed from taxesFa/FaWiersz/P_11Vat
Tax CodeDerived from tax characteristicsFa/FaWiersz/P_12

Additional Item Properties Mapping (DodatkowyOpis per Line)

Section titled “Additional Item Properties Mapping (DodatkowyOpis per Line)”

Each invoice line can carry additional key-value properties that map to line-level DodatkowyOpis elements in the KSeF XML.

All attributes listed in the following table are properties of objects contained in the array: invoice.invoice_lines_attributes[].additional_item_properties_attributes[].

BT IDBusiness TermAPI Field (additional item property object)KSeF FA(3) XPath
Line Number ReferenceParent line’s positionFa/DodatkowyOpis/NrWiersza
BT-160Item Attribute Namename (max 255 chars)Fa/DodatkowyOpis/Klucz
BT-161Item Attribute Valuevalue (max 255 chars)Fa/DodatkowyOpis/Wartosc

Example JSON:

{
"invoice": {
"invoice_lines_attributes": [
{
"position": 1,
"description": "Product A",
"additional_item_properties_attributes": [
{ "name": "Color", "value": "Red" },
{ "name": "Size", "value": "XL" }
]
}
]
}
}

Resulting KSeF XML:

<tns:DodatkowyOpis>
<tns:NrWiersza>1</tns:NrWiersza>
<tns:Klucz>Color</tns:Klucz>
<tns:Wartosc>Red</tns:Wartosc>
</tns:DodatkowyOpis>
<tns:DodatkowyOpis>
<tns:NrWiersza>1</tns:NrWiersza>
<tns:Klucz>Size</tns:Klucz>
<tns:Wartosc>XL</tns:Wartosc>
</tns:DodatkowyOpis>

Setting an additional item property with name unit_of_measure allows you to specify a free-text unit code for the line’s P_8A field in KSeF, overriding the standard unit codelist.

{
"additional_item_properties_attributes": [
{ "name": "unit_of_measure", "value": "szt." }
]
}

This property is consumed directly as the line’s unit code (Fa/FaWiersz/P_8A) and is not emitted as a DodatkowyOpis element in the XML output.

All attributes listed in the following table are properties of objects contained in the array: invoice.invoice_lines_attributes[].taxes_attributes[].

BT IDBusiness TermAPI Field (tax object)KSeF FA(3) Mapping
BT-118Tax Category Codecategory (check our code list)Used to derive P_12 tax code
BT-119Tax Rate Applicable PercentpercentUsed to derive P_12 tax code and P_13_x/P_14_x aggregations
BT-120Tax Exemption ReasoncommentFa/Adnotacje/Zwolnienie/P_19A. Also accepts a KSeF P_12 code (zw, np I, np II, 0 KR, 0 WDT, 0 EX, oo) to override the derived value.

Tax Breakdown Aggregation (P_13_x / P_14_x)

Section titled “Tax Breakdown Aggregation (P_13_x / P_14_x)”

KSeF requires tax amounts to be aggregated by rate at the header level. These fields are automatically computed from the invoice’s tax breakdowns:

KSeF FieldDescriptionTax Rate / Category
P_13_1Taxable base at basic rate23% or 22%
P_14_1Tax amount at basic rate23% or 22%
P_14_1WTax amount at basic rate converted to PLN23% or 22% (foreign currency invoices only)
P_13_2Taxable base at first reduced rate8% or 7%
P_14_2Tax amount at first reduced rate8% or 7%
P_14_2WTax amount at first reduced rate converted to PLN8% or 7% (foreign currency invoices only)
P_13_3Taxable base at second reduced rate5%
P_14_3Tax amount at second reduced rate5%
P_14_3WTax amount at second reduced rate converted to PLN5% (foreign currency invoices only)
P_13_6_1Total value of domestic zero-rated sales0% domestic (excluding intra-EU and export)
P_13_6_2Total value of intra-Community supply of goods at 0%0% intra-EU goods
P_13_6_3Total value of exports at 0%0% export
P_13_7Total value of exempt salesExempt (category E, domestic scope)
P_13_8Total value of cross-border reverse charge (np I)Category AE, non-domestic scope
P_13_10Total value of domestic reverse chargeCategory AE, domestic scope
P_15Total amount due (inclusive of all taxes)Sum of all categories