KSeF token

How to generate a KSeF token and connect it to Notaly

This guide explains how to generate a KSeF token in the Polish taxpayer application and connect it to Notaly so you can issue e-invoices under your own NIP.

Updated 5 min read

What you need before you start

  • An active Polish VAT taxpayer (a valid NIP).
  • Access to the KSeF taxpayer application using one of the accepted login methods (Profil Zaufany, qualified signature, e-dowód, or your bank).
  • A Notaly account.

Which environment to use

  • Production (ap.ksef.mf.gov.pl) — issues invoices with legal effect. Use this only when you are ready to issue real invoices.
  • Demo (ap-demo.ksef.mf.gov.pl) — uses your real NIP and a real token, but invoices have no legal effect. Use this to test the connection end to end.
  • Test (ap-test.ksef.mf.gov.pl) — for fictional data only. This is what Notaly uses for the free Sandbox; you do not need your own token for Sandbox.

A token created in one environment does not work in another. Generate the token in the environment that matches your Notaly plan: Demo to test a paid connection, or Production to issue real invoices. You do not select the environment inside Notaly — Notaly selects it automatically from your plan.

Step 1 — Log in to the KSeF taxpayer application

Open the taxpayer application for the environment you are using and log in with your chosen method.

Step 2 — Open the tokens section

Go to the section for generating API tokens. The exact label may vary slightly depending on the version of the application; look for an item named “Tokeny” (Tokens) or “Generowanie tokenów” (Generating tokens).

Step 3 — Create a new token

  • Select the option to generate a new token.
  • Enter a name for the token, for example “Notaly”.
  • If the application offers an expiry date, choose one that suits your security policy. Remember you will need to regenerate and reconnect the token when it expires.

Step 4 — Grant the required permissions

Notaly needs two permissions:

  • InvoiceWrite — to issue invoices on your behalf (shown in Polish as “wystawianie faktur”).
  • InvoiceRead — to read invoice status and the official confirmation (UPO).

Select both permissions when you generate the token. Do not add permissions Notaly does not need.

Step 5 — Copy the token

Generate the token and copy it immediately. The token is typically shown only once. Store it securely until you paste it into Notaly.

Treat the token like a password. Do not send it by email, commit it to a repository, or paste it into a support chat.

Step 6 — Connect the token in Notaly

In the Notaly dashboard, open Settings and then Connect KSeF. Provide:

  • your NIP;
  • the token you generated.

Notaly selects the environment automatically from your plan (Demo for testing, Production for real invoices) and validates the connection against that environment. If it succeeds, the connection is marked active and you can issue invoices under your own NIP.

If the connection fails

  • Check that the token was copied completely and has not expired.
  • Check that you generated the token in the environment matching your Notaly plan (Demo for testing, Production for real invoices).
  • Check that the token has both InvoiceWrite and InvoiceRead permissions.
  • If you generated a new token, the previous token may have been invalidated. Reconnect with the new token.
  • If the problem persists, contact hello@getnotaly.com. Never paste the token into the message.

Revoking access

You can disconnect KSeF at any time from the Notaly dashboard. We also recommend revoking the token in the KSeF taxpayer application so it can no longer be used.

Frequently asked questions

Where do I generate a KSeF token?

In the Ministry of Finance KSeF application (Aplikacja Podatnika KSeF / Certificates and Permissions Module) for the environment you need: ap-test.ksef.mf.gov.pl, ap-demo.ksef.mf.gov.pl or ap.ksef.mf.gov.pl.

Which permissions does the token need?

At least the permission to issue invoices (InvoiceWrite). Add invoice viewing (InvoiceRead) if you also want to read invoices from KSeF.

Can I see my KSeF token again later?

No. KSeF shows the token once. If you lose it, revoke it and generate a new one.

Does a TEST token work in production?

No. KSeF environments are separate: a token from TEST or DEMO never works in PRODUCTION, and vice versa.

Do I need a token for the Notaly sandbox?

No. The sandbox uses Notaly's KSeF TEST credentials. You only connect your own token for paid plans.

Issue your first KSeF test invoice today

Create a sandbox account: API key in seconds, 3 free test invoices on KSeF TEST, no credit card.