Skip to main content

Download Documents

GET /invoices/{environment}/{ksefNumber}​

Downloads an invoice document from KSeF in the selected format. Content is returned as base64-encoded string. Requires an active KSeF session.

Path Parameters​

ParameterTypeRequiredDescription
environmentstringβœ…test, demo or prod
ksefNumberstringβœ…KSeF invoice number

Query Parameters​

ParameterTypeDefaultDescription
docTypestringxmlDocument type

Available document types (docType)​

ValueDescriptionContent-Type
xmlKSeF invoice XMLapplication/xml
pdfGenerated invoice PDF (via ksef-pdf-generator with QR)application/pdf
qrQR code image in PNGimage/png
info

docType=pdf generates a full PDF server-side using ksef-pdf-generator, supporting FA(1), FA(2), FA(3) and FA_RR schemas, including QR verification code.

UPO

To download UPO (Official Confirmation of Receipt), use the dedicated endpoint: GET /invoices/{environment}/status/{referenceNumber}/{ksefNumber}/upo

Response 200 β€” XML​

{
"ksefNumber": "1234567890-20260101-ABCDEF-12",
"docType": "xml",
"contentType": "application/xml",
"content": "PD94bWwgdmVyc2lvbj0i...",
"fileName": "1234567890-20260101-ABCDEF-12.xml"
}

Response 200 β€” PDF​

{
"ksefNumber": "1234567890-20260101-ABCDEF-12",
"docType": "pdf",
"contentType": "application/pdf",
"content": "JVBERi0xLjQK...",
"fileName": "1234567890-20260101-ABCDEF-12.pdf",
"qrVerificationUrl": "https://qr-test.ksef.mf.gov.pl/invoice/..."
}

Response 200 β€” QR​

{
"ksefNumber": "1234567890-20260101-ABCDEF-12",
"docType": "qr",
"contentType": "image/png",
"content": "iVBORw0KGgoAAAA...",
"fileName": "1234567890-20260101-ABCDEF-12-qr.png",
"qrVerificationUrl": "https://qr-test.ksef.mf.gov.pl/invoice/..."
}
FieldTypeDescription
ksefNumberstringKSeF invoice number
docTypestringRequested document type (xml, pdf, qr)
contentTypestringMIME type of the content
contentstringBase64-encoded document content
fileNamestringSuggested file name
qrVerificationUrlstringQR verification URL (only for pdf and qr types)

Error Codes​

CodeDescription
400Invalid docType parameter
401Unauthorized
404No active KSeF session or invoice not found
500PDF generation error
502KSeF error