---
title: "Utwórz fakturę marża"
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 marża

`POST /margin_invoices.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`

## Query parameters

- `send_to_ksef` (`MarginInvoices_create.query.send_to_ksef`; boolean, optional)

## Request body

_Required._

- `margin_invoice` (`MarginInvoices_create.margin_invoice`; object, required)
  - `number` (`MarginInvoices_create.margin_invoice.number`; string, optional)
  - `check_duplicate_number` (`MarginInvoices_create.margin_invoice.check_duplicate_number`; boolean, optional) — Odrzuć żądanie, gdy istnieje faktura o tym samym numerze.
  - `currency` (`MarginInvoices_create.margin_invoice.currency`; string, optional)
  - `paid_price` (`MarginInvoices_create.margin_invoice.paid_price`; integer, optional) — Kwota w groszach (1/100 PLN). `12300` oznacza 123,00 PLN.
    - format `int64`
  - `left_to_pay` (`MarginInvoices_create.margin_invoice.left_to_pay`; integer, optional) — Kwota w groszach (1/100 PLN). `12300` oznacza 123,00 PLN.
    - format `int64`
  - `notes` (`MarginInvoices_create.margin_invoice.notes`; string, optional)
    - maxLength 5000
  - `payment_method` (`MarginInvoices_create.margin_invoice.payment_method`; string, optional) — Metoda płatności.
    - one of `"transfer"`, `"cash"`, `"card"`, `"barter"`, `"check"`, `"delivery"`, `"other"`, `"compensation"`, `"accredited"`, `"paypal"`, `"payu"`, `"bill_of_sale"`, `"subscription"`, `"instalment_sale"`, `"tpay"`, `"przelewy24"`, `"dotpay"`
  - `recipient_signature` (`MarginInvoices_create.margin_invoice.recipient_signature`; string, optional)
    - maxLength 255
  - `seller_signature` (`MarginInvoices_create.margin_invoice.seller_signature`; string, optional)
    - maxLength 255
  - `invoice_date` (`MarginInvoices_create.margin_invoice.invoice_date`; string, optional)
    - format `date`
  - `sale_date` (`MarginInvoices_create.margin_invoice.sale_date`; string, optional)
    - format `date`
  - `vat_date_value` (`MarginInvoices_create.margin_invoice.vat_date_value`; string, optional) — `sale_date`, `issue_date` albo `paid_date` (metoda kasowa).
    - one of `"sale_date"`, `"issue_date"`, `"paid_date"`
  - `occasional_sale` (`MarginInvoices_create.margin_invoice.occasional_sale`; boolean, optional)
  - `payment_date` (`MarginInvoices_create.margin_invoice.payment_date`; string, optional)
    - format `date`
  - `paid_date` (`MarginInvoices_create.margin_invoice.paid_date`; string, optional)
    - format `date`
  - `client_id` (`MarginInvoices_create.margin_invoice.client_id`; integer, optional) — ID istniejącego klienta; niewysłane pola klienta są z niego kopiowane. Bez `client_id` klient jest dopasowywany po `client_tax_code`, `client_company_name` albo `client_first_name` i `client_last_name` (zawężonych przez `client_business_activity_kind`), a gdy nie ma dopasowania, jest tworzony z pól `client_*`.
    - format `int64`
  - `client_company_name` (`MarginInvoices_create.margin_invoice.client_company_name`; string, optional)
  - `client_first_name` (`MarginInvoices_create.margin_invoice.client_first_name`; string, optional)
  - `client_last_name` (`MarginInvoices_create.margin_invoice.client_last_name`; string, optional)
  - `client_business_activity_kind` (`MarginInvoices_create.margin_invoice.client_business_activity_kind`; string, optional) — Forma prawna klienta.
    - one of `"private_person"`, `"self_employed"`, `"other_business"`
  - `client_street` (`MarginInvoices_create.margin_invoice.client_street`; string, optional)
  - `client_street_number` (`MarginInvoices_create.margin_invoice.client_street_number`; string, optional)
  - `client_flat_number` (`MarginInvoices_create.margin_invoice.client_flat_number`; string, optional)
  - `client_city` (`MarginInvoices_create.margin_invoice.client_city`; string, optional)
  - `client_post_code` (`MarginInvoices_create.margin_invoice.client_post_code`; string, optional)
  - `client_tax_code` (`MarginInvoices_create.margin_invoice.client_tax_code`; string, optional)
  - `client_country` (`MarginInvoices_create.margin_invoice.client_country`; string, optional) — Dwuliterowy kod kraju jak `alpha_2` w `GET /countries.json`: ISO 3166-1 alpha-2, z wyjątkiem `EL` dla Grecji (`GR` nie jest rozpoznawany) i `XI` dla Irlandii Północnej.
    - pattern `^[A-Z]{2}$`
  - `bank_account` (`MarginInvoices_create.margin_invoice.bank_account`; string, optional) — Musi być jednym z kont bankowych użytkownika (`GET /bank_accounts.json`); pominięty `swift` jest brany z tego konta.
  - `bank_name` (`MarginInvoices_create.margin_invoice.bank_name`; string, optional)
  - `swift` (`MarginInvoices_create.margin_invoice.swift`; string, optional)
  - `sale_type` (`MarginInvoices_create.margin_invoice.sale_type`; string, optional) — Wymagane dla klientów zagranicznych i sprzedaży z odwrotnym obciążeniem; ignorowane przy sprzedaży krajowej.
    - one of `"service"`, `"merchandise"`
  - `invoice_date_kind` (`MarginInvoices_create.margin_invoice.invoice_date_kind`; string, optional) — Rodzaj daty drukowanej obok daty sprzedaży.
    - one of `"sale_date"`, `"service_date"`, `"cargo_date"`, `"continuous_service_end_on"`
  - `document_markings_ids` (`MarginInvoices_create.margin_invoice.document_markings_ids`; array<string>, optional) — Najwyżej jedno ID oznaczenia dokumentu. Zobacz `GET /incomes_documents_markings.json`.
  - `bdo_code` (`MarginInvoices_create.margin_invoice.bdo_code`; string, optional) — Dziewięć cyfr.
    - pattern `^\d{9}$`
  - `not_income` (`MarginInvoices_create.margin_invoice.not_income`; boolean, optional)
  - `vat_exchange_date_kind` (`MarginInvoices_create.margin_invoice.vat_exchange_date_kind`; string, optional)
    - one of `"pit"`, `"vat"`
  - `sales_kind` (`MarginInvoices_create.margin_invoice.sales_kind`; string, optional)
    - one of `"sprzedaz_podstawowa"`, `"sprzedaz_pozostala"`
  - `ksef_number` (`MarginInvoices_create.margin_invoice.ksef_number`; string, optional)
  - `transaction_terms` (`MarginInvoices_create.margin_invoice.transaction_terms`; object, optional)
    - `contracts` (`MarginInvoices_create.margin_invoice.transaction_terms.contracts`; array<object>, optional)
      - `number` (`MarginInvoices_create.margin_invoice.transaction_terms.contracts.number`; string, required)
      - `date` (`MarginInvoices_create.margin_invoice.transaction_terms.contracts.date`; string, required)
        - format `date`
    - `orders` (`MarginInvoices_create.margin_invoice.transaction_terms.orders`; array<object>, optional)
      - `number` (`MarginInvoices_create.margin_invoice.transaction_terms.orders.number`; string, required)
      - `date` (`MarginInvoices_create.margin_invoice.transaction_terms.orders.date`; string, required)
        - format `date`
  - `local_government_recipient_address` (`MarginInvoices_create.margin_invoice.local_government_recipient_address`; object, optional) — Przy aktualizacji pominięcie tego pola usuwa istniejący adres.
    - `company_name` (`MarginInvoices_create.margin_invoice.local_government_recipient_address.company_name`; string, required)
    - `street` (`MarginInvoices_create.margin_invoice.local_government_recipient_address.street`; string, required)
      - maxLength 65
    - `building_number` (`MarginInvoices_create.margin_invoice.local_government_recipient_address.building_number`; string, required)
      - maxLength 9
    - `city` (`MarginInvoices_create.margin_invoice.local_government_recipient_address.city`; string, required)
    - `tax_id` (`MarginInvoices_create.margin_invoice.local_government_recipient_address.tax_id`; string, optional) — NIP.
    - `door_number` (`MarginInvoices_create.margin_invoice.local_government_recipient_address.door_number`; string, optional)
      - maxLength 10
    - `post_code` (`MarginInvoices_create.margin_invoice.local_government_recipient_address.post_code`; string, optional)
    - `country_id` (`MarginInvoices_create.margin_invoice.local_government_recipient_address.country_id`; integer, optional) — Liczbowe ID kraju (`GET /countries.json`); domyślnie Polska.
      - format `int64`
  - `local_government_seller_address` (`MarginInvoices_create.margin_invoice.local_government_seller_address`; object, optional) — Domyślnie adres z ustawień konta, gdy jego wyświetlanie na fakturach jest włączone.
    - `company_name` (`MarginInvoices_create.margin_invoice.local_government_seller_address.company_name`; string, required)
    - `street` (`MarginInvoices_create.margin_invoice.local_government_seller_address.street`; string, required)
      - maxLength 65
    - `building_number` (`MarginInvoices_create.margin_invoice.local_government_seller_address.building_number`; string, required)
      - maxLength 9
    - `city` (`MarginInvoices_create.margin_invoice.local_government_seller_address.city`; string, required)
    - `tax_id` (`MarginInvoices_create.margin_invoice.local_government_seller_address.tax_id`; string, optional) — NIP.
    - `door_number` (`MarginInvoices_create.margin_invoice.local_government_seller_address.door_number`; string, optional)
      - maxLength 10
    - `post_code` (`MarginInvoices_create.margin_invoice.local_government_seller_address.post_code`; string, optional)
    - `country_id` (`MarginInvoices_create.margin_invoice.local_government_seller_address.country_id`; integer, optional) — Liczbowe ID kraju (`GET /countries.json`); domyślnie Polska.
      - format `int64`
  - `third_party_addresses` (`MarginInvoices_create.margin_invoice.third_party_addresses`; array<object>, optional) — Podmioty trzecie w KSeF. Ignorowane przez `POST /invoices.json`; uwzględniane przy aktualizacji i przy tworzeniu asynchronicznym. Przy aktualizacji wpisy bez `id` są dodawane, a niewysłane istniejące adresy zostają.
    - `id` (`MarginInvoices_create.margin_invoice.third_party_addresses.id`; integer, optional) — Tylko przy aktualizacji: ID istniejącego adresu do zmiany lub usunięcia.
      - format `int64`
    - `_destroy` (`MarginInvoices_create.margin_invoice.third_party_addresses._destroy`; boolean, optional) — Tylko przy aktualizacji: usuń adres wskazany w `id`.
    - `company_name` (`MarginInvoices_create.margin_invoice.third_party_addresses.company_name`; string, optional) — Wymagane, chyba że `_destroy` ma wartość `true`.
    - `tax_id` (`MarginInvoices_create.margin_invoice.third_party_addresses.tax_id`; string, optional)
    - `street` (`MarginInvoices_create.margin_invoice.third_party_addresses.street`; string, optional)
    - `building_number` (`MarginInvoices_create.margin_invoice.third_party_addresses.building_number`; string, optional)
    - `door_number` (`MarginInvoices_create.margin_invoice.third_party_addresses.door_number`; string, optional)
    - `post_code` (`MarginInvoices_create.margin_invoice.third_party_addresses.post_code`; string, optional)
    - `city` (`MarginInvoices_create.margin_invoice.third_party_addresses.city`; string, optional)
    - `country_code` (`MarginInvoices_create.margin_invoice.third_party_addresses.country_code`; string, optional) — Kod kraju alpha-2; ma pierwszeństwo przed `country_id`.
      - pattern `^[A-Z]{2}$`
    - `country_id` (`MarginInvoices_create.margin_invoice.third_party_addresses.country_id`; integer, optional) — Liczbowe ID kraju (`GET /countries.json`).
      - format `int64`
    - `role_code` (`MarginInvoices_create.margin_invoice.third_party_addresses.role_code`; string, optional) — Rola podmiotu trzeciego w KSeF (`Podmiot3`), wymagana, chyba że `_destroy` ma wartość `true`: | Kod | Rola | |---|---| | `1` | Faktor | | `2` | Odbiorca | | `3` | Podmiot pierwotny | | `4` | Dodatkowy nabywca | | `5` | Wystawca faktury | | `6` | Dokonujący płatności | | `7` | JST – wystawca | | `8` | JST – odbiorca | | `9` | Członek grupy VAT – wystawca | | `10` | Członek grupy VAT – odbiorca | | `11` | Pracownik |
      - one of `"1"`, `"2"`, `"3"`, `"4"`, `"5"`, `"6"`, `"7"`, `"8"`, `"9"`, `"10"`, `"11"`
    - `internal_identifier` (`MarginInvoices_create.margin_invoice.third_party_addresses.internal_identifier`; string, optional) — Identyfikator wewnętrzny, np. `1234567890-00001`.
      - pattern `^[1-9]((\d[1-9])|([1-9]\d))\d{7}-\d{5}$`
  - `allow_correction` (`MarginInvoices_create.margin_invoice.allow_correction`; boolean, optional) — Potwierdź zmianę, która skoryguje złożone deklaracje; działa jak parametr zapytania `allow_correction`.
  - `margin_kind` (`MarginInvoices_create.margin_invoice.margin_kind`; string, optional) — Domyślnie `second_hand_goods`.
    - one of `"second_hand_goods"`, `"travel_agencies"`, `"works_of_art"`, `"collectables_and_antiques"`
  - `services` (`MarginInvoices_create.margin_invoice.services`; array<object>, optional) — Wymagana jest co najmniej jedna pozycja. Przy aktualizacji wysłana lista zastępuje wszystkie pozycje.
    - `name` (`MarginInvoices_create.margin_invoice.services.name`; string, required)
    - `gtu_id` (`MarginInvoices_create.margin_invoice.services.gtu_id`; integer, optional)
      - format `int64`
    - `unit` (`MarginInvoices_create.margin_invoice.services.unit`; string, optional)
    - `quantity` (`MarginInvoices_create.margin_invoice.services.quantity`; number, optional)
      - format `double`; default `1`
    - `gross_with_margin_amount_price` (`MarginInvoices_create.margin_invoice.services.gross_with_margin_amount_price`; integer, optional) — Cena sprzedaży z marżą.
      - format `int64`
    - `margin_amount_price` (`MarginInvoices_create.margin_invoice.services.margin_amount_price`; integer, optional) — Kwota marży; VAT nalicza się od niej według stawki podstawowej.
      - format `int64`
    - `flat_rate_tax_symbol` (`MarginInvoices_create.margin_invoice.services.flat_rate_tax_symbol`; string, optional)

