---
title: "Wyślij fakturę zaliczkową marża do KSeF"
description: "Zakres: `api:invoices:write`."
---

> 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 zaliczkowe marża

`POST /margin_advance_invoices/{uuid}/send_to_ksef.json`

Zakres: `api:invoices:write`.

## Authentication

Requires one of the following:

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

## Path parameters

- `uuid` (`MarginAdvanceInvoices_sendToKsef.path.uuid`; string, required)
  - format `uuid`

## Query parameters

- `allow_correction` (`MarginAdvanceInvoices_sendToKsef.query.allow_correction`; boolean, optional) — Potwierdź akcję, która skoryguje złożone deklaracje (zamknięty okres księgowy). Bez tego takie żądania zwracają `422` z `errors.allow_correction` albo `errors.locked_accounting`, gdy plan nie pozwala na korekty (wtedy ta flaga jest ignorowana). Można też podać w treści żądania.

## Request body

_Optional._

- `inform_via_email` (`MarginAdvanceInvoices_sendToKsef.inform_via_email`; object, optional) — Zapisuje opcje wysyłki e-mailem, tak jak `save_email_data`. Nieprawidłowe opcje dają `422`.
  - `recipient` (`MarginAdvanceInvoices_sendToKsef.inform_via_email.recipient`; string, optional) — Adresy rozdzielone przecinkami; domyślnie e-mail klienta.
  - `print_type` (`MarginAdvanceInvoices_sendToKsef.inform_via_email.print_type`; string, optional)
    - one of `"original"`, `"copy"`, `"original_copy"`, `"original_duplicate"`, `"copy_duplicate"`, `"duplicate"`, `"regular"`, `"double_regular"`; default `"regular"`
  - `locale` (`MarginAdvanceInvoices_sendToKsef.inform_via_email.locale`; string, optional)
    - one of `"pl"`, `"en"`, `"pe"`; default `"pl"`
  - `send_copy` (`MarginAdvanceInvoices_sendToKsef.inform_via_email.send_copy`; boolean, optional) — Wyślij kopię do właściciela konta.
    - default `false`
  - `content` (`MarginAdvanceInvoices_sendToKsef.inform_via_email.content`; string, optional) — Treść wiadomości.
  - `send_to_ksef` (`MarginAdvanceInvoices_sendToKsef.inform_via_email.send_to_ksef`; boolean, optional)
    - default `false`
  - `send_via_email` (`MarginAdvanceInvoices_sendToKsef.inform_via_email.send_via_email`; boolean, optional)
    - default `false`
  - `quick_payments` (`MarginAdvanceInvoices_sendToKsef.inform_via_email.quick_payments`; boolean, optional)
    - default `false`

## Example request

```json
{
  "inform_via_email": {
    "recipient": "string",
    "print_type": "original",
    "locale": "pl",
    "send_copy": false,
    "content": "string",
    "send_to_ksef": false,
    "send_via_email": false,
    "quick_payments": false
  }
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url https://api.sandbox-infakt.pl/v3/margin_advance_invoices/9bdc76fd-7a02-42ec-a4a3-42bc867b9a9f/send_to_ksef.json \
  --header 'Content-Type: application/json' \
  --header 'X-inFakt-ApiKey: <X-inFakt-ApiKey>' \
  --data '
{
  "inform_via_email": {
    "recipient": "string",
    "print_type": "original",
    "locale": "pl",
    "send_copy": false,
    "content": "string",
    "send_to_ksef": false,
    "send_via_email": false,
    "quick_payments": false
  }
}
'
```

### TypeScript

```typescript
const url = 'https://api.sandbox-infakt.pl/v3/margin_advance_invoices/9bdc76fd-7a02-42ec-a4a3-42bc867b9a9f/send_to_ksef.json';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', 'X-inFakt-ApiKey': '<X-inFakt-ApiKey>'},
  body: JSON.stringify({
    inform_via_email: {
      recipient: 'string',
      print_type: 'original',
      locale: 'pl',
      send_copy: false,
      content: 'string',
      send_to_ksef: false,
      send_via_email: false,
      quick_payments: false
    }
  })
};

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/margin_advance_invoices/9bdc76fd-7a02-42ec-a4a3-42bc867b9a9f/send_to_ksef.json"

payload = { "inform_via_email": {
        "recipient": "string",
        "print_type": "original",
        "locale": "pl",
        "send_copy": False,
        "content": "string",
        "send_to_ksef": False,
        "send_via_email": False,
        "quick_payments": False
    } }
headers = {
    "Content-Type": "application/json",
    "X-inFakt-ApiKey": "<X-inFakt-ApiKey>"
}

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

print(response.text)
```

## Responses

### 200

Sukces

#### Example

```json
{
  "request_uuid": "5b1f0c2e-8d4a-4b7e-9f3c-1a2b3c4d5e6f",
  "invoice_uuid": "9bdc76fd-7a02-42ec-a4a3-42bc867b9a9f",
  "invoice_kind": "vat",
  "ksef_number": null,
  "status": "sent",
  "status_description": null,
  "timestamps": {
    "request_created_at": "2026-10-01 09:31:00 +0200",
    "request_finished_at": null
  }
}
```

- `request_uuid` (`MarginAdvanceInvoices_sendToKsef.response.200.request_uuid`; any of, required) — `null` dla faktur odrzuconych przed wysyłką.
  - any of: `string`, `null`
- `invoice_uuid` (`MarginAdvanceInvoices_sendToKsef.response.200.invoice_uuid`; any of, required)
  - any of: `Uuid`, `null`
