Skip to content
Back to articles
Technology9 min readUpdated:

KSeF Certificate or Token: How to Connect Your CRM and Store to the KSeF 2.0 API

How a CRM, online store or B2B portal logs in to the KSeF 2.0 API, Poland’s e-invoicing system: KSeF token or KSeF certificate, token validity after 2026 under the draft of October 27, 2026, how to get a certificate, the offline certificate and the TEST and DEMO environments.

In short

  • A CRM, online store or B2B portal that sends invoices to KSeF (Krajowy System e-Faktur, Poland’s national e-invoicing system) on its own logs in to the KSeF 2.0 API with a KSeF token or a KSeF certificate for authentication. Both methods work in parallel.
  • Under the regulation in force, tokens work until December 31, 2026. The Polish Ministry of Finance has announced that the method will stay, and a draft amendment to the regulation of October 27, 2026, provides for current tokens to remain valid until November 30, 2027, and new ones for at most 365 days. As of November 14, 2026, this is a draft.
  • A KSeF certificate is valid for at most 2 years. You apply for it in the KSeF Taxpayer Application 2.0 (Aplikacja Podatnika KSeF 2.0) or through the API, after logging in with Profil Zaufany (the Polish government e-ID), a qualified signature or a qualified electronic seal. You cannot order a certificate with a token.
  • Invoices in offline mode require a separate offline certificate: without it, the system cannot generate the second QR code.
  • You test the integration first in the TEST environment, then in DEMO, and only at the end in production.

How does a CRM or online store log in to the KSeF 2.0 API?

Software that sends invoices to KSeF without human involvement does not log in with a password. Each time it connects, it goes through a short procedure: it fetches a one-time challenge from KSeF, confirms it with a token or a certificate signature, and in return receives an access token that it uses to send and download invoices. The access token is valid for a dozen or so minutes, and the refresh token for at most 7 days. After that, the system has to authenticate again.

Authentication in the KSeF 2.0 API step by step (Ministry of Finance documentation, as of November 14, 2026)
StepAPI callWhat you need to know
1. ChallengePOST /auth/challengeThe challenge is valid for 10 minutes.
2a. CertificatePOST /auth/xades-signatureThe system signs an XML document containing the challenge and the NIP (Polish tax identification number) with an XAdES signature: a KSeF certificate, a qualified signature or a qualified electronic seal.
2b. KSeF tokenPOST /auth/ksef-tokenThe system sends the token combined with the timestamp from the challenge, encrypted with the Ministry of Finance public key.
3. StatusGET /auth/{referenceNumber}Polled until it completes. A qualified signature may take longer to verify with its issuer; a KSeF certificate is verified straight away.
4. Access tokensPOST /auth/token/redeemReturns an access token and a refresh token. A second call with the same authentication token fails with an error.
5. RefreshPOST /auth/token/refreshA new access token without logging in again, as long as the refresh token is valid.
Source: the Ministry of Finance KSeF 2.0 API documentation on GitHub (authentication).

KSeF token or KSeF certificate: which should you choose for an integration?

According to the Ministry of Finance FAQ, the token and the certificate work in parallel, and an external system can use either one. They differ in how you obtain them, how long they are valid and what else they let you do.

KSeF token and KSeF certificate in an integration (as of November 14, 2026)
FeatureKSeF tokenKSeF certificate (authentication)
What it isA string of characters generated in KSeF with a defined scope of permissions, e.g. sending and reading invoices.An electronic confirmation of the identity of a person or company, with a key pair. The private key stays with you.
How to get itYou generate it in the KSeF Taxpayer Application 2.0 or through the API (POST /tokens) after logging in.A request in the KSeF Taxpayer Application 2.0 or through the API, after logging in with Profil Zaufany, a qualified signature or a qualified electronic seal.
ValidityRules in force: until December 31, 2026. Draft of October 27, 2026: current tokens until November 30, 2027, new ones for at most 365 days.At most 2 years, renewable while it is still valid.
PermissionsStored in the token. Changing the scope means a new token.The certificate does not contain them: KSeF checks the permissions of the person or company it was issued to.
Requirements on the system sideEncrypting the token with the Ministry of Finance public key.An XAdES signature on the authentication document.
LimitationsAfter logging in with a token, you cannot create a KSeF certificate.You cannot use it to log in to the KSeF Taxpayer Application: it is meant for systems that connect through the API.
Basis: § 6 and § 13 of the regulation of December 12, 2025 (Journal of Laws (Dz.U.) 2025, item 1815), the Ministry of Finance page on KSeF certificates, the KSeF 2.0 FAQ and the API documentation.

A token is simpler to start with, because the system does not have to sign XAdES documents. A certificate gives a longer and predictable validity period, and in an integration you build today it has one more advantage: it does not depend on how the change to the token rules turns out. The safest approach is to build the integration so that the login method can be changed in the settings, without reworking the software.

