Skip to content

Quickstart

This quickstart uses the TEST environment and the SDK-generated TEST certificate. Use a real XAdES certificate or KSeF token for DEMO and PRODUCTION.

Terminal window
uv run ksef2 --help

Profiles keep repeated non-secret options in one local config file. The TEST certificate auth method is useful for local development:

Terminal window
uv run ksef2 profile create test-company \
--env test \
--nip 5261040828 \
--test-cert

Authenticate with that profile and print the SDK auth token payload:

Terminal window
uv run ksef2 --profile test-company --json auth login

Global options such as --profile, --env, --nip, --test-cert, and --json must appear before the command group.

Terminal window
uv run ksef2 --profile test-company --json \
invoices metadata \
--role seller \
--date-from 2026-01-01T00:00:00Z \
--all

For token authentication in CI, skip the profile and pass direct root options:

Terminal window
uv run ksef2 --nip "$KSEF2_NIP" --token "$KSEF2_TOKEN" --json \
invoices metadata \
--role seller \
--date-from 2026-01-01T00:00:00Z \
--all
Terminal window
uv run ksef2 --profile test-company \
invoices send invoice.xml \
--wait \
--upo-dir upos \
--receipt invoice-receipt.json

By default, invoices send uses online mode. The receipt file lets you check status or download the UPO later without managing the underlying session:

Terminal window
uv run ksef2 --profile test-company \
invoices status --receipt invoice-receipt.json --wait
uv run ksef2 --profile test-company \
invoices upo --receipt invoice-receipt.json --out invoice-upo.xml
Terminal window
uv run ksef2 --profile test-company \
invoices send invoices/ --receipt-dir receipts

Directory input includes direct child *.xml files. Add --recursive for nested directories. Use --mode batch when the files should be submitted as one batch:

Terminal window
uv run ksef2 --profile test-company \
invoices send invoices/ --mode batch --wait --upo-dir upos