Offline invoices
Offline invoicing is a setting on the Legal Entity. Once you turn it on, you send invoices through the usual
POST /invoices/v3 endpoint, and A-Cube issues them in KSeF offline mode.
- The Legal Entity must be onboarded.
- Your account must have the KSeF
InvoiceWritepermission given for that Legal Entity in KSeF. Without it, publishing the invoice is blocked. - Your Legal Entity must have an offline certificate.
Offline cases in KSeF
KSeF allows issuing an invoice offline in these cases. Each one has its own deadline for sending the invoice to KSeF:
| Case | When | Deadline to send the invoice to KSeF |
|---|---|---|
| Offline24 | The issuer decides to issue the invoice offline, for any reason. | The next business day after the issue date. |
| KSeF unavailable | KSeF is unavailable, as announced by the Ministry of Finance. | The next business day after KSeF is available again. |
| KSeF failure | A KSeF failure is announced by the Ministry of Finance. | 7 business days after the end of the failure. |
In all cases the invoice carries the QR code II, signed with the offline certificate.
Offline certificate
Whether you send the certificate depends on how the Legal Entity authenticates with KSeF:
- KSeF token:
certificate,privateKeyandpasswordare required. Without them, the API returns400 Bad Request. - Certificate: you can leave out all the certificate fields. A-Cube then requests an offline certificate from KSeF in the background.
When you send a certificate:
- send
certificate,privateKeyandpasswordtogether; serialNumberis optional, but when you send it, it must match the certificate.
Enable offline mode
Send the offline settings with POST /legal-entities/{legalEntityUuid}/offline:
POST /legal-entities/{legalEntityUuid}/offline
Authorization: Bearer <your-token>
Content-Type: application/json
{
"enabled": true,
"mode": "always",
"name": "My offline certificate",
"serialNumber": "ABC123456789",
"certificate": "<base64 DER certificate>",
"privateKey": "<base64 DER private key>",
"password": "<private key password>"
}
mode sets which invoices are issued offline:
always: every invoice.on_request: only the invoices sent with?offline=true.
With the on_request mode, invoices also fall back to offline automatically when KSeF is unavailable.
Send the invoice
Send the FA (3) invoice as JSON or XML, with the matching Content-Type, as described in Send an invoice.
With the always mode, send it as usual:
POST /invoices/v3
Authorization: Bearer <your-token>
Content-Type: application/xml
<FA (3) invoice XML>
With the on_request mode, add offline=true to the query:
POST /invoices/v3?offline=true
Authorization: Bearer <your-token>
Content-Type: application/xml
<FA (3) invoice XML>
Publish the invoice
- If the
invoiceAutomation.sendingInvoicessetting of the Legal Entity istrue, the invoice is published right away. - Otherwise, publish it by approving it with
POST /invoices/{uuid}:
POST /invoices/{uuid}
Authorization: Bearer <your-token>
If the Legal Entity has no active offline certificate when the invoice is published, the API returns 400 Bad Request:
Legal entity does not have offline invoicing enabled with a valid offline certificate.
Check the result
An invoice issued offline has these fields:
| Field | Value |
|---|---|
invoicingMode | Offline |
ksefInvoiceUrl | QR code I, the link to the invoice in KSeF. |
ksefValidationUrl | QR code II, the certificate check that KSeF requires on offline invoices. |
The PDF or HTML visualization of the invoice prints both QR codes.
Disable offline mode
POST /legal-entities/{legalEntityUuid}/offline
Authorization: Bearer <your-token>
Content-Type: application/json
{
"enabled": false
}