---
title: "Anuluj fakturę w KSeF"
description: "Zakres: `api:invoices:write`. Anuluje fakturę wysłaną do KSeF: wystawia do niej korektę, która zeruje jej wartości, i wysyła tę korektę do KSeF."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.niebieskiorzel.pl/llms.txt
> Use this file to discover all available pages before exploring further.

Path: inFakt API › Faktury VAT

`POST /invoices/{id}/cancel_ksef.json`

Zakres: `api:invoices:write`. Anuluje fakturę wysłaną do KSeF: wystawia do niej korektę, która zeruje jej wartości, i wysyła tę korektę do KSeF.

## Authentication

Requires one of the following:

- `ApiKey`, apiKey, in header, header `X-inFakt-ApiKey`
- `Token`, apiKey, in header, header `X-Token`

## Path parameters

- `id` (`Invoices_cancelInKsef.path.id`; string, required) — Liczbowe `id` albo `uuid` rekordu.

## Code samples

### cURL

```bash
curl --request POST \
  --url https://api.sandbox-infakt.pl/v3/invoices/999/cancel_ksef.json \
  --header 'X-inFakt-ApiKey: <X-inFakt-ApiKey>'
```

### TypeScript

```typescript
const url = 'https://api.sandbox-infakt.pl/v3/invoices/999/cancel_ksef.json';
const options = {method: 'POST', headers: {'X-inFakt-ApiKey': '<X-inFakt-ApiKey>'}};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.sandbox-infakt.pl/v3/invoices/999/cancel_ksef.json"

headers = {"X-inFakt-ApiKey": "<X-inFakt-ApiKey>"}

response = requests.post(url, headers=headers)

print(response.text)
```

## Responses

### 200

Sukces

#### Example

```json
{
  "request_uuid": "7c2e1d3f-9a5b-4c6d-8e7f-2b3c4d5e6f70",
  "invoice_uuid": "0e1f2a3b-4c5d-4e6f-8a7b-9c0d1e2f3a4b",
  "invoice_kind": "correction",
  "ksef_number": null,
  "status": "sent",
  "status_description": null,
  "timestamps": {
    "request_created_at": "2026-10-02 10:00:00 +0200",
    "request_finished_at": null
  }
}
```

- `request_uuid` (`Invoices_cancelInKsef.response.200.request_uuid`; any of, required) — `null` dla faktur odrzuconych przed wysyłką.
  - any of: `string`, `null`
- `invoice_uuid` (`Invoices_cancelInKsef.response.200.invoice_uuid`; any of, required)
  - any of: `Uuid`, `null`
- `invoice_kind` (`Invoices_cancelInKsef.response.200.invoice_kind`; any of, required)
  - any of: `InvoiceKind`, `null`
- `ksef_number` (`Invoices_cancelInKsef.response.200.ksef_number`; any of, required) — Numer KSeF nadany po przyjęciu.
  - any of: `string`, `null`
- `status` (`Invoices_cancelInKsef.response.200.status`; string, required) — `rejected` tylko w odpowiedziach zbiorczych, dla dokumentów, których w ogóle nie wysłano.
  - one of `"pending"`, `"sent"`, `"success"`, `"error"`, `"cancelled"`, `"rejected"`
- `status_description` (`Invoices_cancelInKsef.response.200.status_description`; any of, required)
  - any of: `string`, `null`
- `timestamps` (`Invoices_cancelInKsef.response.200.timestamps`; object, required)
  - `request_created_at` (`Invoices_cancelInKsef.response.200.timestamps.request_created_at`; string, required)
  - `request_finished_at` (`Invoices_cancelInKsef.response.200.timestamps.request_finished_at`; any of, required)
    - any of: `string`, `null`

### 401

Brak klucza API, nieprawidłowy klucz albo klucz bez wymaganego zakresu uprawnień.

#### Example

```json
{
  "error": "Zasób którego szukasz nie został znaleziony."
}
```

- `error` (`Invoices_cancelInKsef.response.401.error`; any of, optional) — Komunikat po polsku (po angielsku dla `429`). Niektóre akcje zamiast jednego tekstu zwracają listę komunikatów albo błędy walidacji według pól.
  - any of: `string`, `array<string>`, `object`