## Example requests

### Samochód używany

```json
{
  "margin_invoice": {
    "client_id": 1003,
    "margin_kind": "second_hand_goods",
    "invoice_date": "2026-10-01",
    "sale_date": "2026-10-01",
    "payment_date": "2026-10-15",
    "payment_method": "transfer",
    "services": [
      {
        "name": "Samochód osobowy używany",
        "unit": "szt.",
        "quantity": 1,
        "gross_with_margin_amount_price": 1500000,
        "margin_amount_price": 300000
      }
    ]
  }
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url https://api.sandbox-infakt.pl/v3/margin_invoices.json \
  --header 'Content-Type: application/json' \
  --header 'X-inFakt-ApiKey: <X-inFakt-ApiKey>' \
  --data '
{
  "margin_invoice": {
    "client_id": 1003,
    "margin_kind": "second_hand_goods",
    "invoice_date": "2026-10-01",
    "sale_date": "2026-10-01",
    "payment_date": "2026-10-15",
    "payment_method": "transfer",
    "services": [
      {
        "name": "Samochód osobowy używany",
        "unit": "szt.",
        "quantity": 1,
        "gross_with_margin_amount_price": 1500000,
        "margin_amount_price": 300000
      }
    ]
  }
}
'
```

### TypeScript

```typescript
const url = 'https://api.sandbox-infakt.pl/v3/margin_invoices.json';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', 'X-inFakt-ApiKey': '<X-inFakt-ApiKey>'},
  body: JSON.stringify({
    margin_invoice: {
      client_id: 1003,
      margin_kind: 'second_hand_goods',
      invoice_date: '2026-10-01',
      sale_date: '2026-10-01',
      payment_date: '2026-10-15',
      payment_method: 'transfer',
      services: [
        {
          name: 'Samochód osobowy używany',
          unit: 'szt.',
          quantity: 1,
          gross_with_margin_amount_price: 1500000,
          margin_amount_price: 300000
        }
      ]
    }
  })
};

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_invoices.json"

payload = { "margin_invoice": {
        "client_id": 1003,
        "margin_kind": "second_hand_goods",
        "invoice_date": "2026-10-01",
        "sale_date": "2026-10-01",
        "payment_date": "2026-10-15",
        "payment_method": "transfer",
        "services": [
            {
                "name": "Samochód osobowy używany",
                "unit": "szt.",
                "quantity": 1,
                "gross_with_margin_amount_price": 1500000,
                "margin_amount_price": 300000
            }
        ]
    } }
headers = {
    "Content-Type": "application/json",
    "X-inFakt-ApiKey": "<X-inFakt-ApiKey>"
}

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

print(response.text)
```

