{"openapi":"3.1.0","info":{"title":"API Faktulii dla integracji","version":"1.0.0","description":"Dane firmy w Faktulii dla własnych integracji. Token `fk_…` z portalu (Konto → Tokeny API), nagłówek `Authorization: Bearer`. Pełna dokumentacja: https://docs.faktulia.pl."},"servers":[{"url":"https://app.faktulia.pl/api/v1"}],"security":[{"tokenApi":[]}],"tags":[{"name":"Firma"},{"name":"Płatności"},{"name":"Rozliczenia"},{"name":"Dokumenty"},{"name":"Faktury"},{"name":"Kontrahenci"}],"paths":{"/firmy/{firma}":{"get":{"summary":"Dane firmy","description":"Dane firmy, uprawnienia osoby i zakresy tokenu.\n\nZakres tokenu: `firma:odczyt`.","tags":["Firma"],"parameters":[{"name":"firma","in":"path","required":true,"description":"Identyfikator firmy (firma tokenu).","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"firma":{"$ref":"#/components/schemas/Firma"}}}}}},"401":{"$ref":"#/components/responses/Blad401"},"403":{"$ref":"#/components/responses/Blad403"},"404":{"$ref":"#/components/responses/Blad404"},"429":{"$ref":"#/components/responses/Blad429"}},"x-zakres":"firma:odczyt"}},"/firmy/{firma}/podsumowanie":{"get":{"summary":"Podsumowanie miesiąca","description":"Przychody, wydatki, należności i zobowiązania. Sekcja bez dostępu - null.\n\nZakres tokenu: `firma:odczyt`.","tags":["Firma"],"parameters":[{"name":"firma","in":"path","required":true,"description":"Identyfikator firmy (firma tokenu).","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}},{"name":"miesiac","in":"query","required":false,"description":"Miesiąc RRRR-MM (domyślnie bieżący).","schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"podsumowanie":{"$ref":"#/components/schemas/Podsumowanie"}}}}}},"401":{"$ref":"#/components/responses/Blad401"},"403":{"$ref":"#/components/responses/Blad403"},"404":{"$ref":"#/components/responses/Blad404"},"422":{"$ref":"#/components/responses/Blad422"},"429":{"$ref":"#/components/responses/Blad429"}},"x-zakres":"firma:odczyt"}},"/firmy/{firma}/naleznosci":{"get":{"summary":"Należności","description":"Niezapłacone faktury sprzedaży od najbliższego terminu.\n\nZakres tokenu: `faktury:odczyt albo platnosci:odczyt`.","tags":["Płatności"],"parameters":[{"name":"firma","in":"path","required":true,"description":"Identyfikator firmy (firma tokenu).","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}},{"name":"stan","in":"query","required":false,"description":"do_zaplaty (domyślnie), w_terminie, po_terminie","schema":{"type":"string","enum":["do_zaplaty","w_terminie","po_terminie"]}},{"name":"strona","in":"query","required":false,"description":"Numer strony (od 1).","schema":{"type":"integer","minimum":1}},{"name":"na_strone","in":"query","required":false,"description":"Pozycji na stronie (1-100, domyślnie 30).","schema":{"type":"integer","minimum":1,"maximum":100}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"dane":{"type":"array","items":{"$ref":"#/components/schemas/Faktura"}},"strony":{"$ref":"#/components/schemas/Strony"},"suma_pln":{"type":["string","null"],"pattern":"^-?[0-9]+\\.[0-9]{2}$","examples":["1230.00"]}},"required":["dane","strony","suma_pln"]}}}},"401":{"$ref":"#/components/responses/Blad401"},"403":{"$ref":"#/components/responses/Blad403"},"404":{"$ref":"#/components/responses/Blad404"},"422":{"$ref":"#/components/responses/Blad422"},"429":{"$ref":"#/components/responses/Blad429"}},"x-zakres":"faktury:odczyt albo platnosci:odczyt"}},"/firmy/{firma}/zobowiazania":{"get":{"summary":"Zobowiązania","description":"Niezapłacone wydatki (faktury kosztowe i inne dokumenty do zapłaty).\n\nZakres tokenu: `dokumenty:odczyt albo platnosci:odczyt`.","tags":["Płatności"],"parameters":[{"name":"firma","in":"path","required":true,"description":"Identyfikator firmy (firma tokenu).","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}},{"name":"stan","in":"query","required":false,"description":"do_zaplaty (domyślnie) albo po_terminie","schema":{"type":"string","enum":["do_zaplaty","po_terminie"]}},{"name":"strona","in":"query","required":false,"description":"Numer strony (od 1).","schema":{"type":"integer","minimum":1}},{"name":"na_strone","in":"query","required":false,"description":"Pozycji na stronie (1-100, domyślnie 30).","schema":{"type":"integer","minimum":1,"maximum":100}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"dane":{"type":"array","items":{"$ref":"#/components/schemas/Zobowiazanie"}},"strony":{"$ref":"#/components/schemas/Strony"},"suma_pln":{"type":["string","null"],"pattern":"^-?[0-9]+\\.[0-9]{2}$","examples":["1230.00"]}},"required":["dane","strony","suma_pln"]}}}},"401":{"$ref":"#/components/responses/Blad401"},"403":{"$ref":"#/components/responses/Blad403"},"404":{"$ref":"#/components/responses/Blad404"},"422":{"$ref":"#/components/responses/Blad422"},"429":{"$ref":"#/components/responses/Blad429"}},"x-zakres":"dokumenty:odczyt albo platnosci:odczyt"}},"/firmy/{firma}/rozliczenia":{"get":{"summary":"Rozliczenia z biurem","description":"Opublikowane rozliczenia miesięcy roku: podatki, ZUS i usługa biura do zapłaty.\n\nZakres tokenu: `rozliczenia:odczyt`.","tags":["Rozliczenia"],"parameters":[{"name":"firma","in":"path","required":true,"description":"Identyfikator firmy (firma tokenu).","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}},{"name":"rok","in":"query","required":false,"description":"Rok (domyślnie bieżący).","schema":{"type":"integer"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"rok":{"type":"integer"},"dane":{"type":"array","items":{"$ref":"#/components/schemas/Rozliczenie"}}}}}}},"401":{"$ref":"#/components/responses/Blad401"},"403":{"$ref":"#/components/responses/Blad403"},"404":{"$ref":"#/components/responses/Blad404"},"422":{"$ref":"#/components/responses/Blad422"},"429":{"$ref":"#/components/responses/Blad429"}},"x-zakres":"rozliczenia:odczyt"}},"/firmy/{firma}/dokumenty":{"get":{"summary":"Lista dokumentów","description":"Dokumenty firmy widoczne w portalu, od najnowiej dodanych.\n\nZakres tokenu: `dokumenty:odczyt`.","tags":["Dokumenty"],"parameters":[{"name":"firma","in":"path","required":true,"description":"Identyfikator firmy (firma tokenu).","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}},{"name":"status","in":"query","required":false,"description":"Status albo kilka po przecinku: surowy, odczytany, uzupelniony, gotowy, zaksiegowany, odrzucony.","schema":{"type":"string"}},{"name":"szukaj","in":"query","required":false,"description":"Wyszukiwarka portalu.","schema":{"type":"string"}},{"name":"strona","in":"query","required":false,"description":"Numer strony (od 1).","schema":{"type":"integer","minimum":1}},{"name":"na_strone","in":"query","required":false,"description":"Pozycji na stronie (1-100, domyślnie 30).","schema":{"type":"integer","minimum":1,"maximum":100}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"dane":{"type":"array","items":{"$ref":"#/components/schemas/Dokument"}},"strony":{"$ref":"#/components/schemas/Strony"}},"required":["dane","strony"]}}}},"401":{"$ref":"#/components/responses/Blad401"},"403":{"$ref":"#/components/responses/Blad403"},"404":{"$ref":"#/components/responses/Blad404"},"422":{"$ref":"#/components/responses/Blad422"},"429":{"$ref":"#/components/responses/Blad429"}},"x-zakres":"dokumenty:odczyt"},"post":{"summary":"Dodaj dokument","description":"Plik staje się dokumentem w domyślnym miesiącu firmy (ta sama ścieżka co portal: odczyt danych, duplikaty, limity).\n\nZakres tokenu: `dokumenty:zapis`.","tags":["Dokumenty"],"parameters":[{"name":"firma","in":"path","required":true,"description":"Identyfikator firmy (firma tokenu).","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"UUID - ponowienie z tym samym kluczem zwraca pierwszy dokument.","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Powtórzenie z tym samym kluczem idempotencji","content":{"application/json":{"schema":{"type":"object","properties":{"dokument":{"$ref":"#/components/schemas/Dokument"},"odczyt_rozpoczety":{"type":"boolean"},"ostrzezenie":{"type":["string","null"]}}}}}},"401":{"$ref":"#/components/responses/Blad401"},"403":{"$ref":"#/components/responses/Blad403"},"404":{"$ref":"#/components/responses/Blad404"},"422":{"$ref":"#/components/responses/Blad422"},"429":{"$ref":"#/components/responses/Blad429"},"201":{"description":"Dodano dokument","content":{"application/json":{"schema":{"type":"object","properties":{"dokument":{"$ref":"#/components/schemas/Dokument"},"odczyt_rozpoczety":{"type":"boolean"},"ostrzezenie":{"type":["string","null"]}}}}}},"409":{"$ref":"#/components/responses/Blad409"}},"x-zakres":"dokumenty:zapis","requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["plik"],"properties":{"plik":{"type":"string","format":"binary"},"typ":{"type":"string"},"opis":{"type":"string","maxLength":2000},"odczyt":{"type":"string","enum":["0","1"]}}}}}}}},"/firmy/{firma}/dokumenty/{dokument}":{"get":{"summary":"Szczegóły dokumentu","description":"Szczegóły z komentarzami i podpisanym adresem pliku.\n\nZakres tokenu: `dokumenty:odczyt`.","tags":["Dokumenty"],"parameters":[{"name":"firma","in":"path","required":true,"description":"Identyfikator firmy (firma tokenu).","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}},{"name":"dokument","in":"path","required":true,"description":"Identyfikator dokumentu.","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"dokument":{"$ref":"#/components/schemas/DokumentSzczegoly"}}}}}},"401":{"$ref":"#/components/responses/Blad401"},"403":{"$ref":"#/components/responses/Blad403"},"404":{"$ref":"#/components/responses/Blad404"},"429":{"$ref":"#/components/responses/Blad429"}},"x-zakres":"dokumenty:odczyt"}},"/firmy/{firma}/dokumenty/{dokument}/plik":{"get":{"summary":"Plik dokumentu","description":"Plik pod podpisanym adresem `adres_pliku` ze szczegółów (ważnym 30 minut); wymaga też tokenu.\n\nZakres tokenu: `dokumenty:odczyt`.","tags":["Dokumenty"],"parameters":[{"name":"firma","in":"path","required":true,"description":"Identyfikator firmy (firma tokenu).","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}},{"name":"dokument","in":"path","required":true,"description":"Identyfikator dokumentu.","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}},{"name":"pobierz","in":"query","required":false,"description":"1 - jako załącznik.","schema":{"type":"string"}}],"responses":{"200":{"description":"Plik","content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}}}},"401":{"$ref":"#/components/responses/Blad401"},"403":{"$ref":"#/components/responses/Blad403"},"404":{"$ref":"#/components/responses/Blad404"},"429":{"$ref":"#/components/responses/Blad429"}},"x-zakres":"dokumenty:odczyt"}},"/firmy/{firma}/dokumenty/{dokument}/komentarze":{"post":{"summary":"Dodaj komentarz","description":"Komentarz do dokumentu - biuro dostaje powiadomienie.\n\nZakres tokenu: `dokumenty:zapis`.","tags":["Dokumenty"],"parameters":[{"name":"firma","in":"path","required":true,"description":"Identyfikator firmy (firma tokenu).","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}},{"name":"dokument","in":"path","required":true,"description":"Identyfikator dokumentu.","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}}],"responses":{"200":{"description":"-","content":{"application/json":{"schema":{"type":"object"}}}},"401":{"$ref":"#/components/responses/Blad401"},"403":{"$ref":"#/components/responses/Blad403"},"404":{"$ref":"#/components/responses/Blad404"},"422":{"$ref":"#/components/responses/Blad422"},"429":{"$ref":"#/components/responses/Blad429"},"201":{"description":"Dodano komentarz","content":{"application/json":{"schema":{"type":"object","properties":{"komentarz":{"$ref":"#/components/schemas/Komentarz"}}}}}}},"x-zakres":"dokumenty:zapis","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["tresc"],"properties":{"tresc":{"type":"string","maxLength":2000}}}}}}}},"/firmy/{firma}/faktury":{"get":{"summary":"Lista faktur sprzedaży","description":"Faktury sprzedaży firmy od najnowszych.\n\nZakres tokenu: `faktury:odczyt`.","tags":["Faktury"],"parameters":[{"name":"firma","in":"path","required":true,"description":"Identyfikator firmy (firma tokenu).","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}},{"name":"miesiac","in":"query","required":false,"description":"Miesiąc wystawienia RRRR-MM.","schema":{"type":"string"}},{"name":"status","in":"query","required":false,"description":"szkic, wystawiona, anulowana","schema":{"type":"string","enum":["szkic","wystawiona","anulowana"]}},{"name":"zaplata","in":"query","required":false,"description":"do_zaplaty, w_terminie, po_terminie, czesciowo, zaplacone","schema":{"type":"string","enum":["do_zaplaty","w_terminie","po_terminie","czesciowo","zaplacone"]}},{"name":"kontrahent_id","in":"query","required":false,"description":"Kontrahent (nabywca).","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}},{"name":"szukaj","in":"query","required":false,"description":"Numer, nazwa lub NIP nabywcy.","schema":{"type":"string"}},{"name":"strona","in":"query","required":false,"description":"Numer strony (od 1).","schema":{"type":"integer","minimum":1}},{"name":"na_strone","in":"query","required":false,"description":"Pozycji na stronie (1-100, domyślnie 30).","schema":{"type":"integer","minimum":1,"maximum":100}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"dane":{"type":"array","items":{"$ref":"#/components/schemas/Faktura"}},"strony":{"$ref":"#/components/schemas/Strony"}},"required":["dane","strony"]}}}},"401":{"$ref":"#/components/responses/Blad401"},"403":{"$ref":"#/components/responses/Blad403"},"404":{"$ref":"#/components/responses/Blad404"},"422":{"$ref":"#/components/responses/Blad422"},"429":{"$ref":"#/components/responses/Blad429"}},"x-zakres":"faktury:odczyt"},"post":{"summary":"Nowa faktura","description":"Szkic albo od razu wystawiona faktura (`wystaw: true`); nowy nabywca trafia do kontrahentów.\n\nZakres tokenu: `faktury:wystawianie`.","tags":["Faktury"],"parameters":[{"name":"firma","in":"path","required":true,"description":"Identyfikator firmy (firma tokenu).","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"UUID - ponowienie z tym samym kluczem zwraca pierwszą fakturę.","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Powtórzenie z tym samym kluczem idempotencji","content":{"application/json":{"schema":{"type":"object","properties":{"faktura":{"$ref":"#/components/schemas/FakturaSzczegoly"},"ksef_blad":{"type":["string","null"]},"ostrzezenie":{"type":["string","null"]}}}}}},"401":{"$ref":"#/components/responses/Blad401"},"403":{"$ref":"#/components/responses/Blad403"},"404":{"$ref":"#/components/responses/Blad404"},"422":{"$ref":"#/components/responses/Blad422"},"429":{"$ref":"#/components/responses/Blad429"},"201":{"description":"Utworzono fakturę","content":{"application/json":{"schema":{"type":"object","properties":{"faktura":{"$ref":"#/components/schemas/FakturaSzczegoly"},"ksef_blad":{"type":["string","null"]},"ostrzezenie":{"type":["string","null"]}}}}}}},"x-zakres":"faktury:wystawianie","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FakturaWe"}}}}}},"/firmy/{firma}/faktury/{faktura}":{"get":{"summary":"Szczegóły faktury","description":"Faktura z pozycjami, KSeF i zapłatą.\n\nZakres tokenu: `faktury:odczyt`.","tags":["Faktury"],"parameters":[{"name":"firma","in":"path","required":true,"description":"Identyfikator firmy (firma tokenu).","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}},{"name":"faktura","in":"path","required":true,"description":"Identyfikator faktury.","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"faktura":{"$ref":"#/components/schemas/FakturaSzczegoly"}}}}}},"401":{"$ref":"#/components/responses/Blad401"},"403":{"$ref":"#/components/responses/Blad403"},"404":{"$ref":"#/components/responses/Blad404"},"429":{"$ref":"#/components/responses/Blad429"}},"x-zakres":"faktury:odczyt"}},"/firmy/{firma}/faktury/{faktura}/pdf":{"get":{"summary":"PDF faktury","description":"Plik PDF faktury (szkic nie ma PDF - 404).\n\nZakres tokenu: `faktury:odczyt`.","tags":["Faktury"],"parameters":[{"name":"firma","in":"path","required":true,"description":"Identyfikator firmy (firma tokenu).","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}},{"name":"faktura","in":"path","required":true,"description":"Identyfikator faktury.","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}}],"responses":{"200":{"description":"PDF faktury","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"401":{"$ref":"#/components/responses/Blad401"},"403":{"$ref":"#/components/responses/Blad403"},"404":{"$ref":"#/components/responses/Blad404"},"429":{"$ref":"#/components/responses/Blad429"}},"x-zakres":"faktury:odczyt"}},"/firmy/{firma}/kontrahenci":{"get":{"summary":"Lista kontrahentów","description":"Kontrahenci firmy alfabetycznie.\n\nZakres tokenu: `kontrahenci:odczyt`.","tags":["Kontrahenci"],"parameters":[{"name":"firma","in":"path","required":true,"description":"Identyfikator firmy (firma tokenu).","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}},{"name":"szukaj","in":"query","required":false,"description":"Nazwa lub NIP.","schema":{"type":"string"}},{"name":"nip","in":"query","required":false,"description":"Dokładny NIP.","schema":{"type":"string"}},{"name":"strona","in":"query","required":false,"description":"Numer strony (od 1).","schema":{"type":"integer","minimum":1}},{"name":"na_strone","in":"query","required":false,"description":"Pozycji na stronie (1-100, domyślnie 30).","schema":{"type":"integer","minimum":1,"maximum":100}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"dane":{"type":"array","items":{"$ref":"#/components/schemas/Kontrahent"}},"strony":{"$ref":"#/components/schemas/Strony"}},"required":["dane","strony"]}}}},"401":{"$ref":"#/components/responses/Blad401"},"403":{"$ref":"#/components/responses/Blad403"},"404":{"$ref":"#/components/responses/Blad404"},"422":{"$ref":"#/components/responses/Blad422"},"429":{"$ref":"#/components/responses/Blad429"}},"x-zakres":"kontrahenci:odczyt"},"post":{"summary":"Nowy kontrahent","description":"Dodanie kontrahenta; istniejący o tym NIP - 409 z jego danymi.\n\nZakres tokenu: `kontrahenci:zapis`.","tags":["Kontrahenci"],"parameters":[{"name":"firma","in":"path","required":true,"description":"Identyfikator firmy (firma tokenu).","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}}],"responses":{"200":{"description":"-","content":{"application/json":{"schema":{"type":"object"}}}},"401":{"$ref":"#/components/responses/Blad401"},"403":{"$ref":"#/components/responses/Blad403"},"404":{"$ref":"#/components/responses/Blad404"},"422":{"$ref":"#/components/responses/Blad422"},"429":{"$ref":"#/components/responses/Blad429"},"201":{"description":"Dodano kontrahenta","content":{"application/json":{"schema":{"type":"object","properties":{"kontrahent":{"$ref":"#/components/schemas/Kontrahent"}}}}}},"409":{"$ref":"#/components/responses/Blad409"}},"x-zakres":"kontrahenci:zapis","requestBody":{"required":true,"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/KontrahentWe"},{"required":["nazwa"]}]}}}}}},"/firmy/{firma}/kontrahenci/{kontrahent}":{"get":{"summary":"Szczegóły kontrahenta","description":"Dane kontrahenta.\n\nZakres tokenu: `kontrahenci:odczyt`.","tags":["Kontrahenci"],"parameters":[{"name":"firma","in":"path","required":true,"description":"Identyfikator firmy (firma tokenu).","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}},{"name":"kontrahent","in":"path","required":true,"description":"Identyfikator kontrahenta.","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"kontrahent":{"$ref":"#/components/schemas/Kontrahent"}}}}}},"401":{"$ref":"#/components/responses/Blad401"},"403":{"$ref":"#/components/responses/Blad403"},"404":{"$ref":"#/components/responses/Blad404"},"429":{"$ref":"#/components/responses/Blad429"}},"x-zakres":"kontrahenci:odczyt"},"patch":{"summary":"Zmień kontrahenta","description":"Zmiana podanych pól.\n\nZakres tokenu: `kontrahenci:zapis`.","tags":["Kontrahenci"],"parameters":[{"name":"firma","in":"path","required":true,"description":"Identyfikator firmy (firma tokenu).","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}},{"name":"kontrahent","in":"path","required":true,"description":"Identyfikator kontrahenta.","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"kontrahent":{"$ref":"#/components/schemas/Kontrahent"}}}}}},"401":{"$ref":"#/components/responses/Blad401"},"403":{"$ref":"#/components/responses/Blad403"},"404":{"$ref":"#/components/responses/Blad404"},"422":{"$ref":"#/components/responses/Blad422"},"429":{"$ref":"#/components/responses/Blad429"},"409":{"$ref":"#/components/responses/Blad409"}},"x-zakres":"kontrahenci:zapis","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/KontrahentWe"}}}}}},"/firmy/{firma}/faktury/{faktura}/wystaw":{"post":{"summary":"Wystaw szkic","description":"Nadaje numer i PDF; KSeF wg ustawienia firmy albo pola `ksef`. Już wystawiona - 409.\n\nZakres tokenu: `faktury:wystawianie`.","tags":["Faktury"],"parameters":[{"name":"firma","in":"path","required":true,"description":"Identyfikator firmy (firma tokenu).","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}},{"name":"faktura","in":"path","required":true,"description":"Identyfikator faktury.","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"faktura":{"$ref":"#/components/schemas/FakturaSzczegoly"},"ksef_blad":{"type":["string","null"]},"ostrzezenie":{"type":["string","null"]}}}}}},"401":{"$ref":"#/components/responses/Blad401"},"403":{"$ref":"#/components/responses/Blad403"},"404":{"$ref":"#/components/responses/Blad404"},"422":{"$ref":"#/components/responses/Blad422"},"429":{"$ref":"#/components/responses/Blad429"},"409":{"$ref":"#/components/responses/Blad409"}},"x-zakres":"faktury:wystawianie","requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"ksef":{"type":"boolean"}}}}}}}},"/firmy/{firma}/faktury/{faktura}/ksef":{"post":{"summary":"Wyślij do KSeF","description":"Wysyłka wystawionej faktury; błąd KSeF w polu `ksef_blad`. Już w KSeF albo proforma - 409.\n\nZakres tokenu: `faktury:wystawianie`.","tags":["Faktury"],"parameters":[{"name":"firma","in":"path","required":true,"description":"Identyfikator firmy (firma tokenu).","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}},{"name":"faktura","in":"path","required":true,"description":"Identyfikator faktury.","schema":{"type":"string","pattern":"^[0-9a-z]{26}$"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"faktura":{"$ref":"#/components/schemas/FakturaSzczegoly"},"ksef_blad":{"type":["string","null"]},"ostrzezenie":{"type":["string","null"]}}}}}},"401":{"$ref":"#/components/responses/Blad401"},"403":{"$ref":"#/components/responses/Blad403"},"404":{"$ref":"#/components/responses/Blad404"},"429":{"$ref":"#/components/responses/Blad429"},"409":{"$ref":"#/components/responses/Blad409"}},"x-zakres":"faktury:wystawianie"}}},"components":{"securitySchemes":{"tokenApi":{"type":"http","scheme":"bearer","bearerFormat":"fk_…","description":"Token integracji z portalu (Konto → Tokeny API)."}},"schemas":{"Strony":{"type":"object","properties":{"biezaca":{"type":"integer"},"ostatnia":{"type":"integer"},"razem":{"type":"integer"}},"required":["biezaca","ostatnia","razem"]},"Blad":{"type":"object","properties":{"komunikat":{"type":"string"},"bledy":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}}}},"required":["komunikat","bledy"]},"Adres":{"type":"object","properties":{"ulica":{"type":["string","null"]},"kod_pocztowy":{"type":["string","null"]},"miejscowosc":{"type":["string","null"]},"kraj":{"type":["string","null"]}}},"Firma":{"type":"object","properties":{"id":{"type":"string","pattern":"^[0-9a-z]{26}$"},"nazwa":{"type":"string"},"nazwa_skrocona":{"type":"string"},"nip":{"type":["string","null"]},"regon":{"type":["string","null"]},"forma_prawna":{"type":["string","null"]},"adres":{"$ref":"#/components/schemas/Adres"},"rachunki":{"type":"array","items":{"type":"object","properties":{"numer":{"type":["string","null"]},"nazwa":{"type":["string","null"]},"waluta":{"type":["string","null"]}}}},"uprawnienia":{"type":"array","items":{"type":"string"},"description":"Moduły dostępne osobie, która utworzyła token."},"zakresy_tokenu":{"type":["array","null"],"items":{"type":"string"}}}},"Podsumowanie":{"type":"object","properties":{"miesiac":{"type":"string"},"stan_miesiaca":{"type":["string","null"]},"stan_miesiaca_etykieta":{"type":["string","null"]},"przychody":{"type":["object","null"],"properties":{"netto_pln":{"type":["string","null"],"pattern":"^-?[0-9]+\\.[0-9]{2}$","examples":["1230.00"]},"brutto_pln":{"type":["string","null"],"pattern":"^-?[0-9]+\\.[0-9]{2}$","examples":["1230.00"]},"liczba_faktur":{"type":"integer"}}},"wydatki":{"type":["object","null"],"properties":{"brutto_pln":{"type":["string","null"],"pattern":"^-?[0-9]+\\.[0-9]{2}$","examples":["1230.00"]},"liczba_dokumentow":{"type":"integer"}}},"naleznosci":{"type":["object","null"],"properties":{"do_zaplaty_pln":{"type":["string","null"],"pattern":"^-?[0-9]+\\.[0-9]{2}$","examples":["1230.00"]},"po_terminie_pln":{"type":["string","null"],"pattern":"^-?[0-9]+\\.[0-9]{2}$","examples":["1230.00"]}}},"zobowiazania":{"type":["object","null"],"properties":{"do_zaplaty_pln":{"type":["string","null"],"pattern":"^-?[0-9]+\\.[0-9]{2}$","examples":["1230.00"]},"po_terminie_pln":{"type":["string","null"],"pattern":"^-?[0-9]+\\.[0-9]{2}$","examples":["1230.00"]}}}}},"Dokument":{"type":"object","properties":{"id":{"type":"string","pattern":"^[0-9a-z]{26}$"},"tytul":{"type":"string"},"numer":{"type":["string","null"]},"typ":{"type":"string"},"typ_etykieta":{"type":"string"},"status":{"type":"string"},"status_etykieta":{"type":"string"},"kompletnosc":{"type":"integer"},"data_wystawienia":{"type":["string","null"],"format":"date"},"data_wplywu":{"type":["string","null"],"format":"date"},"suma_brutto":{"type":["string","null"],"pattern":"^-?[0-9]+\\.[0-9]{2}$","examples":["1230.00"]},"waluta":{"type":["string","null"]},"kontrahent":{"type":["string","null"]},"plik_nazwa":{"type":["string","null"]},"plik_mime":{"type":["string","null"]},"utworzono":{"type":["string","null"],"format":"date-time"}}},"Komentarz":{"type":"object","properties":{"id":{"type":"string","pattern":"^[0-9a-z]{26}$"},"autor":{"type":"string"},"tresc":{"type":"string"},"kiedy":{"type":["string","null"],"format":"date-time"},"od_biura":{"type":"boolean"}}},"Zobowiazanie":{"allOf":[{"$ref":"#/components/schemas/Dokument"},{"type":"object","properties":{"termin_platnosci":{"type":["string","null"],"format":"date"},"do_zaplaty":{"type":["string","null"],"pattern":"^-?[0-9]+\\.[0-9]{2}$","examples":["1230.00"]},"pozostalo_do_zaplaty":{"type":["string","null"],"pattern":"^-?[0-9]+\\.[0-9]{2}$","examples":["1230.00"]},"zaplata":{"type":"string"},"po_terminie":{"type":"boolean"},"opis_terminu":{"type":["string","null"]}}}]},"Faktura":{"type":"object","properties":{"id":{"type":"string","pattern":"^[0-9a-z]{26}$"},"numer":{"type":["string","null"]},"rodzaj":{"type":"string","enum":["vat","proforma","korekta","zaliczkowa","rozliczeniowa"]},"rodzaj_etykieta":{"type":"string"},"status":{"type":"string","enum":["szkic","wystawiona","anulowana"]},"status_etykieta":{"type":"string"},"data_wystawienia":{"type":["string","null"],"format":"date"},"data_sprzedazy":{"type":["string","null"],"format":"date"},"termin_platnosci":{"type":["string","null"],"format":"date"},"nabywca":{"type":"object","properties":{"nazwa":{"type":"string"},"nip":{"type":["string","null"]},"kontrahent_id":{"type":["string","null"]}}},"waluta":{"type":"string"},"suma_netto":{"type":["string","null"],"pattern":"^-?[0-9]+\\.[0-9]{2}$","examples":["1230.00"]},"suma_vat":{"type":["string","null"],"pattern":"^-?[0-9]+\\.[0-9]{2}$","examples":["1230.00"]},"suma_brutto":{"type":["string","null"],"pattern":"^-?[0-9]+\\.[0-9]{2}$","examples":["1230.00"]},"pozostalo_do_zaplaty":{"type":["string","null"],"pattern":"^-?[0-9]+\\.[0-9]{2}$","examples":["1230.00"]},"zaplata":{"type":["string","null"]},"ksef":{"type":"object","properties":{"status":{"type":["string","null"]},"status_etykieta":{"type":["string","null"]},"numer":{"type":["string","null"]},"przyjeto":{"type":["string","null"],"format":"date-time"}}},"pobrana_z_ksef":{"type":"boolean"},"koryguje_id":{"type":["string","null"]},"wystawiono":{"type":["string","null"],"format":"date-time"}}},"Rozliczenie":{"type":"object","properties":{"id":{"type":"string","pattern":"^[0-9a-z]{26}$"},"miesiac":{"type":"string"},"przychod":{"type":["string","null"],"pattern":"^-?[0-9]+\\.[0-9]{2}$","examples":["1230.00"]},"koszty":{"type":["string","null"],"pattern":"^-?[0-9]+\\.[0-9]{2}$","examples":["1230.00"]},"dochod":{"type":["string","null"],"pattern":"^-?[0-9]+\\.[0-9]{2}$","examples":["1230.00"]},"waluta":{"type":"string"},"opublikowano":{"type":["string","null"],"format":"date-time"},"uwagi":{"type":["string","null"]},"pozycje":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[0-9a-z]{26}$"},"rodzaj":{"type":"string","enum":["podatek","zus","usluga"]},"typ":{"type":["string","null"]},"nazwa":{"type":["string","null"]},"okres_deklaracji":{"type":["string","null"]},"kwota":{"type":["string","null"],"pattern":"^-?[0-9]+\\.[0-9]{2}$","examples":["1230.00"]},"waluta":{"type":"string"},"termin":{"type":["string","null"],"format":"date"},"rachunek_bankowy":{"type":["string","null"]},"zaplacono":{"type":["string","null"],"format":"date-time"}}}}}},"Kontrahent":{"type":"object","properties":{"id":{"type":"string","pattern":"^[0-9a-z]{26}$"},"nazwa":{"type":"string"},"nazwa_skrocona":{"type":"string"},"nip":{"type":["string","null"]},"rodzaj_identyfikatora":{"type":"string"},"regon":{"type":["string","null"]},"adres":{"$ref":"#/components/schemas/Adres"},"klient":{"type":"boolean"},"dostawca":{"type":"boolean"},"email":{"type":["string","null"]},"telefon":{"type":["string","null"]},"termin_platnosci_dni":{"type":"integer"},"status_vat":{"type":["string","null"]},"rachunki":{"type":"array","items":{"type":["string","null"]}}}},"DokumentSzczegoly":{"allOf":[{"$ref":"#/components/schemas/Dokument"},{"type":"object","properties":{"miesiac":{"type":["string","null"]},"termin_platnosci":{"type":["string","null"],"format":"date"},"opis":{"type":["string","null"]},"komentarze":{"type":"array","items":{"$ref":"#/components/schemas/Komentarz"}},"adres_pliku":{"type":"string","format":"uri","description":"Podpisany adres (30 min); pobranie wymaga też nagłówka Authorization."},"adres_podgladu":{"type":["string","null"],"format":"uri"}}}]},"FakturaSzczegoly":{"allOf":[{"$ref":"#/components/schemas/Faktura"},{"type":"object","properties":{"forma_platnosci":{"type":["string","null"]},"rachunek_bankowy":{"type":["string","null"]},"uwagi":{"type":["string","null"]},"pozycje":{"type":"array","items":{"type":"object","properties":{"lp":{"type":"integer"},"nazwa":{"type":"string"},"jednostka":{"type":"string"},"ilosc":{"type":"string"},"cena_netto":{"type":["string","null"],"pattern":"^-?[0-9]+\\.[0-9]{2}$","examples":["1230.00"]},"stawka_vat":{"type":"string"},"netto":{"type":["string","null"],"pattern":"^-?[0-9]+\\.[0-9]{2}$","examples":["1230.00"]},"vat":{"type":["string","null"],"pattern":"^-?[0-9]+\\.[0-9]{2}$","examples":["1230.00"]},"brutto":{"type":["string","null"],"pattern":"^-?[0-9]+\\.[0-9]{2}$","examples":["1230.00"]}}}}}}]},"NabywcaWe":{"type":"object","required":["nazwa"],"properties":{"nazwa":{"type":"string"},"nip":{"type":["string","null"]},"rodzaj_identyfikatora":{"type":"string","enum":["nip","vat_ue","inny","brak"]},"ulica":{"type":["string","null"]},"kod_pocztowy":{"type":["string","null"]},"miejscowosc":{"type":["string","null"]},"kraj":{"type":"string","minLength":2,"maxLength":2},"email":{"type":["string","null"]}}},"FakturaWe":{"type":"object","required":["pozycje"],"properties":{"rodzaj":{"type":"string","enum":["vat","proforma","bez_vat"],"default":"vat"},"data_wystawienia":{"type":"string","format":"date"},"data_sprzedazy":{"type":"string","format":"date"},"termin_platnosci":{"type":"string","format":"date"},"termin_dni":{"type":"integer","minimum":0,"maximum":365},"kontrahent_id":{"type":"string","pattern":"^[0-9a-z]{26}$"},"nabywca":{"$ref":"#/components/schemas/NabywcaWe"},"waluta":{"type":"string","default":"PLN"},"forma_platnosci":{"type":"string","enum":["gotowka","karta","przelew","kompensata","przedplata","pobranie"]},"rachunek_bankowy":{"type":["string","null"]},"mpp":{"type":"boolean"},"podstawa_zwolnienia":{"type":["string","null"]},"miejsce_wystawienia":{"type":["string","null"]},"uwagi":{"type":["string","null"]},"pozycje":{"type":"array","minItems":1,"items":{"type":"object","required":["nazwa","ilosc","stawka"],"properties":{"nazwa":{"type":"string"},"ilosc":{"type":"number"},"jednostka":{"type":"string"},"cena_netto":{"type":"number"},"cena_brutto":{"type":"number"},"stawka":{"type":"string","enum":["23","8","7","5","0","0_wdt","0_ex","zw","np","np_ue","bez_vat"]}}}},"wystaw":{"type":"boolean","default":false},"ksef":{"type":"boolean","description":"Domyślnie wg ustawienia firmy."}}},"KontrahentWe":{"type":"object","properties":{"nazwa":{"type":"string"},"nazwa_skrocona":{"type":"string"},"rodzaj_identyfikatora":{"type":"string","enum":["nip","vat_ue","inny","brak"]},"nip":{"type":["string","null"]},"regon":{"type":["string","null"]},"ulica":{"type":["string","null"]},"kod_pocztowy":{"type":["string","null"]},"miejscowosc":{"type":["string","null"]},"kraj":{"type":"string"},"email":{"type":["string","null"]},"telefon":{"type":["string","null"]},"klient":{"type":"boolean"},"dostawca":{"type":"boolean"},"termin_platnosci_dni":{"type":"integer"}}}},"responses":{"Blad401":{"description":"Brak tokenu, token nieznany, wygasły albo unieważniony.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Blad"}}}},"Blad403":{"description":"Brak zakresu albo uprawnienia, adres IP spoza listy, blokada za subskrypcję.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Blad"}}}},"Blad404":{"description":"Brak zasobu (także inna firma niż firma tokenu).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Blad"}}}},"Blad409":{"description":"Konflikt (np. powtórzona wysyłka usuniętego dokumentu).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Blad"}}}},"Blad422":{"description":"Błędne dane - pola w `bledy`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Blad"}}}},"Blad429":{"description":"Limit żądań - nagłówek Retry-After.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Blad"}}}}}}}