- `errors` (`Invoices_cancelInKsef.response.401.errors`; any of, optional) — Błędy walidacji według nazw pól API; na niektórych endpointach zwykły komunikat.
  - any of: `object`, `string`
- `limit` (`Invoices_cancelInKsef.response.401.limit`; string, optional) — Kod limitu planu, np. `limit_exceeded`, `plan_upgrade_needed`, `cant_add_client`.
- `type` (`Invoices_cancelInKsef.response.401.type`; string, optional)
  - one of `"redirect"`, `"email_not_confirmed"`
- `url` (`Invoices_cancelInKsef.response.401.url`; string, optional)
- `action_url` (`Invoices_cancelInKsef.response.401.action_url`; string, optional)

### 402

API niedostępne w obecnym planie (`limit: plan_upgrade_needed`) albo osiągnięty limit dokumentów.

#### Example

```json
{
  "error": "Zasób którego szukasz nie został znaleziony."
}
```

- `error` (`Invoices_cancelInKsef.response.402.error`; any of, optional) — Komunikat po polsku (po angielsku dla `429`). Niektóre akcje zamiast jednego tekstu zwracają listę komunikatów albo błędy walidacji według pól.
  - any of: `string`, `array<string>`, `object`
- `errors` (`Invoices_cancelInKsef.response.402.errors`; any of, optional) — Błędy walidacji według nazw pól API; na niektórych endpointach zwykły komunikat.
  - any of: `object`, `string`
- `limit` (`Invoices_cancelInKsef.response.402.limit`; string, optional) — Kod limitu planu, np. `limit_exceeded`, `plan_upgrade_needed`, `cant_add_client`.
- `type` (`Invoices_cancelInKsef.response.402.type`; string, optional)
  - one of `"redirect"`, `"email_not_confirmed"`
- `url` (`Invoices_cancelInKsef.response.402.url`; string, optional)
- `action_url` (`Invoices_cancelInKsef.response.402.action_url`; string, optional)

### 404

Nie znaleziono zasobu.

#### Example

```json
{
  "error": "Zasób którego szukasz nie został znaleziony."
}
```

- `error` (`Invoices_cancelInKsef.response.404.error`; any of, optional) — Komunikat po polsku (po angielsku dla `429`). Niektóre akcje zamiast jednego tekstu zwracają listę komunikatów albo błędy walidacji według pól.
  - any of: `string`, `array<string>`, `object`
- `errors` (`Invoices_cancelInKsef.response.404.errors`; any of, optional) — Błędy walidacji według nazw pól API; na niektórych endpointach zwykły komunikat.
  - any of: `object`, `string`
- `limit` (`Invoices_cancelInKsef.response.404.limit`; string, optional) — Kod limitu planu, np. `limit_exceeded`, `plan_upgrade_needed`, `cant_add_client`.
- `type` (`Invoices_cancelInKsef.response.404.type`; string, optional)
  - one of `"redirect"`, `"email_not_confirmed"`
- `url` (`Invoices_cancelInKsef.response.404.url`; string, optional)
- `action_url` (`Invoices_cancelInKsef.response.404.action_url`; string, optional)

### 406

Ścieżka nie kończy się na `.json`.

#### Example

```json
{
  "error": "Zasób którego szukasz nie został znaleziony."
}
```

- `error` (`Invoices_cancelInKsef.response.406.error`; any of, optional) — Komunikat po polsku (po angielsku dla `429`). Niektóre akcje zamiast jednego tekstu zwracają listę komunikatów albo błędy walidacji według pól.
  - any of: `string`, `array<string>`, `object`
- `errors` (`Invoices_cancelInKsef.response.406.errors`; any of, optional) — Błędy walidacji według nazw pól API; na niektórych endpointach zwykły komunikat.
  - any of: `object`, `string`
- `limit` (`Invoices_cancelInKsef.response.406.limit`; string, optional) — Kod limitu planu, np. `limit_exceeded`, `plan_upgrade_needed`, `cant_add_client`.
- `type` (`Invoices_cancelInKsef.response.406.type`; string, optional)
  - one of `"redirect"`, `"email_not_confirmed"`
