ksef2 is organized around a few long-lived entry points and short-lived KSeF
workflows. The root Client or AsyncClient chooses the environment and owns
transport configuration. Authentication turns that root client into an
authenticated client for one taxpayer context. Sessions are then opened only for
workflows that KSeF models as sessions.
Use this section when you need to understand the shape of a KSeF workflow before writing code. Use the how-to guides when you already know the task and want the SDK calls.
See also:
- Foundations: Start with root clients, authenticated clients, environments, and lifecycle ownership.
- Authentication and security: Understand login context, authenticating subject, certificates, encryption, and XAdES.
- Invoice workflows: Follow sessions, invoice processing, UPO, metadata queries, downloads, and exports.
- Administration: Understand tokens, permission operations, certificates, limits, and PEPPOL lookup.
How the SDK maps the official API
The official KSeF API documentation groups work into access, interactive sending, batch sending, status and UPO, invoice retrieval, tokens, permissions, certificates, limits, public encryption certificates, and PEPPOL. The SDK keeps the same conceptual boundaries and exposes them as branches on the root or authenticated client.
| Official API area | SDK view |
|---|---|
| Access | client.authentication creates an authenticated client for one context. |
| Interactive and batch sending | auth.online_session() and auth.batch_session() own sending-session state. |
| Status and UPO | Session clients and auth.invoice_sessions inspect remote processing and confirmations. |
| Invoice retrieval | auth.invoices owns metadata queries, exports, direct downloads, and package download. |
| Tokens, permissions, certificates, limits | Administrative branches on the authenticated client. |
| Public data | Root-client branches such as client.encryption, client.peppol, and TEST data. |
The low-level raw branches exist for custom protocol work, diagnostics, and
exact KSeF payload debugging. They are public, but they are not the normal
starting point for application code.
Main nouns
| Noun | What it means in the SDK |
|---|---|
| Root client | The unauthenticated client that owns environment and HTTP transport. |
| Authenticated client | A client branch bound to redeemed KSeF access and refresh tokens for one context. |
| Online session | A short-lived sending context for individual encrypted invoice submissions. |
| Batch session | A short-lived sending context for prepared encrypted batch packages. |
| Invoice service | The authenticated branch for metadata queries, exports, direct downloads, and export package download. |
| Reference number | A handle returned by KSeF for sessions, invoices, exports, tokens, permissions, and other asynchronous work. |
| KSeF number | The identifier assigned after KSeF accepts and processes an invoice. |
| UPO | Official confirmation available after a session or invoice reaches the required processed state. |
What belongs where
Use the root client for public lookup and setup:
client.authenticationto start authentication.client.encryptionto inspect public encryption certificates.client.peppolto query public PEPPOL provider data.client.testdatainEnvironment.TESTonly.
Use the authenticated client for context-specific work:
auth.online_session()andauth.batch_session()for sending.auth.invoicesfor metadata, exports, and downloads.auth.tokens,auth.permissions,auth.certificates, andauth.limitsfor administrative workflows.auth.sessionsandauth.invoice_sessionsfor session management and history.
Related pages
- Environments: Choose TEST, DEMO, or PRODUCTION and keep state scoped to that environment.
- Clients and lifecycle: Understand root clients, authenticated clients, sessions, and export handles.
- Authentication methods: Choose token, XAdES, TEST certificate, or profile-based authentication.
- Sessions: Understand online, batch, authentication, and historical invoice sessions.
- Invoice lifecycle: Trace invoice submission through processing, KSeF number assignment, retrieval, and UPO.
- Client and service API: Use the generated API reference when you need the full object and method inventory.
- Official KSeF API guide: Source documentation for the KSeF 2.0 API concepts.
