Skip to main content

Downloading invoices

POST /invoices/{environment}​

Searches invoices in KSeF for a given date range. Requires an active KSeF session (prior call to POST /auth/{environment}).

Path Parameters​

ParameterTypeRequiredDescription
environmentstringβœ…test, demo or prod

Request Body​

{
"dateFrom": "2026-01-01 00:00:00",
"dateTo": "2026-01-31 23:59:59",
"subjectType": "sales",
"pageSize": 10,
"pageNr": 1
}
FieldTypeRequiredDefaultDescription
dateFromstringβœ…β€”Start date (yyyy-MM-dd or yyyy-MM-dd HH:mm:ss)
dateTostringβœ…β€”End date (yyyy-MM-dd or yyyy-MM-dd HH:mm:ss)
subjectTypestring❌salesInvoice list type: sales, purchases, thirdParty
pageSizeinteger❌10Invoices per page (1–100)
pageNrinteger❌1Page number (1-based)

Subject Types​

ValueKSeF equivalentDescription
salesSubject1Invoices where your company is the seller (default)
purchasesSubject2Invoices where your company is the buyer
thirdPartySubject3Invoices where your company is a third party

Response 200​

{
"invoices": [
{
"ksefNumber": "1234567890-20260101-ABCDEF-12",
"invoiceNumber": "FV/2026/01/001",
"sellerNip": "9570429696",
"sellerName": "Firma XYZ",
"buyerNip": "1234567890",
"buyerName": "Client ABC",
"netAmount": "1000.00",
"vatAmount": "230.00",
"grossAmount": "1230.00",
"currency": "PLN",
"invoiceType": "VAT",
"issueDate": "2026-01-15 00:00:00"
}
],
"pageNr": 1,
"pageSize": 10,
"hasMore": false
}
FieldTypeDescription
invoicesarrayList of invoice summaries
pageNrintegerCurrent page number
pageSizeintegerNumber of invoices per page
hasMorebooleanWhether more pages are available

Invoice summary fields:

FieldTypeDescription
ksefNumberstringKSeF invoice number
invoiceNumberstringInvoice number (P_2 element)
sellerNipstringSeller NIP number
sellerNamestringSeller company name
buyerNipstringBuyer NIP number
buyerNamestringBuyer company name
netAmountstringNet amount
vatAmountstringVAT amount
grossAmountstringGross amount
currencystringCurrency code (e.g. PLN)
invoiceTypestringInvoice type
issueDatestringIssue date
DB Synchronization

When invoices are fetched from KSeF, ksef-proxy automatically performs data synchronization:

  • Advance invoices (ROZ ↔ ZAL) β€” detected and linked via advance_groups / advance_group_invoices
  • Correction invoices (KOR) β€” linked to original invoices via invoice_corrections
  • Sync metadata β€” invoice_sync_meta is updated with the last sync timestamp and unread count

Error Codes​

CodeDescription
400Invalid parameters (missing dates, wrong format)
401Unauthorized
404No active KSeF session
502KSeF error