- `url` (`Invoices_cancelInKsef.response.406.url`; string, optional)
- `action_url` (`Invoices_cancelInKsef.response.406.action_url`; string, optional)

### 422

Walidacja nie powiodła się; szczegóły w `errors`.

#### Example

```json
{
  "error": "Faktura nie została wysłana do KSeF."
}
```

- `error` (`Invoices_cancelInKsef.response.422.error`; any of, optional) — Komunikat po polsku (po angielsku dla `429`). Niektóre akcje zamiast jednego tekstu zwracają listę komunikatów albo błędy walidacji według pól.
  - any of: `string`, `array<string>`, `object`
- `errors` (`Invoices_cancelInKsef.response.422.errors`; any of, optional) — Błędy walidacji według nazw pól API; na niektórych endpointach zwykły komunikat.
  - any of: `object`, `string`
- `limit` (`Invoices_cancelInKsef.response.422.limit`; string, optional) — Kod limitu planu, np. `limit_exceeded`, `plan_upgrade_needed`, `cant_add_client`.
- `type` (`Invoices_cancelInKsef.response.422.type`; string, optional)
  - one of `"redirect"`, `"email_not_confirmed"`
- `url` (`Invoices_cancelInKsef.response.422.url`; string, optional)
- `action_url` (`Invoices_cancelInKsef.response.422.action_url`; string, optional)

### 423

Niepotwierdzony adres e-mail albo wymagana weryfikacja tożsamości.

#### Example

```json
{
  "error": "Zasób którego szukasz nie został znaleziony."
}
```

- `error` (`Invoices_cancelInKsef.response.423.error`; any of, optional) — Komunikat po polsku (po angielsku dla `429`). Niektóre akcje zamiast jednego tekstu zwracają listę komunikatów albo błędy walidacji według pól.
  - any of: `string`, `array<string>`, `object`
- `errors` (`Invoices_cancelInKsef.response.423.errors`; any of, optional) — Błędy walidacji według nazw pól API; na niektórych endpointach zwykły komunikat.
  - any of: `object`, `string`
- `limit` (`Invoices_cancelInKsef.response.423.limit`; string, optional) — Kod limitu planu, np. `limit_exceeded`, `plan_upgrade_needed`, `cant_add_client`.
- `type` (`Invoices_cancelInKsef.response.423.type`; string, optional)
  - one of `"redirect"`, `"email_not_confirmed"`
- `url` (`Invoices_cancelInKsef.response.423.url`; string, optional)
- `action_url` (`Invoices_cancelInKsef.response.423.action_url`; string, optional)

### 429

Przekroczony limit zapytań. Komunikat jest po angielsku, np. `API rate limit exceeded. Try again in 60 seconds.`

#### Example

```json
{
  "error": "Zasób którego szukasz nie został znaleziony."
}
```

- `error` (`Invoices_cancelInKsef.response.429.error`; any of, optional) — Komunikat po polsku (po angielsku dla `429`). Niektóre akcje zamiast jednego tekstu zwracają listę komunikatów albo błędy walidacji według pól.
  - any of: `string`, `array<string>`, `object`
- `errors` (`Invoices_cancelInKsef.response.429.errors`; any of, optional) — Błędy walidacji według nazw pól API; na niektórych endpointach zwykły komunikat.
  - any of: `object`, `string`
- `limit` (`Invoices_cancelInKsef.response.429.limit`; string, optional) — Kod limitu planu, np. `limit_exceeded`, `plan_upgrade_needed`, `cant_add_client`.
- `type` (`Invoices_cancelInKsef.response.429.type`; string, optional)
  - one of `"redirect"`, `"email_not_confirmed"`
- `url` (`Invoices_cancelInKsef.response.429.url`; string, optional)
- `action_url` (`Invoices_cancelInKsef.response.429.action_url`; string, optional)


Source: https://docs.niebieskiorzel.pl/api/invoices-cancel-in-ksef/index.md
