Skip to main content

KSeF Authentication

POST /auth/{environment}​

Logs in (establishes a connection) to KSeF using a certificate associated with the user account. Initiates an interactive session and returns access tokens.

Path Parameters​

ParameterTypeRequiredDescription
environmentstring✅test, demo, or prod

Response 200​

{
"accessToken": {
"token": "eyJ...",
"validUntil": "2026-04-18 23:00:00"
},
"refreshToken": {
"token": "eyJ...",
"validUntil": "2026-04-18 23:00:00"
},
"environment": "test",
"nip": "9570429696",
"subjectName": "C=PL, O=Company XYZ, CN=user@example.com",
"shortName": "user@example.com",
"authenticatedAt": "2026-04-11 23:00:00"
}
FieldTypeDescription
accessTokenobjectKSeF access token with an expiration date
refreshTokenobjectKSeF refresh token (may be null)
environmentstringThe KSeF environment used
nipstringCompany Tax ID (NIP)
subjectNamestringFull subject name from the certificate
shortNamestringShortened subject name
authenticatedAtstringAuthentication date

Error Codes​

CodeDescription
401Missing or incorrect credentials (Basic Auth)
403Missing required role (admin or technical)
404No active certificate for the given environment
500Server or KSeF error