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

Invoices and corrections

An invoice comes from a paid order and goes through the queue: number, FA(3) XML, KSeF, PDF. A correction comes from a refund and refers to the invoice's KSeF number. Both documents share statuses and fields.

The Invoice object

A VAT invoice issued from a paid order. Its corrections are nested in corrections.

Attributes

  • idstringrequired

    Document id.

    Prefix inv_

  • objectstringrequired

    Object type.

    One of: invoice, correction · Always invoice

  • livemodebooleanrequired

    true in live mode, false in test mode.

  • statusstringrequired

    pending → queued → sending → accepted, rejected or error; or skipped (cannot be invoiced) and waiting_for_plan_limit (plan limit used up).

    One of: pending, queued, sending, accepted, rejected, skipped, waiting_for_plan_limit, error

  • orderobjectrequired

    The order the document comes from.

    Show fields
    • external_idstringrequired

      Your order id.

    • numberstring | nullrequired

      Order number.

  • numberstring | nullrequired

    Invoice number (gapless per month)

  • ksef_numberstring | nullrequired

    KSeF number

  • ksef_environmentstringrequired

    KSeF environment: test for test keys, prod for live keys.

    One of: test, demo, prod

  • issue_datestring | nullrequired

    Issue date.

    date

  • currencystring | nullrequired

    Invoice currency.

  • total_grossstring | nullrequired

    Gross total in the invoice currency (negative for corrections).

  • buyer_nipstring | nullrequired

    Buyer NIP.

  • pdf_urlstring | nullrequired

    Public link with an unguessable token

  • last_errornull | Errorrequired

    The document's last error or null. Error codes

    Show fields
    • typestringrequired

      Error category.

      One of: invalid_request_error, authentication_error, permission_error, not_found_error, idempotency_error, rate_limit_error, invoice_error, ksef_error, api_error

    • codestringrequired

      Stable machine-readable code. All codes

      One of: parameter_missing, parameter_invalid, body_invalid_json, body_too_large, buyer_nip_missing, buyer_nip_invalid, order_not_paid, order_cancelled, currency_not_supported, vat_rate_missing, vat_rate_unsupported, order_unprocessable, correction_requires_invoice, livemode_mismatch, resource_missing, route_not_found, method_not_allowed, pdf_not_ready, api_key_missing, api_key_invalid, live_mode_disabled, idempotency_key_reused, idempotency_key_invalid, rate_limited, internal_error, seller_not_configured, plan_limit_reached, invoice_build_failed, invoice_schema_invalid, original_not_invoiced, original_rejected, ksef_not_connected, ksef_auth_failed, ksef_duplicate_number, ksef_rejected, ksef_unavailable

    • messagestringrequired

      Human-readable text; may change.

    • paramstring

      JSON path of the parameter

    • ksef_codeinteger

      KSeF's own numeric code (e.g. 440 duplicate

    • doc_urlstringrequired

      Link to the code on the errors page.

  • createdintegerrequired

    Created (Unix seconds).

  • updatedintegerrequired

    Last change (Unix seconds).

  • correctionsarray of Correctionrequired

    Corrections of this invoice.

    See object Correction

Object Invoice
{
  "id": "inv_4fJ2kP9xQwErTy7uI0oPaSdF",
  "object": "invoice",
  "livemode": false,
  "status": "accepted",
  "order": {
    "external_id": "SO-1001",
    "number": "1001"
  },
  "number": "FV/2026/10/1",
  "ksef_number": "4235405606-20261019-0E7570400000-57",
  "ksef_environment": "test",
  "issue_date": "2026-10-19",
  "currency": "PLN",
  "total_gross": "163.99",
  "buyer_nip": "5260250274",
  "pdf_url": "https://app.ksefshop.pl/pdf/cmgxa1b2c0000/Qk9tZ2FsX3ZhbGlkX3Rva2VuX2V4YW1w",
  "last_error": null,
  "created": 1760865185,
  "updated": 1760865214,
  "corrections": []
}

The Correction object

A correction invoice (KOR) issued from a refund. Same fields as an invoice, plus invoice and refund.