## Responses

### 201

Utworzono

#### Example

```json
{
  "id": 2001,
  "uuid": "4c5d6e7f-8a9b-4c0d-9e1f-3a4b5c6d7e8f",
  "number": "1/MAR/10/2026",
  "currency": "PLN",
  "paid_price": 0,
  "notes": "",
  "kind": "margin",
  "payment_method": "transfer",
  "recipient_signature": "",
  "seller_signature": "",
  "invoice_date": "2026-10-01",
  "sale_date": "2026-10-01",
  "vat_date_value": "sale_date",
  "occasional_sale": false,
  "status": "draft",
  "payment_date": "2026-10-15",
  "paid_date": null,
  "gross_price": 1500000,
  "left_to_pay": 1500000,
  "client_id": 1003,
  "client_uuid": "aae6796c-30a9-4bc6-ae55-6b2f08a8a0f6",
  "client_company_name": "Pierwsza Testowa Spółka sp z o.o.",
  "client_first_name": null,
  "client_last_name": null,
  "client_business_activity_kind": "other_business",
  "client_street": "Lwowska",
  "client_street_number": "10",
  "client_flat_number": "17",
  "client_city": "Kraków",
  "client_post_code": "31-202",
  "client_tax_code": "2222222222",
  "client_country": "PL",
  "sale_type": "",
  "invoice_date_kind": "sale_date",
  "document_markings_ids": [
    "7"
  ],
  "bdo_code": null,
  "not_income": null,
  "vat_exchange_date_kind": null,
  "sales_kind": "sprzedaz_podstawowa",
  "amount_in_words": "piętnaście tysięcy PLN 0/100",
  "local_government_recipient_address": null,
  "third_party_addresses": [],
  "building_service": false,
  "created_at": "2026-10-01T09:30:00.000+02:00",
  "ksef_number": null,
  "transaction_terms": null,
  "ksef_data": null,
  "related_exchange_differences_internal_evidences": [],
  "margin_kind_id": 1,
  "margin_kind": "Procedura marży – towary używane",
  "margin_kind_symbol": "second_hand_goods",
  "margin_amount_price": 300000,
  "bank_account": "61109010140000071219812874",
  "bank_name": "PKO BP",
  "swift": "",
  "services": [
    {
      "id": 21,
      "name": "Samochód osobowy używany",
      "gtu_id": null,
      "unit": "szt.",
      "quantity": 1,
      "gross_with_margin_amount_price": 1500000,
      "margin_amount_price": 300000
    }
  ]
}
```

