Save or rotate a customer-owned KSeF token for a company and environment (ADMIN+)
POST
/ksef-connections
const url = 'https://api.invogi.com/v1/ksef-connections';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"company_id":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","environment":"TEST","context_nip":"example","ksef_token":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.invogi.com/v1/ksef-connections \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "company_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "environment": "TEST", "context_nip": "example", "ksef_token": "example" }'Requires an active Invoice Firewall subscription (403 otherwise). The token is encrypted at rest and is never returned. A successful connection test is required before submission.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”X-Invogi-Organization
string format: uuid
For a Clerk session, selects a workspace in which the user has an active membership. If omitted, the remembered accessible workspace is used. API keys remain bound to their own workspace and cannot select another tenant.
Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
object
company_id
Defaults to the organization’s default company
string format: uuid
environment
required
string
context_nip
required
string
ksef_token
required
string
Responses
Section titled “Responses”Connection saved; test it before submitting invoices
Media typeapplication/json
object
id
required
string format: uuid
companyId
required
string format: uuid
companyName
string
environment
required
string
contextNipMasked
required
string
status
required
string
lastTestedAt
required
string | null format: date-time
lastErrorMessage
required
string | null
createdAt
required
string format: date-time
Example
{ "environment": "TEST", "status": "PENDING"}Invalid request
Media typeapplication/json
Missing or invalid API key
Media typeapplication/json
API key lacks required scope/role
Media typeapplication/json