---
title: "Utwórz fakturę zaliczkową asynchronicznie"
description: "Zakres: `api:invoices:write`. Kolejkuje utworzenie dokumentu i zwraca zadanie.\nTreść żądania jest taka sama jak w synchronicznym endpoincie tworzenia."
---

> 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

`POST /async/advance_invoices.json`

Zakres: `api:invoices:write`. Kolejkuje utworzenie dokumentu i zwraca zadanie.
Treść żądania jest taka sama jak w synchronicznym endpoincie tworzenia.

## 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` (`AdvanceInvoices_createAsync.query.send_to_ksef`; boolean, optional) — Wyślij dokument do KSeF po utworzeniu.
- `allow_correction` (`AdvanceInvoices_createAsync.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

_Required._

- `advance_invoice` (`AdvanceInvoices_createAsync.advance_invoice`; object, required)
  - `number` (`AdvanceInvoices_createAsync.advance_invoice.number`; string, optional)
  - `check_duplicate_number` (`AdvanceInvoices_createAsync.advance_invoice.check_duplicate_number`; boolean, optional) — Odrzuć żądanie, gdy istnieje faktura o tym samym numerze.
  - `kind` (`AdvanceInvoices_createAsync.advance_invoice.kind`; string, optional)
    - one of `"vat"`, `"proforma"`, `"margin"`, `"advance"`, `"correction"`, `"margin_correction"`, `"margin_advance"`, `"final"`, `"margin_final"`, `"fiscal_report"`, `"internal"`
  - `currency` (`AdvanceInvoices_createAsync.advance_invoice.currency`; string, optional)
  - `left_to_pay` (`AdvanceInvoices_createAsync.advance_invoice.left_to_pay`; integer, optional) — Kwota w groszach (1/100 PLN). `12300` oznacza 123,00 PLN.
    - format `int64`
  - `notes` (`AdvanceInvoices_createAsync.advance_invoice.notes`; string, optional)
    - maxLength 5000
  - `payment_method` (`AdvanceInvoices_createAsync.advance_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"`
  - `split_payment` (`AdvanceInvoices_createAsync.advance_invoice.split_payment`; boolean, optional)
  - `split_payment_type` (`AdvanceInvoices_createAsync.advance_invoice.split_payment_type`; string, optional)
    - one of `"required"`, `"optional"`
  - `recipient_signature` (`AdvanceInvoices_createAsync.advance_invoice.recipient_signature`; string, optional)
    - maxLength 255
  - `seller_signature` (`AdvanceInvoices_createAsync.advance_invoice.seller_signature`; string, optional)
    - maxLength 255
  - `invoice_date` (`AdvanceInvoices_createAsync.advance_invoice.invoice_date`; string, optional)
    - format `date`
  - `vat_date_value` (`AdvanceInvoices_createAsync.advance_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` (`AdvanceInvoices_createAsync.advance_invoice.occasional_sale`; boolean, optional)
  - `payment_date` (`AdvanceInvoices_createAsync.advance_invoice.payment_date`; string, optional)
    - format `date`
  - `paid_date` (`AdvanceInvoices_createAsync.advance_invoice.paid_date`; string, optional)
    - format `date`
  - `client_id` (`AdvanceInvoices_createAsync.advance_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` (`AdvanceInvoices_createAsync.advance_invoice.client_company_name`; string, optional)
  - `client_first_name` (`AdvanceInvoices_createAsync.advance_invoice.client_first_name`; string, optional)
  - `client_last_name` (`AdvanceInvoices_createAsync.advance_invoice.client_last_name`; string, optional)
  - `client_business_activity_kind` (`AdvanceInvoices_createAsync.advance_invoice.client_business_activity_kind`; string, optional) — Forma prawna klienta.
    - one of `"private_person"`, `"self_employed"`, `"other_business"`
  - `client_street` (`AdvanceInvoices_createAsync.advance_invoice.client_street`; string, optional)
  - `client_street_number` (`AdvanceInvoices_createAsync.advance_invoice.client_street_number`; string, optional)
  - `client_flat_number` (`AdvanceInvoices_createAsync.advance_invoice.client_flat_number`; string, optional)
  - `client_city` (`AdvanceInvoices_createAsync.advance_invoice.client_city`; string, optional)
  - `client_post_code` (`AdvanceInvoices_createAsync.advance_invoice.client_post_code`; string, optional)
  - `client_tax_code` (`AdvanceInvoices_createAsync.advance_invoice.client_tax_code`; string, optional)
  - `client_country` (`AdvanceInvoices_createAsync.advance_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` (`AdvanceInvoices_createAsync.advance_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` (`AdvanceInvoices_createAsync.advance_invoice.bank_name`; string, optional)
  - `swift` (`AdvanceInvoices_createAsync.advance_invoice.swift`; string, optional)
  - `vat_exemption_reason` (`AdvanceInvoices_createAsync.advance_invoice.vat_exemption_reason`; integer, optional) — Wymagane, gdy pozycja ma stawkę VAT `zw`.
    - format `int64`
  - `sale_type` (`AdvanceInvoices_createAsync.advance_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` (`AdvanceInvoices_createAsync.advance_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` (`AdvanceInvoices_createAsync.advance_invoice.document_markings_ids`; array<string>, optional) — Najwyżej jedno ID oznaczenia dokumentu. Zobacz `GET /incomes_documents_markings.json`.
  - `transaction_kind_id` (`AdvanceInvoices_createAsync.advance_invoice.transaction_kind_id`; integer, optional)
    - format `int64`
  - `bdo_code` (`AdvanceInvoices_createAsync.advance_invoice.bdo_code`; string, optional) — Dziewięć cyfr.
    - pattern `^\d{9}$`
  - `receipt_number` (`AdvanceInvoices_createAsync.advance_invoice.receipt_number`; string, optional)
  - `not_income` (`AdvanceInvoices_createAsync.advance_invoice.not_income`; boolean, optional)
  - `vat_exchange_date_kind` (`AdvanceInvoices_createAsync.advance_invoice.vat_exchange_date_kind`; string, optional)
    - one of `"pit"`, `"vat"`
  - `sales_kind` (`AdvanceInvoices_createAsync.advance_invoice.sales_kind`; string, optional)
    - one of `"sprzedaz_podstawowa"`, `"sprzedaz_pozostala"`
  - `ksef_number` (`AdvanceInvoices_createAsync.advance_invoice.ksef_number`; string, optional)
  - `transaction_terms` (`AdvanceInvoices_createAsync.advance_invoice.transaction_terms`; object, optional)
    - `contracts` (`AdvanceInvoices_createAsync.advance_invoice.transaction_terms.contracts`; array<object>, optional)
      - `number` (`AdvanceInvoices_createAsync.advance_invoice.transaction_terms.contracts.number`; string, required)
      - `date` (`AdvanceInvoices_createAsync.advance_invoice.transaction_terms.contracts.date`; string, required)
        - format `date`
    - `orders` (`AdvanceInvoices_createAsync.advance_invoice.transaction_terms.orders`; array<object>, optional)
      - `number` (`AdvanceInvoices_createAsync.advance_invoice.transaction_terms.orders.number`; string, required)
      - `date` (`AdvanceInvoices_createAsync.advance_invoice.transaction_terms.orders.date`; string, required)
        - format `date`
  - `local_government_recipient_address` (`AdvanceInvoices_createAsync.advance_invoice.local_government_recipient_address`; object, optional) — Przy aktualizacji pominięcie tego pola usuwa istniejący adres.
    - `company_name` (`AdvanceInvoices_createAsync.advance_invoice.local_government_recipient_address.company_name`; string, required)
    - `street` (`AdvanceInvoices_createAsync.advance_invoice.local_government_recipient_address.street`; string, required)
      - maxLength 65
    - `building_number` (`AdvanceInvoices_createAsync.advance_invoice.local_government_recipient_address.building_number`; string, required)
      - maxLength 9
    - `city` (`AdvanceInvoices_createAsync.advance_invoice.local_government_recipient_address.city`; string, required)
    - `tax_id` (`AdvanceInvoices_createAsync.advance_invoice.local_government_recipient_address.tax_id`; string, optional) — NIP.
    - `door_number` (`AdvanceInvoices_createAsync.advance_invoice.local_government_recipient_address.door_number`; string, optional)
      - maxLength 10
    - `post_code` (`AdvanceInvoices_createAsync.advance_invoice.local_government_recipient_address.post_code`; string, optional)
    - `country_id` (`AdvanceInvoices_createAsync.advance_invoice.local_government_recipient_address.country_id`; integer, optional) — Liczbowe ID kraju (`GET /countries.json`); domyślnie Polska.
      - format `int64`
  - `local_government_seller_address` (`AdvanceInvoices_createAsync.advance_invoice.local_government_seller_address`; object, optional) — Domyślnie adres z ustawień konta, gdy jego wyświetlanie na fakturach jest włączone.
    - `company_name` (`AdvanceInvoices_createAsync.advance_invoice.local_government_seller_address.company_name`; string, required)
    - `street` (`AdvanceInvoices_createAsync.advance_invoice.local_government_seller_address.street`; string, required)
      - maxLength 65
    - `building_number` (`AdvanceInvoices_createAsync.advance_invoice.local_government_seller_address.building_number`; string, required)
      - maxLength 9
    - `city` (`AdvanceInvoices_createAsync.advance_invoice.local_government_seller_address.city`; string, required)
    - `tax_id` (`AdvanceInvoices_createAsync.advance_invoice.local_government_seller_address.tax_id`; string, optional) — NIP.
    - `door_number` (`AdvanceInvoices_createAsync.advance_invoice.local_government_seller_address.door_number`; string, optional)
      - maxLength 10
    - `post_code` (`AdvanceInvoices_createAsync.advance_invoice.local_government_seller_address.post_code`; string, optional)
    - `country_id` (`AdvanceInvoices_createAsync.advance_invoice.local_government_seller_address.country_id`; integer, optional) — Liczbowe ID kraju (`GET /countries.json`); domyślnie Polska.
      - format `int64`
  - `third_party_addresses` (`AdvanceInvoices_createAsync.advance_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` (`AdvanceInvoices_createAsync.advance_invoice.third_party_addresses.id`; integer, optional) — Tylko przy aktualizacji: ID istniejącego adresu do zmiany lub usunięcia.
      - format `int64`
    - `_destroy` (`AdvanceInvoices_createAsync.advance_invoice.third_party_addresses._destroy`; boolean, optional) — Tylko przy aktualizacji: usuń adres wskazany w `id`.
    - `company_name` (`AdvanceInvoices_createAsync.advance_invoice.third_party_addresses.company_name`; string, optional) — Wymagane, chyba że `_destroy` ma wartość `true`.
    - `tax_id` (`AdvanceInvoices_createAsync.advance_invoice.third_party_addresses.tax_id`; string, optional)
    - `street` (`AdvanceInvoices_createAsync.advance_invoice.third_party_addresses.street`; string, optional)
    - `building_number` (`AdvanceInvoices_createAsync.advance_invoice.third_party_addresses.building_number`; string, optional)
    - `door_number` (`AdvanceInvoices_createAsync.advance_invoice.third_party_addresses.door_number`; string, optional)
    - `post_code` (`AdvanceInvoices_createAsync.advance_invoice.third_party_addresses.post_code`; string, optional)
    - `city` (`AdvanceInvoices_createAsync.advance_invoice.third_party_addresses.city`; string, optional)
    - `country_code` (`AdvanceInvoices_createAsync.advance_invoice.third_party_addresses.country_code`; string, optional) — Kod kraju alpha-2; ma pierwszeństwo przed `country_id`.
      - pattern `^[A-Z]{2}$`
    - `country_id` (`AdvanceInvoices_createAsync.advance_invoice.third_party_addresses.country_id`; integer, optional) — Liczbowe ID kraju (`GET /countries.json`).
      - format `int64`
    - `role_code` (`AdvanceInvoices_createAsync.advance_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` (`AdvanceInvoices_createAsync.advance_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` (`AdvanceInvoices_createAsync.advance_invoice.allow_correction`; boolean, optional) — Potwierdź zmianę, która skoryguje złożone deklaracje; działa jak parametr zapytania `allow_correction`.
  - `services` (`AdvanceInvoices_createAsync.advance_invoice.services`; array<object>, optional) — Przy aktualizacji wysłana lista zastępuje wszystkie pozycje.
    - `name` (`AdvanceInvoices_createAsync.advance_invoice.services.name`; string, required)
    - `tax_symbol` (`AdvanceInvoices_createAsync.advance_invoice.services.tax_symbol`; string, required) — Symbol stawki VAT. Zobacz `GET /vat_rates.json`.
    - `unit` (`AdvanceInvoices_createAsync.advance_invoice.services.unit`; string, optional)
    - `quantity` (`AdvanceInvoices_createAsync.advance_invoice.services.quantity`; number, optional)
      - format `double`; default `1`
    - `unit_net_price` (`AdvanceInvoices_createAsync.advance_invoice.services.unit_net_price`; integer, optional) — Kwota w groszach (1/100 PLN). `12300` oznacza 123,00 PLN.
      - format `int64`
    - `net_price` (`AdvanceInvoices_createAsync.advance_invoice.services.net_price`; integer, optional) — Kwota w groszach (1/100 PLN). `12300` oznacza 123,00 PLN.
      - format `int64`
    - `gross_price` (`AdvanceInvoices_createAsync.advance_invoice.services.gross_price`; integer, optional) — Kwota w groszach (1/100 PLN). `12300` oznacza 123,00 PLN.
      - format `int64`
    - `tax_price` (`AdvanceInvoices_createAsync.advance_invoice.services.tax_price`; integer, optional) — Kwota w groszach (1/100 PLN). `12300` oznacza 123,00 PLN.
      - format `int64`
    - `symbol` (`AdvanceInvoices_createAsync.advance_invoice.services.symbol`; string, optional)
    - `pkwiu` (`AdvanceInvoices_createAsync.advance_invoice.services.pkwiu`; string, optional)
    - `cn` (`AdvanceInvoices_createAsync.advance_invoice.services.cn`; string, optional)
    - `pkob` (`AdvanceInvoices_createAsync.advance_invoice.services.pkob`; string, optional)
    - `gtin` (`AdvanceInvoices_createAsync.advance_invoice.services.gtin`; string, optional)
    - `flat_rate_tax_symbol` (`AdvanceInvoices_createAsync.advance_invoice.services.flat_rate_tax_symbol`; string, optional) — Stawka ryczałtu; domyślnie z ustawień konta. Używana tylko u podatników na ryczałcie.
    - `discount` (`AdvanceInvoices_createAsync.advance_invoice.services.discount`; number, optional) — Rabat w procentach.
      - format `double`; default `0`
    - `unit_net_price_before_discount` (`AdvanceInvoices_createAsync.advance_invoice.services.unit_net_price_before_discount`; integer, optional) — Kwota w groszach (1/100 PLN). `12300` oznacza 123,00 PLN.
      - format `int64`
    - `gtu_id` (`AdvanceInvoices_createAsync.advance_invoice.services.gtu_id`; integer, optional)
      - format `int64`
    - `related_id` (`AdvanceInvoices_createAsync.advance_invoice.services.related_id`; integer, optional) — Faktury zaliczkowe i końcowe: ID pozycji z poprzedniej faktury zaliczkowej, którą kontynuuje ta pozycja.
      - format `int64`
    - `user_calculated` (`AdvanceInvoices_createAsync.advance_invoice.services.user_calculated`; boolean, optional) — Zachowaj wysłane kwoty bez przeliczania niespójnych wartości.
  - `advance_date` (`AdvanceInvoices_createAsync.advance_invoice.advance_date`; string, optional)
    - format `date`
  - `advance_price` (`AdvanceInvoices_createAsync.advance_invoice.advance_price`; integer, optional) — Otrzymana kwota.
    - format `int64`
  - `previous_advance_id` (`AdvanceInvoices_createAsync.advance_invoice.previous_advance_id`; integer, optional) — Poprzednia faktura zaliczkowa w grupie; pomiń przy pierwszej zaliczce. Gdy jest podana, a żadna pozycja nie ma `related_id`, pozycje są zastępowane pozycjami ostatniej zaliczki w grupie.
    - format `int64`

## Example request

```json
{
  "advance_invoice": {
    "number": "string",
    "check_duplicate_number": true,
    "kind": "vat",
    "currency": "string",
    "left_to_pay": 12300,
    "notes": "string",
    "payment_method": "transfer",
    "split_payment": true,
    "split_payment_type": "required",
    "recipient_signature": "string",
    "seller_signature": "string",
    "invoice_date": "2019-08-24",
    "vat_date_value": "sale_date",
    "occasional_sale": true,
    "payment_date": "2019-08-24",
    "paid_date": "2019-08-24",
    "client_id": 0,
    "client_company_name": "string",
    "client_first_name": "string",
    "client_last_name": "string",
    "client_business_activity_kind": "private_person",
    "client_street": "string",
    "client_street_number": "string",
    "client_flat_number": "string",
    "client_city": "string",
    "client_post_code": "string",
    "client_tax_code": "string",
    "client_country": "PL",
    "bank_account": "string",
    "bank_name": "string",
    "swift": "string",
    "vat_exemption_reason": 0,
    "sale_type": "service",
    "invoice_date_kind": "sale_date",
    "document_markings_ids": [
      "string"
    ],
    "transaction_kind_id": 0,
    "bdo_code": "string",
    "receipt_number": "string",
    "not_income": true,
    "vat_exchange_date_kind": "pit",
    "sales_kind": "sprzedaz_podstawowa",
    "ksef_number": "string",
    "transaction_terms": {
      "contracts": [
        {
          "number": "string",
          "date": "2019-08-24"
        }
      ],
      "orders": [
        {
          "number": "string",
          "date": "2019-08-24"
        }
      ]
    },
    "local_government_recipient_address": {
      "company_name": "string",
      "tax_id": "string",
      "street": "string",
      "building_number": "string",
      "door_number": "string",
      "post_code": "string",
      "city": "string",
      "country_id": 0
    },
    "local_government_seller_address": {
      "company_name": "string",
      "tax_id": "string",
      "street": "string",
      "building_number": "string",
      "door_number": "string",
      "post_code": "string",
      "city": "string",
      "country_id": 0
    },
    "third_party_addresses": [
      {
        "id": 0,
        "_destroy": true,
        "company_name": "string",
        "tax_id": "string",
        "street": "string",
        "building_number": "string",
        "door_number": "string",
        "post_code": "string",
        "city": "string",
        "country_code": "PL",
        "country_id": 0,
        "role_code": "1",
        "internal_identifier": "string"
      }
    ],
    "allow_correction": true,
    "services": [
      {
        "name": "string",
        "tax_symbol": "string",
        "unit": "string",
        "quantity": 1,
        "unit_net_price": 12300,
        "net_price": 12300,
        "gross_price": 12300,
        "tax_price": 12300,
        "symbol": "string",
        "pkwiu": "string",
        "cn": "string",
        "pkob": "string",
        "gtin": "string",
        "flat_rate_tax_symbol": "string",
        "discount": 0,
        "unit_net_price_before_discount": 12300,
        "gtu_id": 0,
        "related_id": 0,
        "user_calculated": true
      }
    ],
    "advance_date": "2019-08-24",
    "advance_price": 12300,
    "previous_advance_id": 0
  }
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url https://api.sandbox-infakt.pl/v3/async/advance_invoices.json \
  --header 'Content-Type: application/json' \
  --header 'X-inFakt-ApiKey: <X-inFakt-ApiKey>' \
  --data '
{
  "advance_invoice": {
    "number": "string",
    "check_duplicate_number": true,
    "kind": "vat",
    "currency": "string",
    "left_to_pay": 12300,
    "notes": "string",
    "payment_method": "transfer",
    "split_payment": true,
    "split_payment_type": "required",
    "recipient_signature": "string",
    "seller_signature": "string",
    "invoice_date": "2019-08-24",
    "vat_date_value": "sale_date",
    "occasional_sale": true,
    "payment_date": "2019-08-24",
    "paid_date": "2019-08-24",
    "client_id": 0,
    "client_company_name": "string",
    "client_first_name": "string",
    "client_last_name": "string",
    "client_business_activity_kind": "private_person",
    "client_street": "string",
    "client_street_number": "string",
    "client_flat_number": "string",
    "client_city": "string",
    "client_post_code": "string",
    "client_tax_code": "string",
    "client_country": "PL",
    "bank_account": "string",
    "bank_name": "string",
    "swift": "string",
    "vat_exemption_reason": 0,
    "sale_type": "service",
    "invoice_date_kind": "sale_date",
    "document_markings_ids": [
      "string"
    ],
    "transaction_kind_id": 0,
    "bdo_code": "string",
    "receipt_number": "string",
    "not_income": true,
    "vat_exchange_date_kind": "pit",
    "sales_kind": "sprzedaz_podstawowa",
    "ksef_number": "string",
    "transaction_terms": {
      "contracts": [
        {
          "number": "string",
          "date": "2019-08-24"
        }
      ],
      "orders": [
        {
          "number": "string",
          "date": "2019-08-24"
        }
      ]
    },
    "local_government_recipient_address": {
      "company_name": "string",
      "tax_id": "string",
      "street": "string",
      "building_number": "string",
      "door_number": "string",
      "post_code": "string",
      "city": "string",
      "country_id": 0
    },
    "local_government_seller_address": {
      "company_name": "string",
      "tax_id": "string",
      "street": "string",
      "building_number": "string",
      "door_number": "string",
      "post_code": "string",
      "city": "string",
      "country_id": 0
    },
    "third_party_addresses": [
      {
        "id": 0,
        "_destroy": true,
        "company_name": "string",
        "tax_id": "string",
        "street": "string",
        "building_number": "string",
        "door_number": "string",
        "post_code": "string",
        "city": "string",
        "country_code": "PL",
        "country_id": 0,
        "role_code": "1",
        "internal_identifier": "string"
      }
    ],
    "allow_correction": true,
    "services": [
      {
        "name": "string",
        "tax_symbol": "string",
        "unit": "string",
        "quantity": 1,
        "unit_net_price": 12300,
        "net_price": 12300,
        "gross_price": 12300,
        "tax_price": 12300,
        "symbol": "string",
        "pkwiu": "string",
        "cn": "string",
        "pkob": "string",
        "gtin": "string",
        "flat_rate_tax_symbol": "string",
        "discount": 0,
        "unit_net_price_before_discount": 12300,
        "gtu_id": 0,
        "related_id": 0,
        "user_calculated": true
      }
    ],
    "advance_date": "2019-08-24",
    "advance_price": 12300,
    "previous_advance_id": 0
  }
}
'
```

### TypeScript

```typescript
const url = 'https://api.sandbox-infakt.pl/v3/async/advance_invoices.json';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', 'X-inFakt-ApiKey': '<X-inFakt-ApiKey>'},
  body: JSON.stringify({
    advance_invoice: {
      number: 'string',
      check_duplicate_number: true,
      kind: 'vat',
      currency: 'string',
      left_to_pay: 12300,
      notes: 'string',
      payment_method: 'transfer',
      split_payment: true,
      split_payment_type: 'required',
      recipient_signature: 'string',
      seller_signature: 'string',
      invoice_date: '2019-08-24',
      vat_date_value: 'sale_date',
      occasional_sale: true,
      payment_date: '2019-08-24',
      paid_date: '2019-08-24',
      client_id: 0,
      client_company_name: 'string',
      client_first_name: 'string',
      client_last_name: 'string',
      client_business_activity_kind: 'private_person',
      client_street: 'string',
      client_street_number: 'string',
      client_flat_number: 'string',
      client_city: 'string',
      client_post_code: 'string',
      client_tax_code: 'string',
      client_country: 'PL',
      bank_account: 'string',
      bank_name: 'string',
      swift: 'string',
      vat_exemption_reason: 0,
      sale_type: 'service',
      invoice_date_kind: 'sale_date',
      document_markings_ids: ['string'],
      transaction_kind_id: 0,
      bdo_code: 'string',
      receipt_number: 'string',
      not_income: true,
      vat_exchange_date_kind: 'pit',
      sales_kind: 'sprzedaz_podstawowa',
      ksef_number: 'string',
      transaction_terms: {
        contracts: [{number: 'string', date: '2019-08-24'}],
        orders: [{number: 'string', date: '2019-08-24'}]
      },
      local_government_recipient_address: {
        company_name: 'string',
        tax_id: 'string',
        street: 'string',
        building_number: 'string',
        door_number: 'string',
        post_code: 'string',
        city: 'string',
        country_id: 0
      },
      local_government_seller_address: {
        company_name: 'string',
        tax_id: 'string',
        street: 'string',
        building_number: 'string',
        door_number: 'string',
        post_code: 'string',
        city: 'string',
        country_id: 0
      },
      third_party_addresses: [
        {
          id: 0,
          _destroy: true,
          company_name: 'string',
          tax_id: 'string',
          street: 'string',
          building_number: 'string',
          door_number: 'string',
          post_code: 'string',
          city: 'string',
          country_code: 'PL',
          country_id: 0,
          role_code: '1',
          internal_identifier: 'string'
        }
      ],
      allow_correction: true,
      services: [
        {
          name: 'string',
          tax_symbol: 'string',
          unit: 'string',
          quantity: 1,
          unit_net_price: 12300,
          net_price: 12300,
          gross_price: 12300,
          tax_price: 12300,
          symbol: 'string',
          pkwiu: 'string',
          cn: 'string',
          pkob: 'string',
          gtin: 'string',
          flat_rate_tax_symbol: 'string',
          discount: 0,
          unit_net_price_before_discount: 12300,
          gtu_id: 0,
          related_id: 0,
          user_calculated: true
        }
      ],
      advance_date: '2019-08-24',
      advance_price: 12300,
      previous_advance_id: 0
    }
  })
};

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/async/advance_invoices.json"

payload = { "advance_invoice": {
        "number": "string",
        "check_duplicate_number": True,
        "kind": "vat",
        "currency": "string",
        "left_to_pay": 12300,
        "notes": "string",
        "payment_method": "transfer",
        "split_payment": True,
        "split_payment_type": "required",
        "recipient_signature": "string",
        "seller_signature": "string",
        "invoice_date": "2019-08-24",
        "vat_date_value": "sale_date",
        "occasional_sale": True,
        "payment_date": "2019-08-24",
        "paid_date": "2019-08-24",
        "client_id": 0,
        "client_company_name": "string",
        "client_first_name": "string",
        "client_last_name": "string",
        "client_business_activity_kind": "private_person",
        "client_street": "string",
        "client_street_number": "string",
        "client_flat_number": "string",
        "client_city": "string",
        "client_post_code": "string",
        "client_tax_code": "string",
        "client_country": "PL",
        "bank_account": "string",
        "bank_name": "string",
        "swift": "string",
        "vat_exemption_reason": 0,
        "sale_type": "service",
        "invoice_date_kind": "sale_date",
        "document_markings_ids": ["string"],
        "transaction_kind_id": 0,
        "bdo_code": "string",
        "receipt_number": "string",
        "not_income": True,
        "vat_exchange_date_kind": "pit",
        "sales_kind": "sprzedaz_podstawowa",
        "ksef_number": "string",
        "transaction_terms": {
            "contracts": [
                {
                    "number": "string",
                    "date": "2019-08-24"
                }
            ],
            "orders": [
                {
                    "number": "string",
                    "date": "2019-08-24"
                }
            ]
        },
        "local_government_recipient_address": {
            "company_name": "string",
            "tax_id": "string",
            "street": "string",
            "building_number": "string",
            "door_number": "string",
            "post_code": "string",
            "city": "string",
            "country_id": 0
        },
        "local_government_seller_address": {
            "company_name": "string",
            "tax_id": "string",
            "street": "string",
            "building_number": "string",
            "door_number": "string",
            "post_code": "string",
            "city": "string",
            "country_id": 0
        },
        "third_party_addresses": [
            {
                "id": 0,
                "_destroy": True,
                "company_name": "string",
                "tax_id": "string",
                "street": "string",
                "building_number": "string",
                "door_number": "string",
                "post_code": "string",
                "city": "string",
                "country_code": "PL",
                "country_id": 0,
                "role_code": "1",
                "internal_identifier": "string"
            }
        ],
        "allow_correction": True,
        "services": [
            {
                "name": "string",
                "tax_symbol": "string",
                "unit": "string",
                "quantity": 1,
                "unit_net_price": 12300,
                "net_price": 12300,
                "gross_price": 12300,
                "tax_price": 12300,
                "symbol": "string",
                "pkwiu": "string",
                "cn": "string",
                "pkob": "string",
                "gtin": "string",
                "flat_rate_tax_symbol": "string",
                "discount": 0,
                "unit_net_price_before_discount": 12300,
                "gtu_id": 0,
                "related_id": 0,
                "user_calculated": True
            }
        ],
        "advance_date": "2019-08-24",
        "advance_price": 12300,
        "previous_advance_id": 0
    } }
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
{
  "invoice_task_reference_number": "4f6a8c1e-2b3d-4e5f-9a7b-8c9d0e1f2a3b",
  "processing_code": 100,
  "processing_description": "Zlecenie przyjęte",
  "action": "create_invoice",
  "invoice_kind": "advance_invoice",
  "timestamps": {
    "task_created_at": "2026-10-02 12:00:00 +0200"
  }
}
```

- `invoice_task_reference_number` (`AdvanceInvoices_createAsync.response.201.invoice_task_reference_number`; string, required) — Uuid zadania; użyj go w endpoincie statusu.
  - format `uuid`
- `processing_code` (`AdvanceInvoices_createAsync.response.201.processing_code`; integer, required) — `100` zainicjowane, `120` oczekuje, `140` w trakcie, `201` faktura utworzona, `200` akcja wykonana, `422` błąd (zobacz `invoice_errors`).
  - format `int32`
- `action` (`AdvanceInvoices_createAsync.response.201.action`; string, required) — `create_invoice` albo `mark_as_paid`.
  - one of `"create_invoice"`, `"mark_as_paid"`
- `timestamps` (`AdvanceInvoices_createAsync.response.201.timestamps`; object, required)
  - `task_created_at` (`AdvanceInvoices_createAsync.response.201.timestamps.task_created_at`; string, required)
- `processing_description` (`AdvanceInvoices_createAsync.response.201.processing_description`; string, optional)
- `invoice_kind` (`AdvanceInvoices_createAsync.response.201.invoice_kind`; string, optional)
- `invoice_errors` (`AdvanceInvoices_createAsync.response.201.invoice_errors`; any of, optional) — Błędy, gdy `processing_code` to `422`: błędy pól według nazwy pola w API (lista albo pojedynczy komunikat, np. `{"status": "Faktura już została oznaczona jako zapłacona."}`) albo zwykły komunikat przy nieoczekiwanych błędach.
  - any of: `object`, `string`
- `invoice_uuid` (`AdvanceInvoices_createAsync.response.201.invoice_uuid`; string, optional) — Ustawiane, gdy faktura już istnieje.
  - format `uuid`

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

### 422

Nie utworzono zadania; szczegóły w `errors`.

#### Example

```json
{
  "errors": {}
}
```

- `errors` (`AdvanceInvoices_createAsync.response.422.errors`; object, required)

### 423

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

#### Example

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

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


Source: https://docs.niebieskiorzel.pl/api/advance-invoices-create-async/index.md