How do you get a KSeF certificate, step by step?

Since February 2026, you apply for a certificate in the KSeF Taxpayer Application 2.0 or through the KSeF 2.0 API. The Certificates and Permissions Module (Moduł Certyfikatów i Uprawnień, MCU), which issued certificates from November 2025, was available until the end of January 2026. In the application, it works like this:

  1. Log in to the KSeF Taxpayer Application 2.0 with Profil Zaufany (via login.gov.pl), a qualified signature or your company’s qualified electronic seal. Check that you are working in the context of the correct NIP.
  2. Open the “Certyfikaty” (Certificates) tab and select “Wnioskuj o certyfikat” (request a certificate). The application fills in the request with the data from your login.
  3. Choose the purpose: authentication or offline mode. Each certificate has one purpose, so for both you need two requests.
  4. Protect the private key. The key pair is created with the request, and only the public key goes to the Ministry. Without the private key the certificate is useless, and anyone who has the key can act on your behalf within the limits of your permissions.
  5. Download the certificate and upload it to your system together with the private key, over a secure channel. Do not send the key by email.
  6. Write down the expiry date. You can order the next certificate before the previous one expires. Set a reminder at least a month in advance.

The system can also submit the request itself, through the API: it checks the limits (GET /certificates/limits), fetches the data for the request (GET /certificates/enrollments/data), sends a CSR in PKCS#10 format (POST /certificates/enrollments), checks the status and downloads the certificate (POST /certificates/retrieve). The documentation allows RSA 2048 and EC P-256 keys and recommends EC. Only its owner can revoke a certificate, e.g. after a key leak (POST /certificates/{numer}/revoke), and a revoked certificate cannot be restored.

Whose certificate should your company’s system use?

A certificate confirms identity, but it does not grant permissions. Each time the system connects, KSeF checks what the person or company the certificate was issued to is allowed to do. According to the Ministry of Finance FAQ, a certificate can be obtained by an individual identified by a NIP or a PESEL number (Polish personal identification number), and by a company that logs in with a qualified electronic seal. A company certificate can be shared with employees, while the certificate of a sole proprietorship is personal.

  • Company certificate (qualified electronic seal): the integration does not depend on one person. It is a sensible choice for a CRM or online store that issues invoices for the whole company.
  • Employee certificate: works as long as that employee has KSeF permissions for the company. When they leave and lose their permissions, the system stops sending invoices.
  • Accounting firm or external provider: logs in with its own certificate and acts within the permissions granted by the company. The draft amendment to the regulation of October 27, 2026, also provides for a certificate issued in the context of one specified NIP, i.e. one that works only for a specific client. This is a draft.

When do you need a KSeF offline certificate?

When you issue an invoice without a connection to KSeF, you have to mark it with two QR codes. The first lets you check the invoice in KSeF; the second confirms the issuer’s identity and requires a KSeF certificate for offline mode. Such a certificate is not used for logging in, and a login certificate cannot sign the QR code. Deadlines for sending the invoice later, according to the API documentation:

Offline modes in KSeF 2.0 and deadlines for sending the invoice later
ModeWhenDeadline for sending to KSeF
offline24For any reason, at the taxpayer’s discretionBy the next business day after the issue date
offline (unavailability)Announced unavailability of KSeFBy the next business day after the unavailability ends
emergencyAnnounced KSeF failureWithin 7 business days of the end of the failure
total failureFailure announced in the mass mediaInvoice without QR codes and with no obligation to send it to KSeF later
Source: offline modes in the KSeF 2.0 API documentation.

For the system, this means four things: sending the invoice flagged as offline mode, taking the issue date only from the P_1 field, both QR codes on the printout and in the PDF, and keeping track of the deadline for sending it later. Without an offline certificate, an online store or CRM cannot issue a correct invoice to a business while KSeF is unavailable.

Where should you test a KSeF integration: TEST, DEMO or production?

KSeF 2.0 API environments (Ministry of Finance documentation of March 16, 2026)
EnvironmentAPI addressWhat it is for
TESTapi-test.ksef.mf.gov.plFirst integration tests. Fictitious NIP numbers, self-generated certificates, data may be visible to other integrators. Maintenance breaks between 16 and 18 h (Polish time).
DEMO (pre-production)api-demo.ksef.mf.gov.plA final check in a configuration close to production. No real invoices or company data.
Productionapi.ksef.mf.gov.plInvoices with full legal effect.
The OpenAPI specification is available at the environment address followed by /docs/v2. The Ministry also provides official client libraries in C# and Java.

In TEST you check logging in, sending an invoice, a rejection, a corrective invoice and offline mode. In DEMO you repeat the same with the certificate you will use in production. Do not send real invoices to either of these environments.