Attributes

  • idstringrequired

    Document id.

    Prefix cor_

  • objectstringrequired

    Object type.

    One of: invoice, correction · Always correction

  • livemodebooleanrequired

    true in live mode, false in test mode.

  • statusstringrequired

    pending → queued → sending → accepted, rejected or error; or skipped (cannot be invoiced) and waiting_for_plan_limit (plan limit used up).

    One of: pending, queued, sending, accepted, rejected, skipped, waiting_for_plan_limit, error

  • orderobjectrequired

    The order the document comes from.

    Show fields
    • external_idstringrequired

      Your order id.

    • numberstring | nullrequired

      Order number.

  • numberstring | nullrequired

    Invoice number (gapless per month)

  • ksef_numberstring | nullrequired

    KSeF number

  • ksef_environmentstringrequired

    KSeF environment: test for test keys, prod for live keys.

    One of: test, demo, prod

  • issue_datestring | nullrequired

    Issue date.

    date

  • currencystring | nullrequired

    Invoice currency.

  • total_grossstring | nullrequired

    Gross total in the invoice currency (negative for corrections).

  • buyer_nipstring | nullrequired

    Buyer NIP.

  • pdf_urlstring | nullrequired

    Public link with an unguessable token

  • last_errornull | Errorrequired

    The document's last error or null. Error codes

    Show fields
    • typestringrequired

      Error category.

      One of: invalid_request_error, authentication_error, permission_error, not_found_error, idempotency_error, rate_limit_error, invoice_error, ksef_error, api_error

    • codestringrequired

      Stable machine-readable code. All codes

      One of: parameter_missing, parameter_invalid, body_invalid_json, body_too_large, buyer_nip_missing, buyer_nip_invalid, order_not_paid, order_cancelled, currency_not_supported, vat_rate_missing, vat_rate_unsupported, order_unprocessable, correction_requires_invoice, livemode_mismatch, resource_missing, route_not_found, method_not_allowed, pdf_not_ready, api_key_missing, api_key_invalid, live_mode_disabled, idempotency_key_reused, idempotency_key_invalid, rate_limited, internal_error, seller_not_configured, plan_limit_reached, invoice_build_failed, invoice_schema_invalid, original_not_invoiced, original_rejected, ksef_not_connected, ksef_auth_failed, ksef_duplicate_number, ksef_rejected, ksef_unavailable

    • messagestringrequired

      Human-readable text; may change.

    • paramstring

      JSON path of the parameter

    • ksef_codeinteger

      KSeF's own numeric code (e.g. 440 duplicate

    • doc_urlstringrequired

      Link to the code on the errors page.

  • createdintegerrequired

    Created (Unix seconds).

  • updatedintegerrequired

    Last change (Unix seconds).

  • invoicestring | nullrequired

    Id of the corrected invoice.

  • refundobjectrequired

    The refund the correction comes from.

    Show fields
    • external_idstringrequired

      Your refund id.

Object Correction
{
  "id": "cor_8hG3jK2lMnBvCxZ1aS4dF6gH",
  "object": "correction",
  "livemode": false,
  "status": "pending",
  "order": {
    "external_id": "SO-1001",
    "number": null
  },
  "number": null,
  "ksef_number": null,
  "ksef_environment": "test",
  "issue_date": null,
  "currency": null,
  "total_gross": null,
  "buyer_nip": null,
  "pdf_url": null,
  "last_error": null,
  "created": 1760951000,
  "updated": 1760951000,
  "invoice": "inv_4fJ2kP9xQwErTy7uI0oPaSdF",
  "refund": {
    "external_id": "RF-1"
  }
}

List invoices

GET /v1/invoices

Invoices, newest first, with their corrections nested. Paginate with limit and starting_after; external_id returns the invoice of one order.

Parameters

  • limitquery · integer

    How many objects per page.

    Default 10 · 1-100

  • starting_afterquery · string

    Id of the last object of the previous page.

  • external_idquery · string

    Only the invoice of this order.

Responses

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

Create an invoice from a paid order

POST /v1/invoices

Takes a paid order and answers at once with an invoice in status pending. The queue numbers it, builds FA(3), sends it to KSeF and renders the PDF; usually it is accepted after 10-60 seconds. The buyer needs a valid Polish NIP.

Send order (neutral format, gross prices) or woocommerce_order (a WooCommerce REST API v3 order). The same external_id returns the existing invoice with 200 instead of 201.

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)

