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β
| Parameter | Type | Required | Description |
|---|---|---|---|
environment | string | β | test, demo or prod |
ksefNumber | string | β | KSeF invoice number |
Query Parametersβ
| Parameter | Type | Default | Description |
|---|---|---|---|
docType | string | xml | Document type |
Available document types (docType)β
| Value | Description | Content-Type |
|---|---|---|
xml | KSeF invoice XML | application/xml |
pdf | Generated invoice PDF (via ksef-pdf-generator with QR) | application/pdf |
qr | QR code image in PNG | image/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/..."
}
| Field | Type | Description |
|---|---|---|
ksefNumber | string | KSeF invoice number |
docType | string | Requested document type (xml, pdf, qr) |
contentType | string | MIME type of the content |
content | string | Base64-encoded document content |
fileName | string | Suggested file name |
qrVerificationUrl | string | QR verification URL (only for pdf and qr types) |
Error Codesβ
| Code | Description |
|---|---|
| 400 | Invalid docType parameter |
| 401 | Unauthorized |
| 404 | No active KSeF session or invoice not found |
| 500 | PDF generation error |
| 502 | KSeF error |