What else does an integration need to handle besides logging in?

  • Renewing access: refreshing the access token and logging in again when the refresh token expires.
  • Expiry reminders: a warning before the certificate or token expires, sent to the person who can generate a new one.
  • Secure storage: the token and the private key in a secrets vault or an encrypted configuration, never in the program code or in a spreadsheet.
  • Switchable login method: moving from a token to a certificate without rebuilding the integration.
  • Invoices: sending FA(3) e-invoices, the KSeF number and UPO (Urzędowe Poświadczenie Odbioru, the official confirmation of receipt) stored with the invoice, handling rejections, corrective invoices with the KSeF number of the original invoice, downloading purchase invoices and API request limits.

We compare the ways of connecting an online store and a CRM to KSeF, with prices (the Ministry of Finance app, invoicing software, a plugin, an API gateway, a direct integration), in the article KSeF in CRM and online stores: 5 ways to integrate, and the 2027 deadlines in the KSeF 2027 checklist. You will find the terms explained in the IT glossary.

When is off-the-shelf software enough, and when do you need an integration?

If you issue invoices in invoicing software or on an e-commerce platform that supports KSeF, you upload the certificate or token there following the vendor’s instructions and do not need a developer. An API integration makes sense when invoices are created in your CRM, B2B portal or order system, when you have several invoice sources, or when you want the KSeF number to flow back to the order and the payment.

UNSEEN builds integrations like these from 1,400 EUR net (UN·Connect) and a financial module with KSeF from 6,850 EUR net (UN·Finance). Among other things, we have built invoice submission to KSeF into a CRM for a renewable energy company: an invoice issued in the system goes to KSeF together with the UPO, and purchase invoices come back into the system. The full scope is described on our page invoices from your CRM and online store to KSeF.

Frequently asked questions about the KSeF certificate and token

Will the KSeF token stop working on December 31, 2026?

Under the regulation in force, you can log in with a token until December 31, 2026. The Ministry of Finance has announced that the method will stay, and a draft amendment to the regulation of October 27, 2026, provides for current tokens to remain valid until November 30, 2027, and new ones for at most 365 days. Until the amendment is published, December 31, 2026, is binding.

Where do I generate a KSeF certificate?

In the KSeF Taxpayer Application 2.0, in the “Certyfikaty” (Certificates) tab, or through the KSeF 2.0 API. Before that, from November 2025 to the end of January 2026, certificates were issued by the Certificates and Permissions Module (MCU).

How long is a KSeF certificate valid?

For at most 2 years from its creation or from the start date given in the request. It can be renewed before it expires.

Can I log in to the KSeF Taxpayer Application with a KSeF certificate?

No. The authentication certificate is meant for systems that connect to KSeF through the API, e.g. invoicing software, online stores and CRMs. You log in to the Taxpayer Application with Profil Zaufany, a qualified signature or a qualified electronic seal.

Do I need a separate certificate for offline invoices?

Yes. The second QR code on an offline invoice requires a KSeF certificate for offline mode. A login certificate cannot replace it, and one certificate cannot have both purposes.

Can I order a certificate with a KSeF token?

No. After logging in with a token, you cannot create a KSeF certificate. The request requires logging in with Profil Zaufany, a qualified signature or a qualified electronic seal.

Update history

  • First version. Authentication methods, the validity of tokens and certificates, environments and offline modes checked on November 14, 2026, in the Journal of Laws, on the RCL website, on the Ministry of Finance websites and in the KSeF 2.0 API documentation.

Sources

  1. Regulation of the Minister of Finance and Economy (MFiG) of December 12, 2025, on the use of KSeF, Journal of Laws 2025, item 1815 (§ 6, § 13) (checked on November 14, 2026)
  2. RCL: draft regulation amending the regulation on the use of KSeF (October 27, 2026) (checked on November 14, 2026)
  3. Ministry of Finance: KSeF certificates (checked on November 14, 2026)
  4. Ministry of Finance: KSeF 2.0 questions and answers (checked on November 14, 2026)
  5. KSeF 2.0 API documentation: authentication (checked on November 14, 2026)
  6. KSeF 2.0 API documentation: KSeF certificates (checked on November 14, 2026)
  7. KSeF 2.0 API documentation: KSeF tokens (checked on November 14, 2026)
  8. KSeF 2.0 API documentation: offline modes (checked on November 14, 2026)
  9. KSeF 2.0 API documentation: environments (checked on November 14, 2026)
  10. Infor.pl: changes in KSeF from 2027, draft amendment to the regulation (November 9, 2026) (secondary source)

This article is for information only and is not tax advice: in tax matters, your accountant or tax advisor has the final say.

Need personalized advice?

Book a free consultation. We’ll analyze your business and propose specific solutions.

Book a free 30-min call

Analytics and marketing cookies only with your consent. Details in our privacy policy.