Exactly one of order or woocommerce_order.

  • orderOrder

    The order in the neutral format (gross prices, explicit VAT rates).

    Show fields
    • external_idstringrequired

      Your order id; one invoice per external_id.

    • numberstring

      Order number printed on the invoice (defaults to external_id).

    • created_atstring

      When the order was placed.

      ISO 8601 date and time

    • paid_atstringrequired

      Payment time; the tax point and the NBP rate date follow it.

      ISO 8601 date and time

    • currencystring

      PLN or a currency of NBP table A.

      Default PLN

    • payment_methodstring

      Payment method printed on the invoice.

      One of: card, transfer, cash, mobile · Default card

    • buyerobjectrequired

      The buyer, with a Polish NIP.

      Show fields
      • nipstringrequired

        Polish NIP

      • namestringrequired

        The buyer's company name.

      • address_line1stringrequired

        Street and number.

      • address_line2string

        Postal code and city.

      • emailstring

        The PDF is emailed here.

    • linesarray of OrderLinerequired

      Order lines.

      1-1000 items

      Show fields
      • namestringrequired

        Product or service name.

        max 512 characters

      • skustring

        Product code (optional).

      • quantityintegerrequired

        Quantity.

      • unit_pricedecimal stringrequired

        Amount as a string with a dot, e.g. "49.00"

      • discountdecimal string

        Amount as a string with a dot, e.g. "49.00"

      • vat_ratestringrequired

        VAT rate: 23, 8, 5 or 0 (0% domestic). Exempt supplies (zw) are not supported yet.

        One of: 23, 8, 5, 0

    • shippingarray of object

      Shipping charges as separate lines.

      Show fields
      • namestringrequired

        Shipping name, e.g. "Courier".

      • pricedecimal stringrequired

        Gross shipping price.

        Amount as a string with a dot, e.g. "49.00"

      • vat_ratestringrequired

        VAT rate of the shipping.

        One of: 23, 8, 5, 0

  • woocommerce_orderobject

    WooCommerce REST API v3 order (fields id, number, status, currency, dates, billing, meta_data with the NIP, line_items, shipping_lines, fee_lines, tax_lines).

Responses

POST /v1/invoices
curl -X POST https://app.ksefshop.pl/v1/invoices \
  -H "Authorization: Bearer $KSEF_API_KEY" \
  -H "Idempotency-Key: order-SO-1001" \
  -H "Content-Type: application/json" \
  -d '{
  "order": {
    "external_id": "SO-1001",
    "number": "1001",
    "paid_at": "2026-10-19T09:13:05Z",
    "currency": "PLN",
    "payment_method": "card",
    "buyer": {
      "nip": "5260250274",
      "name": "Testowa Firma sp. z o.o.",
      "address_line1": "ul. Prosta 20",
      "address_line2": "00-850 Warszawa",
      "email": "jan@example.com"
    },
    "lines": [
      {
        "name": "Kubek ceramiczny 350 ml",
        "sku": "KUB-350",
        "quantity": 2,
        "unit_price": "49.00",
        "vat_rate": "23"
      },
      {
        "name": "Książka: Podstawy księgowości",
        "sku": "KS-001",
        "quantity": 1,
        "unit_price": "59.90",
        "discount": "9.90",
        "vat_rate": "5"
      }
    ],
    "shipping": [
      {
        "name": "Kurier InPost",
        "price": "15.99",
        "vat_rate": "23"
      }
    ]
  }
}'
Response
{
  "id": "inv_4fJ2kP9xQwErTy7uI0oPaSdF",
  "object": "invoice",
  "livemode": false,
  "status": "accepted",
  "order": {
    "external_id": "SO-1001",
    "number": "1001"
  },
  "number": "FV/2026/10/1",
  "ksef_number": "4235405606-20261019-0E7570400000-57",
  "ksef_environment": "test",
  "issue_date": "2026-10-19",
  "currency": "PLN",
  "total_gross": "163.99",
  "buyer_nip": "5260250274",
  "pdf_url": "https://app.ksefshop.pl/pdf/cmgxa1b2c0000/Qk9tZ2FsX3ZhbGlkX3Rva2VuX2V4YW1w",
  "last_error": null,
  "created": 1760865185,
  "updated": 1760865214,
  "corrections": []
}

Retrieve an invoice or a correction

GET /v1/invoices/{id}

Returns an invoice (inv_..., with its corrections) or a correction (cor_...). Use it to check the status, the KSeF number and last_error.

Parameters

  • idpath · stringrequired

    The object's id.

    Prefix inv_ / cor_

Responses

GET /v1/invoices/{id}
curl https://app.ksefshop.pl/v1/invoices/inv_4fJ2kP9xQwErTy7uI0oPaSdF \
  -H "Authorization: Bearer $KSEF_API_KEY"