- `invoice_kind` (`MarginAdvanceInvoices_sendToKsef.response.200.invoice_kind`; any of, required)
  - any of: `InvoiceKind`, `null`
- `ksef_number` (`MarginAdvanceInvoices_sendToKsef.response.200.ksef_number`; any of, required) — Numer KSeF nadany po przyjęciu.
  - any of: `string`, `null`
- `status` (`MarginAdvanceInvoices_sendToKsef.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` (`MarginAdvanceInvoices_sendToKsef.response.200.status_description`; any of, required)
  - any of: `string`, `null`
- `timestamps` (`MarginAdvanceInvoices_sendToKsef.response.200.timestamps`; object, required)
  - `request_created_at` (`MarginAdvanceInvoices_sendToKsef.response.200.timestamps.request_created_at`; string, required)
  - `request_finished_at` (`MarginAdvanceInvoices_sendToKsef.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` (`MarginAdvanceInvoices_sendToKsef.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` (`MarginAdvanceInvoices_sendToKsef.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` (`MarginAdvanceInvoices_sendToKsef.response.401.limit`; string, optional) — Kod limitu planu, np. `limit_exceeded`, `plan_upgrade_needed`, `cant_add_client`.
- `type` (`MarginAdvanceInvoices_sendToKsef.response.401.type`; string, optional)
  - one of `"redirect"`, `"email_not_confirmed"`
- `url` (`MarginAdvanceInvoices_sendToKsef.response.401.url`; string, optional)
- `action_url` (`MarginAdvanceInvoices_sendToKsef.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` (`MarginAdvanceInvoices_sendToKsef.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` (`MarginAdvanceInvoices_sendToKsef.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` (`MarginAdvanceInvoices_sendToKsef.response.402.limit`; string, optional) — Kod limitu planu, np. `limit_exceeded`, `plan_upgrade_needed`, `cant_add_client`.
- `type` (`MarginAdvanceInvoices_sendToKsef.response.402.type`; string, optional)
  - one of `"redirect"`, `"email_not_confirmed"`
- `url` (`MarginAdvanceInvoices_sendToKsef.response.402.url`; string, optional)
- `action_url` (`MarginAdvanceInvoices_sendToKsef.response.402.action_url`; string, optional)

### 404

Nie znaleziono zasobu.

#### Example

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

- `error` (`MarginAdvanceInvoices_sendToKsef.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` (`MarginAdvanceInvoices_sendToKsef.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` (`MarginAdvanceInvoices_sendToKsef.response.404.limit`; string, optional) — Kod limitu planu, np. `limit_exceeded`, `plan_upgrade_needed`, `cant_add_client`.
- `type` (`MarginAdvanceInvoices_sendToKsef.response.404.type`; string, optional)
  - one of `"redirect"`, `"email_not_confirmed"`
- `url` (`MarginAdvanceInvoices_sendToKsef.response.404.url`; string, optional)
- `action_url` (`MarginAdvanceInvoices_sendToKsef.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` (`MarginAdvanceInvoices_sendToKsef.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` (`MarginAdvanceInvoices_sendToKsef.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` (`MarginAdvanceInvoices_sendToKsef.response.406.limit`; string, optional) — Kod limitu planu, np. `limit_exceeded`, `plan_upgrade_needed`, `cant_add_client`.
- `type` (`MarginAdvanceInvoices_sendToKsef.response.406.type`; string, optional)
  - one of `"redirect"`, `"email_not_confirmed"`
- `url` (`MarginAdvanceInvoices_sendToKsef.response.406.url`; string, optional)
- `action_url` (`MarginAdvanceInvoices_sendToKsef.response.406.action_url`; string, optional)

### 422

Akcja odrzucona.

#### Example

```json
{
  "errors": {},
  "error": "string"
}
```

- `errors` (`MarginAdvanceInvoices_sendToKsef.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`
- `error` (`MarginAdvanceInvoices_sendToKsef.response.422.error`; any of, optional)
  - any of: `string`, `array<string>`, `object`

### 423

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

#### Example

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

- `error` (`MarginAdvanceInvoices_sendToKsef.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` (`MarginAdvanceInvoices_sendToKsef.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` (`MarginAdvanceInvoices_sendToKsef.response.423.limit`; string, optional) — Kod limitu planu, np. `limit_exceeded`, `plan_upgrade_needed`, `cant_add_client`.
- `type` (`MarginAdvanceInvoices_sendToKsef.response.423.type`; string, optional)
  - one of `"redirect"`, `"email_not_confirmed"`
- `url` (`MarginAdvanceInvoices_sendToKsef.response.423.url`; string, optional)
- `action_url` (`MarginAdvanceInvoices_sendToKsef.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` (`MarginAdvanceInvoices_sendToKsef.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` (`MarginAdvanceInvoices_sendToKsef.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` (`MarginAdvanceInvoices_sendToKsef.response.429.limit`; string, optional) — Kod limitu planu, np. `limit_exceeded`, `plan_upgrade_needed`, `cant_add_client`.
- `type` (`MarginAdvanceInvoices_sendToKsef.response.429.type`; string, optional)
  - one of `"redirect"`, `"email_not_confirmed"`
- `url` (`MarginAdvanceInvoices_sendToKsef.response.429.url`; string, optional)
- `action_url` (`MarginAdvanceInvoices_sendToKsef.response.429.action_url`; string, optional)


Source: https://docs.niebieskiorzel.pl/api/margin-advance-invoices-send-to-ksef/index.md
