Przejdź do głównej zawartości

Configuration

Ta treść nie jest jeszcze dostępna w Twoim języku.

KSeF2 CLI can run without any local config file. This is the preferred mode for CI and shared machines. On a developer workstation, create named profiles so daily commands do not repeat --env, --nip, and authentication paths.

Terminal window
uv run ksef2 config path

By default, the CLI uses:

~/.config/ksef2-cli/config.toml

Override the path with --config or KSEF2_CONFIG:

Terminal window
uv run ksef2 --config ./local.ksef2.toml config path
Terminal window
uv run ksef2 profile create demo-client \
--env test \
--nip 6880313213 \
--cert /path/accountant-auth-cert.pem \
--key /path/accountant-auth-key.pem

profile create selects the new profile by default. Use --no-activate when you only want to save it.

Token profiles store the environment variable name, not the token value:

Terminal window
uv run ksef2 profile create prod-client \
--env production \
--nip 5261040828 \
--token-env KSEF2_PROD_TOKEN
Terminal window
uv run ksef2 profile use demo-client
uv run ksef2 profile current
uv run ksef2 profile list

Use a different profile for one command:

Terminal window
uv run ksef2 --profile prod-client invoices metadata --date-from 2026-01-01T00:00:00Z

Or select one for the current shell:

Terminal window
export KSEF2_PROFILE=demo-client
Terminal window
uv run ksef2 config show
uv run ksef2 profile show demo-client

The config file stores profile names, environments, NIPs, credential file paths, and secret environment variable names. It should not contain token or password values.

Example config:

active_profile = "demo-client"
[profiles.demo-client]
environment = "test"
nip = "6880313213"
[profiles.demo-client.auth]
type = "xades_pem"
cert = "/path/accountant-auth-cert.pem"
key = "/path/accountant-auth-key.pem"
Terminal window
uv run ksef2 --no-config --nip "$KSEF2_NIP" --token "$KSEF2_TOKEN" \
invoices metadata --role seller --date-from 2026-01-01T00:00:00Z

The default output mode is plain text for humans:

Terminal window
uv run ksef2 invoices metadata --date-from 2026-01-01T00:00:00Z

Use --json or --output json for scripts:

Terminal window
uv run ksef2 --json invoices metadata --date-from 2026-01-01T00:00:00Z
VariablePurpose
KSEF2_CONFIGLocal config file path
KSEF2_PROFILEProfile name for this shell/session
KSEF2_NIPTaxpayer or context NIP override
KSEF2_TOKENKSeF token authentication secret override
KSEF2_CONTEXT_TYPEToken-auth context type override
KSEF2_TEST_CERTEnable SDK-generated TEST certificate authentication
KSEF2_CERTPEM certificate path override
KSEF2_KEYPEM private key path override
KSEF2_KEY_PASSWORDPEM private key password override
KSEF2_P12PKCS#12/PFX archive path override
KSEF2_P12_PASSWORDPKCS#12/PFX password override