Skip to content

Save or rotate a customer-owned KSeF token for a company and environment (ADMIN+)

POST
/ksef-connections
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.

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.

Media typeapplication/json
object
company_id

Defaults to the organization’s default company

string format: uuid
environment
required
string
Allowed values: TEST DEMO PRODUCTION
context_nip
required
string
/^[0-9]{10}$/
ksef_token
required
string
>= 20 characters <= 4096 characters

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
Allowed values: TEST DEMO PRODUCTION
contextNipMasked
required
string
/^\*{6}[0-9]{4}$/
status
required
string
Allowed values: PENDING CONNECTED ERROR DISABLED
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
object
error
required
object
code
required
string
Allowed values: NOT_FOUND UNAUTHORIZED FORBIDDEN INVALID_REQUEST CONFLICT RATE_LIMITED USAGE_LIMIT_EXCEEDED PROCESSING_FAILED
message
required
string
request_id
required
string
details

Optional stable, content-free context, e.g. {reason, resets_at, preparation_id}.

object
key
additional properties
One of:
string

Example

{
"error": {
"code": "NOT_FOUND"
}
}

Missing or invalid API key

Media typeapplication/json
object
error
required
object
code
required
string
Allowed values: NOT_FOUND UNAUTHORIZED FORBIDDEN INVALID_REQUEST CONFLICT RATE_LIMITED USAGE_LIMIT_EXCEEDED PROCESSING_FAILED
message
required
string
request_id
required
string
details

Optional stable, content-free context, e.g. {reason, resets_at, preparation_id}.

object
key
additional properties
One of:
string

Example

{
"error": {
"code": "NOT_FOUND"
}
}

API key lacks required scope/role

Media typeapplication/json
object
error
required
object
code
required
string
Allowed values: NOT_FOUND UNAUTHORIZED FORBIDDEN INVALID_REQUEST CONFLICT RATE_LIMITED USAGE_LIMIT_EXCEEDED PROCESSING_FAILED
message
required
string
request_id
required
string
details

Optional stable, content-free context, e.g. {reason, resets_at, preparation_id}.

object
key
additional properties
One of:
string

Example

{
"error": {
"code": "NOT_FOUND"
}
}