- `id` (`MarginInvoices_create.response.201.id`; integer, required)
  - format `int64`
- `uuid` (`MarginInvoices_create.response.201.uuid`; string, required)
  - format `uuid`
- `number` (`MarginInvoices_create.response.201.number`; string, required)
- `currency` (`MarginInvoices_create.response.201.currency`; string, required) — Kod ISO 4217.
- `paid_price` (`MarginInvoices_create.response.201.paid_price`; integer, required) — Kwota w groszach (1/100 PLN). `12300` oznacza 123,00 PLN.
  - format `int64`
- `kind` (`MarginInvoices_create.response.201.kind`; string, required)
  - one of `"vat"`, `"proforma"`, `"margin"`, `"advance"`, `"correction"`, `"margin_correction"`, `"margin_advance"`, `"final"`, `"margin_final"`, `"fiscal_report"`, `"internal"`
- `payment_method` (`MarginInvoices_create.response.201.payment_method`; any of, required)
  - any of: `PaymentMethod`, `null`
- `recipient_signature` (`MarginInvoices_create.response.201.recipient_signature`; string, required)
- `seller_signature` (`MarginInvoices_create.response.201.seller_signature`; string, required)
- `invoice_date` (`MarginInvoices_create.response.201.invoice_date`; string, required)
  - format `date`
