Skip to main content

Send Invoice

POST /invoices/{environment}/send​

Sends an invoice to KSeF in online or offline mode.

Sending Modes​

ModeDescription
onlineInvoice is encrypted and sent directly to KSeF. The endpoint waits for confirmation and returns the KSeF number. Requires an active KSeF session and KSeF availability.
offlineInvoice is signed with an offline certificate and saved to the queue. Requires an active KSeF outage/simulation.

Path Parameters​

ParameterTypeRequiredDescription
environmentstringβœ…test, demo or prod

Request Body​

{
"invoiceXml": "PD94bWwgdmVyc2lvbj0i...",
"mode": "online"
}
FieldTypeRequiredDescription
invoiceXmlstringβœ…Base64-encoded invoice XML content
modestringβœ…online or offline

Response 200 β€” online mode​

{
"mode": "online",
"ksefNumber": "1234567890-20260101-ABCDEF-12",
"referenceNumber": "20260101-AU-XXXXXXXX-XXXX-XX",
"status": "sent",
"invoiceNumber": "FV/2026/01/001"
}
FieldTypeDescription
modestringAlways online
ksefNumberstring | nullKSeF number assigned to the invoice (null if still processing)
referenceNumberstringKSeF session reference number
statusstringsent (KSeF number obtained) or pending (still processing)
invoiceNumberstringInvoice number from XML (P_2 element)
Session Reference

The referenceNumber is automatically saved to synced_invoices.session_reference_number by ksef-proxy. This reference is required to download UPO later via the status endpoint.

Response 200 β€” offline mode​

{
"mode": "offline",
"offlineId": "uuid",
"status": "signed",
"invoiceNumber": "FV/2026/01/001",
"qrLinkInvoice": "https://qr-test.ksef.mf.gov.pl/...",
"qrLinkCertificate": "https://qr-test.ksef.mf.gov.pl/..."
}
FieldTypeDescription
modestringAlways offline
offlineIdstring (uuid)ID of the saved offline invoice
statusstringsigned β€” invoice signed and queued
invoiceNumberstringInvoice number from XML
qrLinkInvoicestring | nullQR verification URL for the invoice
qrLinkCertificatestring | nullQR verification URL for the certificate

Error Codes​

CodeDescription
400Invalid parameters (missing XML, missing mode)
401Unauthorized
404No active KSeF session (online) or certificate (offline)
409Mode conflict β€” e.g. KSeF available with mode=offline or KSeF unavailable with mode=online. Error message includes details about the outage cause (simulation or real outage).
502KSeF error β€” error message is enriched with outage context if applicable
Outage Awareness

All REST API endpoints that communicate with KSeF check the outage/simulation flags before making requests. If an outage or simulation is active, the API returns a 409 error with a descriptive message indicating:

  • Whether it's a simulation (πŸ”§) or a real outage (🚨)
  • Whether the administrator has confirmed the situation
  • That only offline actions are available

If a KSeF request fails and no flags are set, the error message notes that the administrator has not yet confirmed the cause.