Response
{
  "id": "inv_4fJ2kP9xQwErTy7uI0oPaSdF",
  "object": "invoice",
  "livemode": false,
  "status": "accepted",
  "order": {
    "external_id": "SO-1001",
    "number": "1001"
  },
  "number": "FV/2026/10/1",
  "ksef_number": "4235405606-20261019-0E7570400000-57",
  "ksef_environment": "test",
  "issue_date": "2026-10-19",
  "currency": "PLN",
  "total_gross": "163.99",
  "buyer_nip": "5260250274",
  "pdf_url": "https://app.ksefshop.pl/pdf/cmgxa1b2c0000/Qk9tZ2FsX3ZhbGlkX3Rva2VuX2V4YW1w",
  "last_error": null,
  "created": 1760865185,
  "updated": 1760865214,
  "corrections": []
}

Download the PDF

GET /v1/invoices/{id}/pdf

The PDF in the Ministry of Finance layout, with the KSeF number and the KOD I verification QR code. While it renders you get 409 pdf_not_ready. For the buyer, share the public pdf_url of the invoice object instead.

Parameters

  • idpath · stringrequired

    The object's id.

    Prefix inv_ / cor_

Responses

GET /v1/invoices/{id}/pdf
curl https://app.ksefshop.pl/v1/invoices/inv_4fJ2kP9xQwErTy7uI0oPaSdF/pdf \
  -H "Authorization: Bearer $KSEF_API_KEY" \
  --fail -o invoice.pdf
Response
%PDF-1.7
… PDF file (application/pdf) with the KSeF number and QR code

Create a correction (refund)

POST /v1/invoices/{id}/corrections

A refund becomes a correction invoice (KOR, TypKorekty 2) with difference lines (negative quantities) referring to the original invoice's KSeF number. The queue waits until the original is accepted in KSeF.

Send refund (neutral format) or woocommerce_order plus woocommerce_refund.

Parameters

  • idpath · stringrequired

    The object's id.

    Prefix inv_

  • 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)

Either refund, or woocommerce_order + woocommerce_refund.

  • refundRefund

    The refund in the neutral format.

    Show fields
    • external_idstringrequired

      Your refund id; one correction per external_id.

    • reasonstring

      Correction reason printed on the invoice, e.g. "Returned goods".

    • created_atstring

      When the money was refunded.

      ISO 8601 date and time

    • linesarray of object

      Returned lines (at least one of lines or shipping).

      Show fields
      • namestringrequired

        Line name as on the invoice.

      • skustring

        Product code.

      • quantityintegerrequired

        Returned items (positive).

      • unit_pricedecimal stringrequired

        Gross unit price.

        Amount as a string with a dot, e.g. "49.00"

      • vat_ratestringrequired

        VAT rate of the line.

        One of: 23, 8, 5, 0

    • shippingobject

      Refunded shipping.

      Show fields
      • pricedecimal stringrequired

        Amount as a string with a dot, e.g. "49.00"

  • woocommerce_orderobject

    The WooCommerce order the refund belongs to.

  • woocommerce_refundobject

    WooCommerce REST API v3 refund.

Responses

POST /v1/invoices/{id}/corrections
curl -X POST https://app.ksefshop.pl/v1/invoices/inv_4fJ2kP9xQwErTy7uI0oPaSdF/corrections \
  -H "Authorization: Bearer $KSEF_API_KEY" \
  -H "Idempotency-Key: refund-RF-1" \
  -H "Content-Type: application/json" \
  -d '{
  "refund": {
    "external_id": "RF-1",
    "reason": "Zwrot towaru",
    "lines": [
      {
        "name": "Kubek ceramiczny 350 ml",
        "sku": "KUB-350",
        "quantity": 1,
        "unit_price": "49.00",
        "vat_rate": "23"
      }
    ],
    "shipping": {
      "price": "15.99"
    }
  }
}'
Response
{
  "id": "cor_8hG3jK2lMnBvCxZ1aS4dF6gH",
  "object": "correction",
  "livemode": false,
  "status": "pending",
  "order": {
    "external_id": "SO-1001",
    "number": null
  },
  "number": null,
  "ksef_number": null,
  "ksef_environment": "test",
  "issue_date": null,
  "currency": null,
  "total_gross": null,
  "buyer_nip": null,
  "pdf_url": null,
  "last_error": null,
  "created": 1760951000,
  "updated": 1760951000,
  "invoice": "inv_4fJ2kP9xQwErTy7uI0oPaSdF",
  "refund": {
    "external_id": "RF-1"
  }
}
KSeF Faktury

API early access

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