- `sale_date` (`MarginInvoices_create.response.201.sale_date`; any of, required)
  - any of: `string`, `null`
- `vat_date_value` (`MarginInvoices_create.response.201.vat_date_value`; string, required) — Data powstania obowiązku VAT: `sale_date`, `issue_date` albo `paid_date` (metoda kasowa).
- `occasional_sale` (`MarginInvoices_create.response.201.occasional_sale`; boolean, required)
- `status` (`MarginInvoices_create.response.201.status`; string, required)
  - one of `"draft"`, `"sent"`, `"printed"`, `"unpaid"`, `"paid"`, `"scheduled"`
- `payment_date` (`MarginInvoices_create.response.201.payment_date`; any of, required)
  - any of: `string`, `null`
- `paid_date` (`MarginInvoices_create.response.201.paid_date`; any of, required)
  - any of: `string`, `null`
- `gross_price` (`MarginInvoices_create.response.201.gross_price`; integer, required) — Kwota w groszach (1/100 PLN). `12300` oznacza 123,00 PLN.
  - format `int64`
- `left_to_pay` (`MarginInvoices_create.response.201.left_to_pay`; integer, required) — Kwota w groszach (1/100 PLN). `12300` oznacza 123,00 PLN.
  - format `int64`
- `client_id` (`MarginInvoices_create.response.201.client_id`; any of, required)
  - any of: `integer`, `null`
