KSeF Faktury
EN
Join the start list
Early access

The API is in early access: we hand out test keys (KSeF TEST) in batches to people on the launch list. Live mode comes later.

Request access

API reference

Webhook endpoints

Endpoints we send signed invoice and correction events to. The receiving side is covered in the Webhooks guide.

The WebhookEndpoint object

Where we send signed events. The whsec_... secret appears only in the create response.

Attributes

  • idstringrequired

    Endpoint id.

    Prefix we_

  • objectstringrequired

    Object type.

    Always webhook_endpoint

  • livemodebooleanrequired

    The endpoint's mode.

  • urlstringrequired

    Receiver URL.

  • enabled_eventsarray of stringrequired

    Subscribed event types.

  • descriptionstring | null

    Note.

  • statusstringrequired

    Endpoint state.

    One of: enabled, disabled

  • createdintegerrequired

    Created (Unix seconds).

Object WebhookEndpoint
{
  "id": "we_Ab3Cd5Ef7Gh9Ij1Kl3Mn5Op7",
  "object": "webhook_endpoint",
  "livemode": false,
  "url": "https://example.com/ksef/webhook",
  "enabled_events": [
    "*"
  ],
  "description": "Shop backend",
  "status": "enabled",
  "created": 1760865185
}

List webhook endpoints

GET /v1/webhook_endpoints

Active endpoints in the key's mode. Secrets are not included.

Responses

GET /v1/webhook_endpoints
curl https://app.ksefshop.pl/v1/webhook_endpoints \
  -H "Authorization: Bearer $KSEF_API_KEY"
Response
{
  "object": "list",
  "url": "/v1/webhook_endpoints",
  "has_more": false,
  "data": []
}

Create a webhook endpoint

POST /v1/webhook_endpoints

Registers a URL for events. The whsec_... signing secret is returned only in this response. Live mode needs an https:// URL; test mode also allows http://. At most 16 endpoints per mode.

Parameters

  • Idempotency-Keyheader · string

    Any unique text (1-255 characters), e.g. order-SO-1001. A retry with the same key within 24 hours returns the first response. Idempotency

Request body (JSON)

  • urlstringrequired

    https only in live mode.

  • enabled_eventsarray of stringrequired

    Event types, or * for all.

    One of: invoice.accepted, invoice.rejected, invoice.skipped, correction.accepted, correction.rejected, correction.skipped, * · 1-∞ items

  • descriptionstring

    A note for yourself.

    max 500 characters

Responses

POST /v1/webhook_endpoints
curl -X POST https://app.ksefshop.pl/v1/webhook_endpoints \
  -H "Authorization: Bearer $KSEF_API_KEY" \
  -H "Idempotency-Key: webhook-shop-backend" \
  -H "Content-Type: application/json" \
  -d '{
  "url": "https://example.com/ksef/webhook",
  "enabled_events": [
    "*"
  ],
  "description": "Shop backend"
}'
Response
{
  "id": "we_Ab3Cd5Ef7Gh9Ij1Kl3Mn5Op7",
  "object": "webhook_endpoint",
  "livemode": false,
  "url": "https://example.com/ksef/webhook",
  "enabled_events": [
    "*"
  ],
  "description": "Shop backend",
  "status": "enabled",
  "created": 1760865185,
  "secret": "whsec_shownOnlyOnceExampleValue0000"
}

Retrieve a webhook endpoint

GET /v1/webhook_endpoints/{id}

One endpoint by its we_... id.

Parameters

  • idpath · stringrequired

    The object's id.

    Prefix we_

Responses

GET /v1/webhook_endpoints/{id}
curl https://app.ksefshop.pl/v1/webhook_endpoints/we_Ab3Cd5Ef7Gh9Ij1Kl3Mn5Op7 \
  -H "Authorization: Bearer $KSEF_API_KEY"
Response
{
  "id": "we_Ab3Cd5Ef7Gh9Ij1Kl3Mn5Op7",
  "object": "webhook_endpoint",
  "livemode": false,
  "url": "https://example.com/ksef/webhook",
  "enabled_events": [
    "*"
  ],
  "description": "Shop backend",
  "status": "enabled",
  "created": 1760865185
}

Delete a webhook endpoint

DELETE /v1/webhook_endpoints/{id}

Disables the endpoint: it gets no new events. Events stay available at /v1/events.

Parameters

  • idpath · stringrequired

    The object's id.

    Prefix we_

Responses

DELETE /v1/webhook_endpoints/{id}
curl -X DELETE https://app.ksefshop.pl/v1/webhook_endpoints/we_Ab3Cd5Ef7Gh9Ij1Kl3Mn5Op7 \
  -H "Authorization: Bearer $KSEF_API_KEY"
Response
{
  "id": "we_Ab3Cd5Ef7Gh9Ij1Kl3Mn5Op7",
  "object": "webhook_endpoint",
  "deleted": true
}

Event delivery

When an invoice or a correction reaches a final state, we POST an Event to every enabled endpoint subscribed to that event type.

Header Value
KSeF-Signature t=<unix>,v1=<hex> where v1 = HMAC-SHA256(secret, t + "." + raw body)
KSeF-Event-Id The event id (evt_...), for dropping duplicates
Content-Type application/json

Any 2xx answer counts as delivered. Signature verification in four languages and the retry schedule are in the Webhooks guide.

KSeF Faktury

API early access

We hand out test keys in batches. Leave your email: we will write when your access is ready.