Skip to main content

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.

Prerequisites
  1. The Legal Entity must be onboarded.
  2. Your account must have the KSeF InvoiceWrite permission given for that Legal Entity in KSeF. Without it, publishing the invoice is blocked.
  3. 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:

CaseWhenDeadline to send the invoice to KSeF
Offline24The issuer decides to issue the invoice offline, for any reason.The next business day after the issue date.
KSeF unavailableKSeF is unavailable, as announced by the Ministry of Finance.The next business day after KSeF is available again.
KSeF failureA 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, privateKey and password are required. Without them, the API returns 400 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, privateKey and password together;
  • serialNumber is 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.
Automatic fallback

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.sendingInvoices setting of the Legal Entity is true, the invoice is published right away.
  • Otherwise, publish it by approving it with POST /invoices/{uuid}:
POST /invoices/{uuid}
Authorization: Bearer <your-token>
No active offline certificate

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:

FieldValue
invoicingModeOffline
ksefInvoiceUrlQR code I, the link to the invoice in KSeF.
ksefValidationUrlQR 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
}