- `client_uuid` (`MarginInvoices_create.response.201.client_uuid`; any of, required)
  - any of: `Uuid`, `null`
- `client_company_name` (`MarginInvoices_create.response.201.client_company_name`; any of, required)
  - any of: `string`, `null`
- `client_first_name` (`MarginInvoices_create.response.201.client_first_name`; any of, required)
  - any of: `string`, `null`
- `client_last_name` (`MarginInvoices_create.response.201.client_last_name`; any of, required)
  - any of: `string`, `null`
- `client_business_activity_kind` (`MarginInvoices_create.response.201.client_business_activity_kind`; any of, required)
  - any of: `BusinessActivityKind`, `null`
- `client_street` (`MarginInvoices_create.response.201.client_street`; any of, required)
  - any of: `string`, `null`
- `client_street_number` (`MarginInvoices_create.response.201.client_street_number`; any of, required)
  - any of: `string`, `null`
- `client_flat_number` (`MarginInvoices_create.response.201.client_flat_number`; any of, required)
  - any of: `string`, `null`
- `client_city` (`MarginInvoices_create.response.201.client_city`; any of, required)
  - any of: `string`, `null`
- `client_post_code` (`MarginInvoices_create.response.201.client_post_code`; any of, required)
  - any of: `string`, `null`
- `client_tax_code` (`MarginInvoices_create.response.201.client_tax_code`; string, required)
- `client_country` (`MarginInvoices_create.response.201.client_country`; any of, required)
  - any of: `CountryCode`, `null`
- `sale_type` (`MarginInvoices_create.response.201.sale_type`; string, required) — Tylko transakcje zagraniczne; w pozostałych `""`.
  - one of `"service"`, `"merchandise"`, `""`
- `invoice_date_kind` (`MarginInvoices_create.response.201.invoice_date_kind`; any of, required)
  - any of: `InvoiceDateKind`, `null`
- `document_markings_ids` (`MarginInvoices_create.response.201.document_markings_ids`; any of, required) — ID oznaczeń dokumentu jako stringi. Zobacz `GET /incomes_documents_markings.json`.
  - any of: `array<string>`, `null`
- `bdo_code` (`MarginInvoices_create.response.201.bdo_code`; any of, required)
  - any of: `string`, `null`
- `not_income` (`MarginInvoices_create.response.201.not_income`; any of, required)
  - any of: `boolean`, `null`
- `vat_exchange_date_kind` (`MarginInvoices_create.response.201.vat_exchange_date_kind`; any of, required)
  - any of: `string`, `null`
- `sales_kind` (`MarginInvoices_create.response.201.sales_kind`; string, required)
  - one of `"sprzedaz_podstawowa"`, `"sprzedaz_pozostala"`
- `amount_in_words` (`MarginInvoices_create.response.201.amount_in_words`; any of, required)
  - any of: `string`, `null`
- `local_government_recipient_address` (`MarginInvoices_create.response.201.local_government_recipient_address`; any of, required)
  - any of: `LocalGovernmentAddress`, `null`
