Integrating an ERP system with KSeF step by step
Plan invoice submission and retrieval, divide responsibilities between accounting and IT, and verify the implementation after errors and restarts as well.

Article summary
ERP integration with Poland's National e-Invoicing System, KSeF (Krajowy System e-Faktur), should link the document in the ERP system to its processing outcome, KSeF number and official receipt, UPO (Urzędowe Poświadczenie Odbioru). A separate process must retrieve purchase invoices and route them for approval or posting to the accounts.
Before choosing a solution, check the exact ERP version, extensions and invoice types. A vendor connector, middleware and a custom API connection can work together within a single architecture.
Submission starts processing. Only the final outcome allows an invoice to be marked as accepted. If a response is lost, first reconcile the outcome of the previous operation instead of submitting the document again.
Accept the implementation on the basis of error-handling, recovery and purchase-invoice completeness tests. Offline procedures have different deadlines; a local Internet connection problem is not an officially announced KSeF outage.
Contents
Step 1. Define the document scope and process owners
Start with a list of companies, taxpayer contexts and the systems in which invoices originate. Separate domestic business-to-business sales, consumer sales, international transactions, advance payment invoices, corrective invoices and self-billing. Include cases handled by ERP extensions, rather than just the standard sales form.
The KSeF obligation depends on the taxpayer and the document. VAT exemption does not automatically exclude a taxpayer, while submitting consumer invoices to KSeF is optional. Agree on the rules with accounting; a Polish tax identification number (NIP) or the invoice currency alone does not determine whether a transaction falls within scope.
Accounting approves the tax rules and invoice data. The ERP administrator confirms the data sources and the compatibility of the version and extensions. The integrator is responsible for transport, statuses and recovery. Also designate someone to respond to a queue backlog and a team to approve purchases.
The deliverable is a signed-off matrix covering document type, data source, issuance method, recipient, owner and acceptance criterion. Submitting sales invoices and retrieving purchase invoices have separate requirements. Do not postpone retrieval until submission goes live.
Step 2. Choose a connector, middleware or a custom integration
Ask the supplier to confirm compatibility with the specific ERP product family and version, updates, modules and custom modifications. A general statement that KSeF is supported does not establish which corrective invoices are covered, whether purchase invoices can be retrieved or how the KSeF number is stored against the document.
A connector is a ready-made connection module, usually maintained by the vendor or a partner. Middleware is an intermediary layer between systems that can manage queues and mapping. A custom integration requires a team to maintain the entire API communication lifecycle. Middleware can use a connector, so these options are not necessarily mutually exclusive.
The deliverable is a data-flow diagram and an agreement defining responsibilities. For every handoff, specify where data is persistently stored, who fixes errors and how the data returns to the ERP system. Before purchasing, request a demonstration using a set of your own anonymized scenarios.
| Option | When to consider it | What to confirm before choosing |
|---|---|---|
| ERP connector | Your processes fall within the scope supported by the vendor. | ERP version, modules, purchase invoice retrieval, statuses, offline modes, updates and extensions. |
| Middleware | Several systems or companies require centralized oversight and data transformation. | Responsibility for mapping, archiving, reconciliation and recording the outcome in each ERP system. |
| Custom API integration | Non-standard processes justify developing and continuously maintaining code. | Maintenance team, monitoring, credentials, contract changes and regression tests. |
Step 3. Set up access, permissions and separate environments
Authentication confirms identity. Permissions determine which operations are available in a given context. Test issuance and read access separately, including after a permission is revoked. Successful login alone is not sufficient to sign off this stage.
A type 1 KSeF certificate is used for authentication. Type 2 confirms the issuer in the applicable offline procedures. A certificate does not grant permissions. A KSeF token is a different credential from the short-lived access token obtained during API communication.
Poland's Ministry of Finance (MF) states that KSeF tokens will continue to be supported indefinitely. When choosing an access method, check the current implementing regulations and API documentation. For the method you use, appoint an owner responsible for renewing, revoking and securely storing credentials. Secrets and full invoice data should not appear in ordinary diagnostic logs.
TEST, DEMO and PROD must have separate configurations, queues, archives and synchronization checkpoints. Use anonymized data in TEST. DEMO uses real authentication credentials and permissions, but its invoices have no legal effect. PROD is for genuine documents, not fictitious test invoices.
The deliverable is verified access in every required context, together with a test of losing and restoring access. Before going live, compare the actual production API contract with the contract used in testing. Planned deployment dates in the changelog do not replace this check.
Step 4. Map ERP data to the invoice structure
FA(3) has been the structure for standard structured invoices since February 1, 2026. KSeF receives XML, rather than a PDF or spreadsheet. Prepare a separate data map and example for every supported invoice type; successfully mapping an ordinary sales invoice does not demonstrate support for advance payment or corrective invoices.
For each mapping, record the ERP source field, the structure element, the transformation rule, the condition for populating the field and the approver. Include the parties' details, dates, invoice number, currency, line items, rates, amounts, payments and links to earlier invoices. Define what to do when data is missing.
XSD validation checks compliance with the schema. Check business and tax rules separately: consistent totals, rounding, transaction classification and the correctness of a correction. Distinguish between fields required by the schema, alternative variants and fields required only in a specific case.
The deliverable is an approved mapping and a set of test documents covering every declared scenario. For each rejected document, the user should be shown the reason and where to make the correction. The guide to XML and FA(3) explains the basics of the format.
Check your data before enabling submission
Review the import and data-exchange options available in KSeFGPT. Confirm the scope of the connection to your ERP system separately.
Check available integrationsStep 5. Link sales invoices to their outcome, KSeF number and UPO
The sales workflow includes preparing and validating XML, opening a session and encrypting the data, submitting invoices, checking the outcome for each invoice and storing its KSeF number and UPO. Acceptance of a request for processing does not mean that the invoice has been accepted. In a session containing multiple documents, some may be accepted and others rejected.
Retain the exact XML that was submitted, together with its hash. A persistent operation register should link the ERP invoice to the submission attempt, references and outcome. The issuer's invoice number, technical references and KSeF number are different identifiers.
Keep the following states separate: prepared, submitted and processing, outcome unknown, rejected, accepted, and UPO archived. An accepted invoice with a missing UPO requires retrieval of the receipt, not resubmission. UPO confirms receipt by KSeF; it does not confirm acceptance of the delivery, posting to the accounts or payment.
The deliverable is the ability to trace the history of a single invoice without searching through unrelated logs. After acceptance, changing the data requires the appropriate corrective-invoice workflow rather than overwriting the accepted XML.
| Register data | Purpose |
|---|---|
| ERP identifier and issuer's invoice number | Linking to the source document. |
| Environment, context and operation identifier | Separating companies and controlling retries. |
| Original XML and its hash | Comparing the exact document submitted. |
| Session and invoice references | Checking status after a restart or a lost response. |
| Outcome, KSeF number, dates and UPO | Confirming acceptance and supporting subsequent reconciliation with the ERP system. |
Step 6. Enable independent purchase invoice retrieval
Purchase invoices are retrieved from KSeF for the appropriate entity context and roles. The buyer does not resubmit a purchase invoice received from the system as its own sales invoice. After retrieval, retain the XML and metadata, identify the counterparty and any links between corrective invoices and original documents, then route the document to the appropriate ERP workflow.
For receipt through KSeF, the receipt date is generally the day on which the KSeF number is assigned, not the date of a later import. Emergency modes and delivery to specified recipients outside the system follow separate rules. Retrieving an invoice does not mean that the cost has been approved or that VAT may be deducted.
Incremental retrieval requires a safe completeness boundary. MF documentation describes the permanent storage date, PermanentStorage, and the HWM marker defining the range of available documents. Do not replace it with the time on a local clock or the invoice issue date.
Handle every page, export part and truncated range. Documents at range boundaries may appear again, so deduplicate by KSeF number within the correct environment and context. Advance the synchronization checkpoint only after the entire processed range has been persistently stored.
The deliverable is a reconciled set of purchase invoices that remains complete after delayed storage, repeated retrieval and an import failure. A single invoice visible under several roles should not create several payment liabilities.
Step 7. Handle errors without duplicate submissions
For example, the ERP system requested submission and KSeF started processing, but the connection dropped before the response arrived. Record the outcome as unknown. If you have an invoice reference, read its status; if you have only a session reference, reconcile the documents in that session. Do not create modified XML solely to retry transport.
Run retries from the persistent register, with a single active worker for each document. Duplicate status code 440 is an invoice-processing status, not an HTTP status code. Use the returned link to the original document. Local checks are still needed: the same invoice from a business perspective may contain different technical data.
For HTTP 429, respect the waiting time specified by Retry-After and throttle the relevant request group. An XML error requires data correction. Missing permissions require administrator intervention. Transient read errors can be retried with increasing intervals; every attempt should retain references and progress.
The deliverable is a controlled intervention queue and reconciliation between the ERP system, the register and KSeF. A process restart should resume submission, polling or retrieval according to the stored state. Restoring an older database backup requires reconciling documents accepted after that backup was created.
Step 8. Distinguish offline24, unavailability and outages
The procedure depends on the cause and the official announcement. Offline24 may also be used at the taxpayer's discretion or when there is an Internet connection problem. A local ERP failure does not automatically entitle you to the deadline that applies to an officially announced KSeF outage.
The deadlines below reflect MF information checked on October 15, 2026. Offline24 does not mean 24 clock hours. The queue must calculate working days, track announcements and raise alerts before deadlines expire. If another outage is announced in the meantime, apply the relevant rules for switching between modes.
In offline24, during unavailability and in emergency mode, the issue date is the date entered in field P_1. The receipt date depends on the mode and the recipient category. For domestic receipt through KSeF under offline24 and during unavailability, it is generally the date the KSeF number is assigned; in emergency mode, it is generally the earlier of actual receipt and assignment of the number.
When delivering an invoice before its subsequent submission to KSeF to recipients specified in Article 106gb(4) of the Polish VAT Act, the appropriate OFFLINE and CERTYFIKAT markings are required, using a type 2 certificate. For a domestic buyer with a NIP, MF describes a transaction confirmation that is not an invoice. After acceptance, an invoice visualization delivered outside KSeF carries a QR code with the KSeF number. A complete outage requires neither a KSeF QR code nor subsequent submission of the invoice.
The deliverable is an employee procedure explaining how to choose the mode, what to provide to the recipient, when to submit the document and who monitors the deadline. Merely storing XML in a queue does not complete this stage.
| Mode | Trigger | Deadline for subsequent submission |
|---|---|---|
| Offline24 | Taxpayer's choice or a local communication problem. | Without delay, no later than the next working day after issuance. |
| KSeF unavailability | Announced unavailability, for example maintenance work. | No later than the next working day after the unavailability ends. |
| Emergency mode | An outage announced in the MF Public Information Bulletin (BIP) and the interface software. | Within 7 working days after the outage ends. |
| Complete outage | An official announcement in the mass media. | No obligation to submit subsequently; the invoice is issued outside the system under the general rules. |
12 acceptance tests for ERP integration with KSeF
For every test, record the input, expected outcome, evidence of execution and the person responsible for acceptance. Use anonymized examples representing all declared invoice types. The following criteria are recommendations for implementation acceptance, not an official certificate of compliance.
| Test | Verifiable outcome |
|---|---|
| 1. Environment separation | Invoices, references, credentials and synchronization checkpoints do not mix TEST, DEMO and PROD. |
| 2. Access and loss of permissions | Reading and issuance work in the permitted context; losing access does not delete the queue. |
| 3. Credential renewal | Access expiry or certificate rotation does not lose an operation or trigger it twice. |
| 4. Mapping every scenario | Sales, advance payment invoices, corrective invoices and all other declared variants pass XSD validation and business checks. |
| 5. Partial session rejection | Each invoice has its own outcome; accepted documents are not retried along with rejected ones. |
| 6. Acceptance with a missing UPO | The KSeF number returns to the ERP system; UPO retrieval is retried, not submission of the accepted invoice. |
| 7. Timeout and duplicate | An unknown outcome is reconciled; a duplicate is linked to the original document. |
| 8. Restart and backup restoration | The process resumes from persistent state; documents accepted after the backup was created are reconciled. |
| 9. Request limit | HTTP 429 triggers a wait and controlled processing of the backlog. |
| 10. Complete purchase invoice retrieval | All pages and export parts are stored; HWM, truncation and range boundaries do not cause omissions. |
| 11. Storage failure and multiple roles | The incremental checkpoint does not advance ahead of storage; reimporting does not create another liability. |
| 12. Offline operation and restored communication | The mode, deadline, document provided to the recipient and subsequent submission match the applicable procedure. |
Step 9. Go live and establish maintenance responsibilities
First, sign off the tests in non-production environments. In production, run a limited pilot using genuine, correctly prepared documents and agree on who checks the outcome. Do not test a return to the old system by reissuing documents already accepted in KSeF.
Monitoring should show the age of the oldest invoice in the queue, unknown outcomes, rejections, accepted invoices without UPO, delays in purchase invoice retrieval, truncated exports and access errors. Assign a recipient and a response time to every alert. Set thresholds according to the company's volume and deadlines.
Maintenance covers ERP and API updates, key rotation, credential renewal, backups and recovery tests. A mapping change should trigger tests for every affected invoice type. Periodically reconcile document counts and identifiers between the ERP system, the integration archive and KSeF.
The deliverable is an acceptance report, an incident procedure and a designated maintenance owner. The supplier should also specify how XML, UPO, operation history and configuration will be handed over when the engagement ends.
What determines the cost of ERP integration with KSeF?
Compare proposals for the same scope. Costs depend on the number of companies and systems, availability of a ready-made connector, ERP modifications, invoice types, data quality, volume, purchase invoice retrieval and the required level of maintenance. The license price alone does not automatically include analysis, testing or incident handling.
In your request for proposals, specify the ERP version, extensions, process list, volume and peak periods. Ask for separate quotes for implementation, licensing, infrastructure, maintenance and changes. Attach the mapping matrix and acceptance criteria so that you can compare genuinely equivalent proposals.
Agree on who corrects source data, monitors offline deadlines and reconciles unknown outcomes. Ask about updates following API changes, response times, the scope of responsibility and access to data after changing suppliers. Without these agreements, the cheapest proposal may cover only XML transport.
Where can KSeFGPT support invoice exchange?
KSeFGPT provides a ready-made connection to Fakturownia.pl: configuration using a subdomain and API token, previews, individual or bulk submission, and outcome checks. Selected invoices from KSeF can also be exported to Fakturownia. The Integrations module describes the scope.
File import is a different route from a direct ERP connection. PDF files require OCR extraction and data verification, while CSV, XLS or XLSX files require parsing and column mapping. The prepared FA(3) XML is submitted to KSeF. Whether a particular ERP system can export the data must be confirmed in its configuration.
KSeFGPT does not currently have a direct SAP integration. Automatic retrieval from SAP and writing the KSeF number back to SAP remain planned features with no announced release date. Do not assume that the scope of the ready-made Fakturownia connection applies to any ERP system. Invoicing and data-exchange tools do not replace a full accounting system or a tax assessment.
Frequently asked questions
Answers to questions about scope, confirmations and implementation acceptance.
Is a ready-made ERP connector sufficient?
Yes, if it supports the exact ERP version and every required process. Confirm the scope of sales, purchases, corrective invoices, offline modes, statuses and maintenance using your own test scenarios.
When is an invoice accepted by KSeF?
After processing completes successfully and a KSeF number is assigned. Acceptance of the submission request starts the process. UPO is a separate confirmation of receipt by KSeF.
What should you do if the submission response never arrives?
Record the outcome as unknown and reconcile the status using the known invoice or session references. A retry should be initiated from the persistent operation register after checking the previous outcome.
Is a retrieved purchase invoice automatically approved?
No. Importing from KSeF does not confirm fulfillment of the delivery, approval of the cost, entitlement to deduct VAT or payment. Those decisions remain part of the accounting and business workflows.
Does offline24 mean you have 24 hours to submit?
No. The invoice must be submitted without delay, no later than the next working day after issuance. Announced KSeF unavailability and outages have separate deadlines.
Does KSeFGPT connect directly to every ERP system?
No. The ready-made Fakturownia.pl connection and file imports have a defined scope. Direct SAP integration is planned. The capabilities of a particular ERP system must be confirmed separately.
Choose your invoice-exchange method
Check the ready-made connections and data-exchange formats available in KSeFGPT. Support for a specific ERP system requires separate confirmation.
Explore the Integrations moduleSources
Information was checked on October 15, 2026. Acceptance criteria and organizational arrangements are implementation recommendations. When going live, check the current regulations, the contract for the relevant environment and the documentation for the specific ERP version.
- MF: KSeF 2.0 handbook, issuing and receiving invoices
accessed: October 15, 2026
KSeF scope, FA(3), environments, validation, the KSeF number, UPO and invoice delivery. August 2026 edition.
- MF: KSeF certificates
accessed: October 15, 2026
Certificate types and MF's position on continued token support.
- MF: invoice issuance modes, comparison table
accessed: October 15, 2026
Conditions, dates and submission deadlines for offline24, unavailability, emergency mode and a complete outage.
- CIRFMF: production OpenAPI contract
accessed: October 15, 2026
Operations, document statuses, exports and API limits.
- CIRFMF: incremental invoice retrieval
accessed: October 15, 2026
Incremental retrieval using PermanentStorage, the HWM completeness boundary, truncated packages and deduplication.
- KSeFGPT: Fakturownia.pl integration
accessed: October 15, 2026
Configuration, submission and invoice export for the ready-made connection.