How to read KSeF error codes without guessing?

A KSeF response consists of three layers: the HTTP status, the exceptionCode, and the invoice status. Understanding these layers helps determine whether a message requires technical XML validation fixes or accounting action.

9 min read 226 views
How to read KSeF error codes without guessing?

KSeF (Poland's national e-invoicing system) answers with a number and one sentence, and within the same minute someone has to choose between three very different actions: fix the XML, retry the request, or hand the case to accounting. Three decisions, three costs, three deadlines.

Under the current act, penalties under Article 106ni of the VAT Act apply from 1 January 2027. On 16 September 2026 the Ministry of Finance announced it will move them to 1 January 2028; that is a bill not yet passed, and it moves only the penalties, not the obligation to use KSeF. Either way, an invoice that never reached the system stops being a technical problem and becomes a financial one. If you run a Polish entity or a Polish subsidiary, the thing worth building in the meantime is a procedure for reading gateway messages — not a habit of pasting codes into a search box.

This is the map: how a KSeF response is structured, what each code family covers, which codes are safe to simply retry, and where the handover from engineering to accounting actually sits. The complete list of codes is published by the Ministry of Finance in the API documentation; here we cover the ones you will meet most often.

A KSeF message has three layers, not one

An error number without context is useless. The same 21405 can mean a malformed query parameter one day and a badly mapped ERP field the next. Read every response on three levels:

  1. HTTP status — whether the gateway accepted the request at all.

  2. exceptionCode and exceptionDescription — the specific reason on the KSeF side.

  3. Invoice or session status — whether the document already carries a KSeF number, or does not exist in the system yet.

Only together do these say whose problem it is. Layers one and two belong to the integration. Layer three belongs to accounting, because that is where the decision about a correcting invoice is made.

Two identifiers deserve to be logged every single time: the operation's referenceNumber and the response's traceId. Without them, a ticket to the Ministry of Finance or to your software vendor is an anecdote rather than a report.

Code families: what the leading digits tell you

KSeF 2.0 numbering is not arbitrary. The leading digits point at the subsystem that rejected the request — enough to route the case to the right person in seconds.

FamilyAreaWho fixes it
9xxxsignature and authorisation documentintegrator
211xxauthentication, sessions, invoice retrieval, exportintegrator
212xxbatch package and its partsintegrator
213xxauthorisation and access tokenscompany administrator
214xxdocument and input-data validationintegrator or invoice issuer
250xxKSeF certificatescompany administrator
260xxKSeF tokenscompany administrator

Rule of thumb: anything below 214xx is usually configuration, not the invoice. Editing a document in response to an authentication error is the most common way to lose an hour.

HTTP statuses: the first branch

StatusMeaningResponse
400malformed request or input-data validation failureread exceptionCode and the errors list in the payload
401authentication missing or invalidtoken, certificate, session validity
403insufficient permissions or disallowed contextNIP (Polish tax ID) context and the permission scope for that operation
410the operation has expired and is no longer availablestart the process again
415operation type not allowed in this submission modeswitch modes (see the case below)
429API rate limit exceededRetry-After, queueing, backoff — do not touch the invoice
5xxfailure on the KSeF infrastructure sidecapture traceId, retry per your retry policy

Note that 410 and 415 also appear as invoice processing statuses inside a session, not as the HTTP code of the response — the case below is one of those statuses. The most expensive misreading in this table is 429. Under real API limits it is easy to treat it as a document rejection and start "fixing" a perfectly valid invoice. Current limits are published in the CIRF/MF documentation.

The most frequent codes and what they mean

Signature and authorisation document (9xxx)

CodeMessageAction
9101Invalid documentcheck the document used in the signing process
9102Signature missingthe required signature was not attached
9103Too many signaturesverify the signature count for this document type

Sessions, invoices and export (211xx)

CodeMessageAction
21111Invalid authorisation challengechallenge, encryption and timing in the auth flow
21115Invalid certificatevalidity and compliance with KSeF requirements
21117Invalid subject identifier for the context typethe NIP does not match the selected context type
21155Invoice limit for the session exceededclose the session and open a new one
21157Invalid package part sizedeclared part size ≠ actual file
21161Too many package partsrebuild the batch package
21164Invoice with the given identifier does not existKSeF number, subject context, retrieval permissions
21165Invoice not available yetnot an error — wait and poll again
21166Technical correction unavailableit has most likely already been processed
21167Invoice status does not allow a technical correctionan accounting case, not an integration one
21173No session with that reference numberreference number or environment (test vs. production)
21175Query result does not existexport reference, or the result's availability window expired
21178No UPO found for the given criteriathe UPO (official receipt confirmation) is issued after the session closes — retry later
21180Session status does not allow the operationsession closed or cancelled
21181Invalid invoice export requestexport criteria and subject context
21182Concurrent export limit reachedreduce parallel exports
21183Filter range outside the available data rangedate range and date type

Batch package (212xx)

CodeMessageAction
21205Package must not be emptynot all declared parts were uploaded
21208Upload or finish timeout exceededthe session may have been cancelled — repeat the process
21217Invalid character encodingUTF-8, no BOM

Authentication and authorisation (213xx)

CodeMessageAction
21301Not authorisedtoken revoked, or the authentication operation never completed
21304Not authenticatedno operation with that reference number in this environment
21308Attempt to use the authorisation methods of a deceased personthe entity's authentication path has to change

Document and input validation (214xx)

CodeMessageAction
21401Document does not conform to the XSD schemathe classic "invoice error": FA(3) structure, mandatory fields, encoding
21402Invalid file sizedeclared size ≠ actual content length
21403Invalid file hashhow the hash is computed
21405Input-data validation errorread the details, not the number — the code alone says nothing
21406Signature and authentication type conflictauth method vs. certificate type
21418Invalid continuation token formatnever edit the pagination token by hand
21470Unknown or withdrawn key identifierfetch the current public key for your environment

Certificates and tokens (250xx, 260xx)

CodeMessageAction
25001CSR data cannot be retrieved for this authentication methodchange the authentication method
25002Certificate request cannot be submitted for this methodas above
25003CSR data does not match the authentication vectorsubject data inside the CSR
25004Invalid CSR format or signaturerequest format and signing algorithm
25005Certificate request with that reference number does not existreference number and environment
25006Certificate request limit reachedclean up outstanding requests
25007Held-certificate limit reachedrevoke unused certificates
25010Invalid key type or lengthkey requirements in the certificate docs
25011Invalid CSR signing algorithmalgorithm and hash function
26001Cannot grant a token permissions the subject does not holdfix the subject's permissions first
26002Cannot issue a token for the current context typetokens are issued only in permitted contexts

The KSeF 2.0 catalogue is larger than the list above; the source of truth remains the API documentation at api.ksef.mf.gov.pl and the CIRF/MF integrator guide.

Same document, two different answers: a case from our own rollout

On 10 September 2026, on the Ministry's test environment, we were testing invoices with attachments. The same invoice submitted through an interactive session came back with processing status 415 and a message stating that an invoice with an attachment cannot be sent that way. The same invoice in a batch session was accepted. And the same interactive session accepted the same invoice once the attachment node was removed.

The uncomfortable but useful conclusion: some messages do not say "this document is wrong" — they say "not through this channel". Anyone who had started by editing the XML would have been editing a valid file. The differences between modes are documented in the batch session guide.

An error does not always mean the invoice is missing

The costliest mistakes happen on the other side of the line: when the invoice already has a KSeF number.

Acceptance by the gateway means conformity with the logical structure, and nothing more. KSeF does not check VAT treatment, commercial substance, or arithmetic. An invoice with the wrong rate can pass technical validation without a single message.

The practical consequence: a document that received a KSeF number cannot be withdrawn or overwritten from your sales system. What remains is a correcting invoice. A technical correction applies only to an offline invoice that KSeF rejected — you cannot use it to fix a document that already has a KSeF number. That is an accounting decision, not an integration one, which is exactly why the third layer of the message must never be skipped.

Duplicates are a separate trap. KSeF identifies them from a combination of seller data, invoice type and document number, and keeps uniqueness for years — resending "just in case" is not a neutral act.

Checklist: what to capture for every error

  1. HTTP status of the response.

  2. exceptionCode and the full exceptionDescription.

  3. referenceNumber of the operation (session, request, export).

  4. traceId from the response.

  5. Environment: test or production.

  6. Invoice status: was a KSeF number assigned.

  7. UTC timestamp — with rate limits and sessions, the second matters.

Those seven fields turn "it doesn't work on our side" into something that can actually be investigated. Reporting paths are described on the integrator support page.

Summary

KSeF error codes look like a purely technical topic, yet they settle accounting questions: whether the invoice exists, whether the deadline was met, whether a correction is required. Three layers of the response, the family map and seven checklist fields are enough to stop guessing.

Biurko translates the 28 most common gateway codes into one plain sentence and one suggested action and shows the rest as the Ministry's own text, and it retries transient failures automatically (up to three attempts; after a 429 it waits the time the gateway names). Try Biurko — every new company gets 14 days of the TEAM plan without a card and see what submitting to KSeF looks like when nobody has to read numbers.

FAQ

What does KSeF error 21401 mean? The document does not conform to the XSD schema. In practice it usually comes down to the FA(3) structure, an empty mandatory field, or encoding other than UTF-8 without BOM. The number itself does not identify the field — the validator message returned alongside it does.

Does a 429 error mean my invoice was rejected? No. It signals that the API rate limit was exceeded and concerns the integration only. The invoice is fine. The fix is reading the Retry-After header, queueing requests and applying exponential backoff — not editing the document.

If KSeF accepts an invoice, is the invoice correct? No. The system validates conformity with the logical structure and the technical soundness of the file. It does not verify VAT settlement or arithmetic. An invoice with a substantive error can receive a KSeF number and need a correction later.

Where is the official list of KSeF error codes? The source of truth is the OpenAPI contract and the API 2.0 documentation on api.ksef.mf.gov.pl, together with the CIRF/MF repository holding the integrator guide and the changelog, where the Ministry publishes newly added codes.

What if an invoice already has a KSeF number but contains an error? It cannot be deleted or overwritten. The route is a correcting invoice; a technical correction applies only to an offline invoice that KSeF rejected.

Tags

#KSeF
Share

Previous article

How much does an accountant cost for a Polish JDG?

Next article

How will the 2027 minimum wage affect your ZUS in Poland?

Stay in the loop

An email when we publish a new article — and nothing else.

We respect your privacy. Unsubscribe at any time.

Cookies

We use only essential cookies. Visit statistics are kept on our server, with nothing saved on your device. Website Policy