- `third_party_addresses` (`MarginInvoices_create.response.201.third_party_addresses`; array<object>, required)
  - `id` (`MarginInvoices_create.response.201.third_party_addresses.id`; integer, required)
    - format `int64`
  - `company_name` (`MarginInvoices_create.response.201.third_party_addresses.company_name`; any of, required)
    - any of: `string`, `null`
  - `tax_id` (`MarginInvoices_create.response.201.third_party_addresses.tax_id`; any of, required)
    - any of: `string`, `null`
  - `street` (`MarginInvoices_create.response.201.third_party_addresses.street`; any of, required)
    - any of: `string`, `null`
  - `building_number` (`MarginInvoices_create.response.201.third_party_addresses.building_number`; any of, required)
    - any of: `string`, `null`
  - `door_number` (`MarginInvoices_create.response.201.third_party_addresses.door_number`; any of, required)
    - any of: `string`, `null`
  - `post_code` (`MarginInvoices_create.response.201.third_party_addresses.post_code`; any of, required)
    - any of: `string`, `null`
  - `city` (`MarginInvoices_create.response.201.third_party_addresses.city`; any of, required)
    - any of: `string`, `null`
  - `country_code` (`MarginInvoices_create.response.201.third_party_addresses.country_code`; any of, required)
    - any of: `CountryCode`, `null`
  - `role_code` (`MarginInvoices_create.response.201.third_party_addresses.role_code`; any of, required) — Kod roli podmiotu trzeciego w KSeF; zobacz `ThirdPartyAddressInput.role_code`.
    - any of: `string`, `null`
  - `internal_identifier` (`MarginInvoices_create.response.201.third_party_addresses.internal_identifier`; any of, required)
    - any of: `string`, `null`
- `building_service` (`MarginInvoices_create.response.201.building_service`; boolean, required)
- `created_at` (`MarginInvoices_create.response.201.created_at`; string, required)
  - format `date-time`
- `ksef_number` (`MarginInvoices_create.response.201.ksef_number`; any of, required)
  - any of: `string`, `null`
- `transaction_terms` (`MarginInvoices_create.response.201.transaction_terms`; any of, required)
  - any of: `TransactionTerms`, `null`
- `notes` (`MarginInvoices_create.response.201.notes`; any of, required)
  - any of: `string`, `null`
- `ksef_data` (`MarginInvoices_create.response.201.ksef_data`; any of, required)
  - any of: `InvoiceKsefData`, `KsefSendError`, `null`
- `related_exchange_differences_internal_evidences` (`MarginInvoices_create.response.201.related_exchange_differences_internal_evidences`; array<object>, required)
  - `id` (`MarginInvoices_create.response.201.related_exchange_differences_internal_evidences.id`; integer, required)
    - format `int64`
  - `number` (`MarginInvoices_create.response.201.related_exchange_differences_internal_evidences.number`; string, required)
  - `uuid` (`MarginInvoices_create.response.201.related_exchange_differences_internal_evidences.uuid`; string, required)
    - format `uuid`
- `margin_kind_id` (`MarginInvoices_create.response.201.margin_kind_id`; integer, required)
  - format `int64`
- `margin_kind` (`MarginInvoices_create.response.201.margin_kind`; string, required) — Nazwa procedury marży po polsku.
- `margin_kind_symbol` (`MarginInvoices_create.response.201.margin_kind_symbol`; string, required)
  - one of `"second_hand_goods"`, `"travel_agencies"`, `"works_of_art"`, `"collectables_and_antiques"`
- `margin_amount_price` (`MarginInvoices_create.response.201.margin_amount_price`; integer, required) — Łączna marża.
  - format `int64`
- `bank_account` (`MarginInvoices_create.response.201.bank_account`; any of, required) — Ustawione tylko dla metod płatności `transfer` i `accredited`.
  - any of: `string`, `null`
- `bank_name` (`MarginInvoices_create.response.201.bank_name`; any of, required)
  - any of: `string`, `null`
- `swift` (`MarginInvoices_create.response.201.swift`; any of, required)
  - any of: `string`, `null`
- `services` (`MarginInvoices_create.response.201.services`; array<object>, required)
  - `id` (`MarginInvoices_create.response.201.services.id`; integer, required)
    - format `int64`
  - `name` (`MarginInvoices_create.response.201.services.name`; string, required)
  - `gtu_id` (`MarginInvoices_create.response.201.services.gtu_id`; any of, required)
    - any of: `integer`, `null`
  - `unit` (`MarginInvoices_create.response.201.services.unit`; string, required) — `""`, gdy nie ustawiono.
  - `quantity` (`MarginInvoices_create.response.201.services.quantity`; number, required)
    - format `double`
  - `gross_with_margin_amount_price` (`MarginInvoices_create.response.201.services.gross_with_margin_amount_price`; integer, required) — Cena sprzedaży z marżą.
    - format `int64`
  - `margin_amount_price` (`MarginInvoices_create.response.201.services.margin_amount_price`; integer, required) — Kwota marży.
    - format `int64`
  - `flat_rate_tax_symbol` (`MarginInvoices_create.response.201.services.flat_rate_tax_symbol`; any of, optional) — Tylko u podatników na ryczałcie.
    - any of: `string`, `null`
- `previous_invoice_uuid` (`MarginInvoices_create.response.201.previous_invoice_uuid`; any of, optional) — Tylko w odpowiedzi `get`.
  - any of: `Uuid`, `null`
- `following_invoice_uuid` (`MarginInvoices_create.response.201.following_invoice_uuid`; any of, optional) — Tylko w odpowiedzi `get`.
  - any of: `Uuid`, `null`
- `client_vat_number_active` (`MarginInvoices_create.response.201.client_vat_number_active`; any of, optional) — Tylko w odpowiedzi `get`. Numer VAT klienta jest czynny w rejestrze VAT.
  - any of: `boolean`, `null`
- `show_sales_kind` (`MarginInvoices_create.response.201.show_sales_kind`; boolean, optional) — Tylko w odpowiedzi `get`.
- `exchange_rates_data` (`MarginInvoices_create.response.201.exchange_rates_data`; any of, optional) — Tylko w odpowiedzi `get`; `null` dla faktur w PLN.
  - any of: `ExchangeRatesData`, `null`
- `statuses` (`MarginInvoices_create.response.201.statuses`; array<object>, optional) — Tylko w odpowiedzi `get`.
  - `symbol` (`MarginInvoices_create.response.201.statuses.symbol`; string, required)
  - `name` (`MarginInvoices_create.response.201.statuses.name`; string, required)
  - `group` (`MarginInvoices_create.response.201.statuses.group`; string, required)
- `parent_invoice_data` (`MarginInvoices_create.response.201.parent_invoice_data`; any of, optional) — Tylko w odpowiedzi `get`. `null`, chyba że faktura VAT lub zaliczkowa została wystawiona z innego dokumentu.
  - any of: `ParentInvoiceData`, `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` (`MarginInvoices_create.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` (`MarginInvoices_create.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` (`MarginInvoices_create.response.401.limit`; string, optional) — Kod limitu planu, np. `limit_exceeded`, `plan_upgrade_needed`, `cant_add_client`.
- `type` (`MarginInvoices_create.response.401.type`; string, optional)
  - one of `"redirect"`, `"email_not_confirmed"`
- `url` (`MarginInvoices_create.response.401.url`; string, optional)
- `action_url` (`MarginInvoices_create.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` (`MarginInvoices_create.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` (`MarginInvoices_create.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` (`MarginInvoices_create.response.402.limit`; string, optional) — Kod limitu planu, np. `limit_exceeded`, `plan_upgrade_needed`, `cant_add_client`.
- `type` (`MarginInvoices_create.response.402.type`; string, optional)
  - one of `"redirect"`, `"email_not_confirmed"`
- `url` (`MarginInvoices_create.response.402.url`; string, optional)
- `action_url` (`MarginInvoices_create.response.402.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` (`MarginInvoices_create.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` (`MarginInvoices_create.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` (`MarginInvoices_create.response.406.limit`; string, optional) — Kod limitu planu, np. `limit_exceeded`, `plan_upgrade_needed`, `cant_add_client`.
- `type` (`MarginInvoices_create.response.406.type`; string, optional)
  - one of `"redirect"`, `"email_not_confirmed"`
- `url` (`MarginInvoices_create.response.406.url`; string, optional)
- `action_url` (`MarginInvoices_create.response.406.action_url`; string, optional)

### 422

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

#### Example

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

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


Source: https://docs.niebieskiorzel.pl/api/margin-invoices-json/create/index.md
