Developer's Guide - Faktury Web API

Guide of Faktury Web API usage and samples of source code

Before you start...

You need to have your API key defined. The API key is a 32-character string required for using the API. Never share your API key with anyone. You will find your unique API key in your profile, right after logging in, on the welcome page.

Creating a new invoice

API call for creating a new invoice:
https://www.fakturyweb.cz/api/nf?data={JSON}
The following tables list the parameters you can use to create a new invoice.

Basic parameters:
Parameter Attribute Description
key required parameter API key.
email required parameter E-mail (or username) you use to log in to Fakturyweb.
apitest optional parameter The apitest parameter specifies whether the created invoice is for testing purposes only. This parameter should be used only by developers implementing the Fakturyweb API. The system will treat the created invoice as a test one and will delete it within 5 to 10 minutes. We recommend keeping this value enabled while testing your API implementation. Disable this value in production, otherwise the invoices will be deleted automatically.
Possible values: 1 or 0
Default value: 0
Supplier parameters:
The supplier can be selected either by the d_id parameter, referring to a supplier stored in the My companies list (option 1), or by filling in all the required details in the parameters (option 2).
Parameter Attribute Description
d_id option 1 / required parameter Supplier ID (you will find the ID in the My companies list).
d_name option 2 / required parameter Supplier's business name.
d_street option 2 / optional parameter Supplier's street.
d_city option 2 / optional parameter Supplier's city.
d_state option 2 / optional parameter Supplier's country.
d_zip option 2 / optional parameter Supplier's postal code.
d_ico option 2 / optional parameter Supplier's Company ID (IČO).
d_dic option 2 / optional parameter Supplier's Tax ID (DIČ).
d_vatpayer option 2 / optional parameter VAT payer.
Possible values:
VAT payer: 1
Non-VAT payer: 0
Default value: 0
d_viewpayer option 2 / optional parameter Show on the invoice whether the supplier is a VAT payer.
Possible values:
Yes: 1
No: 0
Default value: 1
d_info option 2 / optional parameter Supplier information.
d_bankaccount option 2 / optional parameter Supplier's bank account number.
d_bank option 2 / optional parameter Supplier's bank name.
d_iban option 2 / optional parameter Supplier's IBAN.
d_swift option 2 / optional parameter Supplier's SWIFT.
d_email option 2 / optional parameter Supplier's e-mail.
d_web option 2 / optional parameter Supplier's website.
d_phone option 2 / optional parameter Supplier's phone.
d_custom_key_1 option 2 / optional parameter Custom field no. 1 - key
d_custom_value_1 option 2 / optional parameter Custom field no. 1 - value
d_custom_key_2 option 2 / optional parameter Custom field no. 2 - key
d_custom_value_2 option 2 / optional parameter Custom field no. 2 - value
Customer parameters:
Parameter Attribute Description
o_name required parameter Customer's business name.
o_street optional parameter Customer's street.
o_city optional parameter Customer's city.
o_state optional parameter Customer's country.
o_zip optional parameter Customer's postal code.
o_ico optional parameter Customer's Company ID (IČO).
o_dic optional parameter Customer's Tax ID (DIČ).
o_email optional parameter Customer's e-mail.
o_name_d optional parameter Delivery address - business name.
o_street_d optional parameter Delivery address - street.
o_city_d optional parameter Delivery address - city.
o_state_d optional parameter Delivery address - country.
o_zip_d optional parameter Delivery address - postal code.
o_custom_key_1 option 2 / optional parameter Custom field no. 1 - key
o_custom_value_1 option 2 / optional parameter Custom field no. 1 - value
o_custom_key_2 option 2 / optional parameter Custom field no. 2 - key
o_custom_value_2 option 2 / optional parameter Custom field no. 2 - value
Invoice parameters:
Parameter Attribute Description
f_number optional parameter Invoice number. If not provided, the number is automatically incremented by 1 from the most recently created invoice (the issue date is decisive; the invoice number must be numeric).
f_taxdoc optional parameter Marks whether the invoice is a tax document. Possible values:
Not shown: 0
Shown: 1
Default value: 0
f_vs optional parameter Variable symbol.
f_ks optional parameter Constant symbol.
f_date_issue optional parameter Issue date. In the YYYY-MM-DD format.
Default value: current date
f_date_delivery optional parameter Delivery date. In the YYYY-MM-DD format.
Default value: current date
f_date_due optional parameter Due date. In the YYYY-MM-DD format.
Default value: 14 days from the current date
f_date_payment optional parameter Date of the received payment for invoice type 5, in the YYYY-MM-DD format.
Default value: current date
f_issued_by optional parameter Invoice issued by.
f_order optional parameter Order number.
f_payment optional parameter Payment method. Possible values:
Bank transfer: prevod
Postal order: poukazka
Cash: hotovost
Cash on delivery: dobirka
Cash register: pokladna
Online payment provider: eprovider
Offset (set-off): zapocet
Payment card: karta
Other: jina
Default value: prevod
f_note_above optional parameter Invoice note. Displayed above the invoice items.
f_note optional parameter Invoice note. Displayed below the invoice items. If the supplier is selected by the d_id parameter and f_note is empty, the note stored for that supplier is displayed.
f_internal_note optional parameter Internal note. For internal use only. It is not shown on the issued invoice; it is visible only in the document detail in the system.
f_logo optional parameter Logo display. Possible values:
Not shown: 0
Shown: 1 (only if the supplier was loaded by d_id and has a logo stored)
f_stamp optional parameter Stamp display. Possible values:
Not shown: 0
Shown: 1 (only if the supplier was loaded by d_id and has a stamp stored)
f_currency optional parameter Invoice currency. Currency code. The default value is Kč.
Default value: Kč
f_type optional parameter Invoice type.
Possible values:
1: invoice
2: proforma invoice
3: credit note
4: debit note
5: receipt for a received payment
Default value: 1
f_original_num required for invoice types 3 and 4 / optional parameter A credit note or a debit note must include a reference to the original document.
Default value: 0
f_paid optional parameter Amount already paid by non-tax advance payments. The value is not used in a receipt for a received payment.
Default value: 0
f_fullpaid optional parameter Forces the “ALREADY PAID” note in the document footer instead of the amount due. Use it when the document is already paid at the time of issue (e.g. prepayment, e-shop). It is independent of the f_paid parameter (amount paid by advance payments) and of the invoice payment status in the system.
Possible values:
0: not shown (default)
1: shows the “ALREADY PAID” note
Default value: 0
f_rounding optional parameter Rounding of the total amount due
Possible values:
0: no rounding
1: round up to a whole number
2: round down to a whole number
4: arithmetic rounding to a whole number
Default value: 0
f_style optional parameter Visual style of the invoice. Possible values:
styl_1
styl_2
styl_3
styl_4
styl_5
styl_6
styl_7 (default designer template)
Default value: styl_1
f_language optional parameter Invoice language. Possible values:
CS, SK, EN, DE, ES, FR, IT, PL, HU, RU, NO, DK
Default value: CS
f_qr optional parameter Show a payment QR code.
Possible values:
0: do not show
1: QR platba + F
2: QR platba
3: EPC format
Default value: 1
f_omit_stats optional parameter Exclude the value from statistics. Possible values:
0: do not exclude
1: exclude
Default value: 0
f_vat_regime optional parameter VAT regime for the whole invoice.
Possible values:
0: Standard regime
1: Reverse charge
2: VAT exemption
3: Intra-EU supply of goods
4: Export of goods outside the EU
5: Pass-through items, not included in the taxable amount
6: Service outside the EU, place of supply abroad
Values 1 to 6 are available only to VAT payers. A document regime greater than 0 applies to all items.
Default value: 0
f_custom optional parameter Any text information sent via the API. It is shown as a separate column in the Excel export.
text, max. 50 characters
f_tags optional parameter A list (array) of tags from the My labels / tags list to be assigned to the document. Format:
Array
(
    [0] => Tag name 1
    [1] => Tag name 2
)
Invoice item parameters:
Parameter Attribute Description
p_text required parameter Invoice item text.
p_quantity required parameter Quantity. Number.
p_unit required parameter Unit of measure. For example kg, pcs, ...
p_price required parameter Amount per unit of measure excluding tax.
p_vat optional parameter Tax in percent. Fill in only if the supplier is a VAT payer.
p_pricevat optional parameter Amount per unit of measure including tax. Fill in only if the supplier is a VAT payer.
p_regime optional parameter VAT regime of the item. If the invoice is set to the standard VAT regime, the VAT regime can also be set separately for individual items.
Possible values:
0: Standard regime
1: Reverse charge
2: VAT exemption
3: Intra-EU supply of goods
4: Export of goods outside the EU
5: Pass-through items, not included in the taxable amount
6: Service outside the EU, place of supply abroad
Values 1 to 6 are available only to VAT payers.
Default value: 0
p_custom optional parameter Any text information sent via the API for the invoice item. It is shown as a separate column in the Excel export.
text, max. 50 characters
Data format before sending:
Array
(
    [key] => dJyMc*53@687*wGhofIWi!WDcEEQUdmj
    [email] => name@example.com
    [apitest] => 1
    [d] => Array
        (
            [d_name] => Moje společnost, s.r.o.
            [d_street] => Táborská 231/10
            [d_city] => Praha 4 - Nusle
            [d_zip] => 140 00
            [d_state] => Česká republika
            [d_ico] => 60991234
            [d_dic] => CZ60991234
            [d_vatpayer] => 1
            [d_viewpayer] => 1
            [d_info] => Zapsaná v obchodním rejstříku u Městského soudu v Praze, oddíl B
            [d_bankaccount] => 12345678/0100
            [d_bank] => Komerční banka
            [d_iban] => CZ620100000000012345678
            [d_swift] => KOMBCZPP
            [d_email] => info@example.com
            [d_web] => www.example.com
            [d_phone] => +420 601 111 111
        )

    [o] => Array
        (
            [o_name] => Petr Novák
            [o_street] => Pod kaštany 2299/10
            [o_city] => Brno - Žabovřesky
            [o_zip] => 616 00
            [o_state] => 
            [o_ico] => 
            [o_dic] => 
            [o_email] => client@example.com
        )

    [f] => Array
        (
            [f_number] => 2024099
            [f_vs] => 2024099
            [f_ks] => 308
            [f_date_issue] => 2014-02-14
            [f_date_delivery] => 2024-02-14
            [f_date_due] => 2024-04-28
            [f_issued_by] => Ing. Zbyněk Tuček
            [f_payment] => prevod
            [f_logo] => 1
            [f_stamp] => 0
            [f_currency] => Kč
            [f_type] => 1
            [f_paid] => 
            [f_rounding] => 0
            [f_style] => standard
            [f_language] => CS
            [f_qr] => 1
            [f_order] => OBJ-2017-514
            [f_tags] => Array
                (
                    [0] => VIP klient
                    [1] => Doprava zdarma
                )

        )

    [p] => Array
        (
            [0] => Array
                (
                    [p_text] => Malířské práce
                    [p_quantity] => 3
                    [p_unit] => hod
                    [p_price] => 300
                    [p_vat] => 21
                )

            [1] => Array
                (
                    [p_text] => Natěračské a lakýrnické práce
                    [p_quantity] => 2
                    [p_unit] => hod
                    [p_vat] => 21
                    [p_pricevat] => 450
                )

        )

)


List of return codes:
Status ID Meaning Description
1 OK Everything went fine, the invoice was created
2 Error The data parameter was not sent via the GET method.
3 Error The API key is missing or has an invalid number of characters.
4 Error The API key is not entered correctly.
5 Error The email parameter is missing.
6 Error The username or the API key is not correct.
7 Error The user does not exist.
8 Error The supplier ID or the supplier name must be provided.
9 Error Cancelled
10 Error The provided supplier ID is not correct.
11 Error The supplier name is missing.
12 Error The customer name is missing.
13 Error Invoice data is missing.
14 Error Invoice items are missing or not entered correctly.
15 Error Error in an invoice item.
16 Error The quantity in an invoice item is not a number.
17 Error The amount excluding tax in an invoice item is not a number.
18 Error The tax in percent is not entered correctly.
19 Error An item has neither an amount excluding tax nor an amount including tax.
20 Error Unsupported invoice language.
21 Error An invoice item has no price excluding tax while the supplier is not a VAT payer.
22 Error The price including tax in an invoice item is not a number.
23 Error A credit note or a debit note must include a reference to the original document f_original_num.
24 Error The total amount of a credit note must be negative.
25 Error The received payment date f_date_payment in a receipt for a received payment is not entered correctly.
26 Error A receipt for a received payment must not contain the received advance payments value f_paid.
27 Error Invalid VAT regime, the value is out of the allowed range.
28 Error The selected VAT regime requires the supplier to be a VAT payer.
Sample source code:
<?php

// Příprava základních dat:
$data = [];

// Váš API klíč:
$data['key'] = "dJyMc*53@687*wGhofIWi!WDcEEQUdmj";

// Váš email (příp. uživatelské jméno):
$data['email'] = "name@example.com";

// V případě, že budeme testovat API, zvolíme hodnotu 1
// Znamená to, že všechny vytvořené faktury se automaticky odstraní o 5 - 10 minut od vytvoření
$data['apitest'] = 1; //hodnota může být 1 nebo 0


// Příprava dat dodavatele
$dodavatel = [];

// Údaje dodavatele můžeme použít buď z uložených záznamů v seznamu Moje společnosti
// nebo údaje dodavatele vložíme zadáním dat.
// Pokud použijeme stávajícího dodavatele, vložíme pouze jeho ID.
// $dodavatel['d_id'] = 123; // ID dodavatele najdeme v seznamu Moje společnosti

// nebo (ne obě) :
$dodavatel['d_name'] = "Moje společnost, s.r.o."; // Obchodní jméno dodavatele
$dodavatel['d_street'] = "Táborská 231/10"; // Ulice
$dodavatel['d_city'] = "Praha 4 - Nusle"; // Město
$dodavatel['d_zip'] = "140 00"; // PSČ
$dodavatel['d_state'] = "Česká republika"; // Stát
$dodavatel['d_ico'] = "60991234"; // IČO
$dodavatel['d_dic'] = "CZ60991234"; // DIČ
$dodavatel['d_vatpayer'] = "1"; // Plátce DPH. Pokud je dodavatel plátcem DPH ponechte
// hodnotu 1, pokud není plátcem DPH, napište 0.
$dodavatel['d_viewpayer'] = "1"; // Pokud chcete zobrazit informaci na faktuře,
// že dodavatel je / není plátcem DPH.
$dodavatel['d_info'] = "Zapsaná v obchodním rejstříku u Městského soudu v Praze, oddíl B";
//Info o dodavateli
$dodavatel['d_bankaccount'] = "12345678/0100"; // Číslo účtu
$dodavatel['d_bank'] = "Komerční banka"; // Název banky
$dodavatel['d_iban'] = "CZ620100000000012345678"; // IBAN
$dodavatel['d_swift'] = "KOMBCZPP"; // SWIFT
$dodavatel['d_email'] = "info@example.com"; // E-mail
$dodavatel['d_web'] = "www.example.com"; // WEB
$dodavatel['d_phone'] = "+420 601 111 111"; // Telefon

// Přidání dodavatele k datům:
$data['d'] = $dodavatel;


// Příprava dat odběratele
$odberatel = [];
$odberatel['o_name'] = "Petr Novák"; // Název odběratele
$odberatel['o_street'] = "Pod kaštany 2299/10"; // Ulice
$odberatel['o_city'] = "Brno - Žabovřesky"; // Město
$odberatel['o_zip'] = "616 00"; // PSČ
$odberatel['o_state'] = ""; // Stát
$odberatel['o_ico'] = ""; // IČO
$odberatel['o_dic'] = ""; // DIČ
$odberatel['o_email'] = "client@example.com"; // Email odběratele

// Přidání odběratele k datům:
$data['o'] = $odberatel;


// Příprava fakturačních údajů
$faktura = [];

// Číslo faktury můžeme zadat ručně:
$faktura['f_number'] = "2024099";
// Pokud chceme vypočítat číslo faktury automaticky, toto pole nevyplňte. Doporučuje se
// ovšem mít zapnuté a nastavené automatické číslování faktur pro vybraného dodavatele.

$faktura['f_vs'] = "2024099"; // Variabilní symbol
$faktura['f_ks'] = "308"; // Konstantní symbol
$faktura['f_date_issue'] = '2014-02-14'; // Datum vystavení ve formátu RRRR-MM-DD
$faktura['f_date_delivery'] = '2024-02-14'; // Datum dodaní ve formátu RRRR-MM-DD
$faktura['f_date_due'] = '2024-04-28'; // Datum splatnosti ve formátu RRRR-MM-DD
$faktura['f_issued_by'] = "Ing. Zbyněk Tuček";  // Fakturu vystavil
$faktura['f_payment'] = "prevod";   // Druh plaby. Na výběr jsou "prevod", "poukazka",
// "hotovost", "dobirka", "registracna_pokladna", "jina", "eprovider"
$faktura['f_logo'] = "1";   // Zobrazit logo dodavatele. Pouze v případě, že byl
// dodavatel vybrán pomocí ID a má uloženo logo.
$faktura['f_stamp'] = "0";  // Nezobrazit razítko
$faktura['f_currency'] = "Kč";  // Měna faktury
$faktura['f_type'] = "1";  // Faktura
$faktura['f_paid'] = "";  // Již uhrazená částka nedaňovými zálohami
$faktura['f_rounding'] = "0";  // Zaokrouhlení - žádné
$faktura['f_style'] = "standard";  // Styl faktury. Možnosti jsou standard nebo classic
$faktura['f_language'] = "CS";   // Jazyk faktury: CS - čeština
$faktura['f_qr'] = "1";   // Zobrazit QR kód na faktuře
$faktura['f_order'] = "OBJ-2017-514";  // Číslo objednávky
$faktura['f_tags'] = ["VIP klient", "Doprava zdarma"];  // Přiřadit označení k faktuře

// Přidání fakturačních údajů k datům:
$data['f'] = $faktura;


// Příprava fakturačních položek
$polozky = [];

// první položka:
$polozka = [];
$polozka['p_text'] = "Malířské práce"; // Název služby nebo zboží
$polozka['p_quantity'] = "3"; // Množství
$polozka['p_unit'] = "hod"; // Měrná jednotka
$polozka['p_price'] = "300"; // Cena za jednu jednotku bez DPH
$polozka['p_vat'] = "21"; // Daň v %
// přiřazení k položkám:
$polozky[] = $polozka;
// druhá položka:
$polozka = [];
$polozka['p_text'] = "Natěračské a lakýrnické práce"; // Název služby nebo zboží
$polozka['p_quantity'] = "2"; // Množství
$polozka['p_unit'] = "hod"; // Měrná jednotka
$polozka['p_vat'] = "21"; // Daň v %
$polozka['p_pricevat'] = "450"; // Cena za jednu jednotku včetně DPH
// přiřazení k položkám:
$polozky[] = $polozka;

// přiřazení fakturačních položek k datům:
$data['p'] = $polozky;

// Data se uloží do formátu JSON:
$data_json = json_encode($data);

// Data se odešlou:
$url = 'https://www.fakturyweb.cz/api/nf?data=' . urlencode($data_json);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$output = curl_exec($ch);

// Výsledek:
$result = json_decode($output, true);
if ($result['status'] == 1) {
    echo "Uloženo, nová faktura má kód: " . $result['code'] . "<br />";
    echo "Číslo faktury: " . $result['number'] . " <br />";
    echo "Faktura vytvořená: " . $result['created'] . " <br />";
} else {
    echo "Vyskytla se chyba č." . $result['status'];
}

Response:
Array
(
    [status] => 1
    [code] => 1a35b89cd48eaf8940a6409ff45a0cc5
    [number] => FA2024015
    [created] => 2024-02-15 17:45:12
)

Session initialization

Session initialization is required for working with documents, for example displaying an invoice, paying an invoice, viewing a quote detail and so on. API call for session initialization:
https://www.fakturyweb.cz/api/init?data={JSON}

Basic parameters:
Parameter Attribute Description
key required parameter API key.
email required parameter E-mail (or username) you use to log in to Fakturyweb.
Data format before sending:
Array
(
    [key] => vJyMc*4@2754*wGhofIWi!QDcEEQUdmj
    [email] => name@example.com
)


List of return codes:
Status ID Meaning Description
1 OK Everything went fine, the session was initialized
102 Error The data parameter was not sent via the GET method.
103 Error The API key is missing or has an invalid number of characters.
104 Error The API key is not entered correctly.
105 Error The email parameter is missing.
106 Error The username or the API key is not correct.
107 Error The user does not exist.
Sample source code:
<?php

// Příprava základních dat:
$data = [];

// Váš API klíč:
$data['key'] = "dJyMc*53@687*wGhofIWi!WDcEEQUdmj";

// Váš email (příp. uživatelské jméno):
$data['email'] = "name@example.com";

// Data se uloží do formátu JSON:
$data_json = json_encode($data);

// Inicializace sezení
$url = 'https://www.fakturyweb.cz/api/init?data=' . urlencode($data_json);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$output = curl_exec($ch);
$result = json_decode($output, true);

// Výsledek:
$result = json_decode($output, true);
if ($result['status'] == 1) {
    echo "Sezení bylo vytvořeno";
} else {
    echo "Vyskytla se chyba č." . $result['status'];
}

Response:
Array
(
    [status] => 1
)

Displaying an invoice

A session must be initialized before this call (see above). API call for displaying an invoice:
https://www.fakturyweb.cz/api/zf?data={JSON}

Basic parameters:
Parameter Attribute Description
key required parameter API key.
email required parameter E-mail (or username) you use to log in to Fakturyweb.
code required parameter Invoice code (obtained from the API response when the invoice was created)
Data format before sending:
Array
(
    [key] => vJyMc*4@2754*wGhofIWi!QDcEEQUdmj
    [email] => name@example.com
    [code] => 26915945a67c8b7ba74dac59c5badfbf
)


List of return codes:
Status ID Meaning Description
1 OK Everything went fine
202 Error The data parameter was not sent via the GET method.
203 Error The API key is missing or has an invalid number of characters.
204 Error The API key is not entered correctly.
205 Error The email parameter is missing.
206 Error No session has been initialized
207 Error The initialized session is not valid
208 Error The username or the API key is not correct.
209 Error The user does not exist.
210 Error The invoice code is missing.
211 Error The invoice code is not entered correctly.
212 Error Error while selecting the invoice.
213 Error Error while rendering the invoice template.
Sample source code:
<?php

// Příprava základních dat:
$data = [];

// Váš API klíč:
$data['key'] = "dJyMc*53@687*wGhofIWi!WDcEEQUdmj";

// Váš email (příp. uživatelské jméno):
$data['email'] = "name@example.com";

// Data se uloží do formátu JSON:
$data_json = json_encode($data);


// Inicializace sezení
$url = 'https://www.fakturyweb.cz/api/init?data=' . urlencode($data_json);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$output = curl_exec($ch);
$result = json_decode($output, true);

// Výsledek:
$result = json_decode($output, true);
if ($result['status'] != 1) {
    throw new Exception("Vyskytla se chyba č. " . $result['status']);
}

// Kód faktury:
$data['code'] = "14915945a66c8b7be74dac59c5badfbf";

// Data se uloží do formátu JSON:
$data_json = json_encode($data);


// Data se odešlou:
$url = 'https://www.fakturyweb.cz/api/zf?data=' . urlencode($data_json);
curl_setopt($ch, CURLOPT_URL, $url);
$output = curl_exec($ch);
$result = json_decode($output, true);
$url = $result['url'];
$cislo = $result['number'];


// Výsledek:
$result = json_decode($output, true);
if ($result['status'] != 1) {
    throw new Exception("Vyskytla se chyba č. " . $result['status']);
}

// pro zobrazení faktury:
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="' . $cislo . '.pdf"');
header('Cache-Control: private, max-age=0, must-revalidate');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
echo curl_exec($ch);


/*
// pro download faktury:
header('Content-Type: application/download');
header('Content-Disposition: inline; filename="'.$cislo.'.pdf"');
header('Cache-Control: private, max-age=0, must-revalidate');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
echo curl_exec($ch);
*/

Response:
Array
(
    [status] => 1
    [url] => http://www.fakturyweb.cz/faktury/detail-soubor?f=26915945a67c8b7ba74dac59c5badfbf
    [number] => FA2019015
)

Paying an invoice

A session must be initialized before this call (see above). API call for marking an invoice as paid:
https://www.fakturyweb.cz/api/uf?data={JSON}

Basic parameters:
Parameter Attribute Description
key required parameter API key.
email required parameter E-mail (or username) you use to log in to Fakturyweb.
code required parameter Invoice code (obtained from the API response when the invoice was created)
date optional parameter Invoice payment date
Default value: 'current date'
Data format before sending:
Array
(
    [key] => vJyMc*4@2754*wGhofIWi!QDcEEQUdmj
    [email] => name@example.com
    [code] => 26915945a67c8b7ba74dac59c5badfbf
    [date] => 2019-02-15
)


List of return codes:
Status ID Meaning Description
1 OK Everything went fine
302 Error The data parameter was not sent via the GET method.
303 Error The API key is missing or has an invalid number of characters.
304 Error The API key is not entered correctly.
305 Error The email parameter is missing.
306 Error No session has been initialized
307 Error The initialized session is not valid
308 Error The username or the API key is not correct.
309 Error The user does not exist.
310 Error The invoice code is missing.
311 Error The invoice code is not entered correctly.
Sample source code:
<?php

// Příprava základních dat:
$data = [];

// Váš API klíč:
$data['key'] = "dJyMc*53@687*wGhofIWi!WDcEEQUdmj";

// Váš email (příp. uživatelské jméno):
$data['email'] = "name@example.com";

// Data se uloží do formátu JSON:
$data_json = json_encode($data);

// Inicializace sezení
$url = 'https://www.fakturyweb.cz/api/init?data=' . urlencode($data_json);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$output = curl_exec($ch);
$result = json_decode($output, true);

// Výsledek:
$result = json_decode($output, true);
if ($result['status'] != 1) {
    throw new Exception("Vyskytla se chyba č. " . $result['status']);
}

// Kod faktury:
$data['code'] = "14915945a66c8b7be74dac59c5badfbf";
// Datum úhrady
$data['date'] = "2017-06-01"; // případně žádný záznam pro nastavení dnešního dne úhrady

// Data se uloží do formátu JSON:
$data_json = json_encode($data);


// Data se odešlou:
$url = 'https://www.fakturyweb.cz/api/uf?data=' . urlencode($data_json);
curl_setopt($ch, CURLOPT_URL, $url);
$output = curl_exec($ch);
$result = json_decode($output, true);


// Výsledek:
$result = json_decode($output, true);
if ($result['status'] == 1) {
    echo "Faktura byla uhrazena";
} else {
    echo "Vyskytla se chyba č." . $result['status'];
}


Response:
Array
(
    [status] => 1
)

Invoice status and detail

A session must be initialized before this call (see above). API call for displaying the invoice status and detail:
https://www.fakturyweb.cz/api/status?data={JSON}

Basic parameters:
Parameter Attribute Description
key required parameter API key.
email required parameter E-mail (or username) you use to log in to Fakturyweb.
code required parameter Invoice code (obtained from the API response when the invoice was created)
Data format before sending:
Array
(
    [key] => vJyMc*4@2754*wGhofIWi!QDcEEQUdmj
    [email] => name@example.com
    [code] => 26915945a67c8b7ba74dac59c5badfbf
)


List of return codes:
Status ID Meaning Description
1 OK Everything went fine
402 Error The data parameter was not sent via the GET method.
403 Error The API key is missing or has an invalid number of characters.
404 Error The API key is not entered correctly.
405 Error The email parameter is missing.
406 Error No session has been initialized
407 Error The initialized session is not valid
408 Error The username or the API key is not correct.
409 Error The user does not exist.
410 Error The invoice code is missing.
411 Error The invoice code is not entered correctly.
412 Error Error while selecting the invoice
413 Error Error while rendering the invoice template
Sample source code:
<?php

// Příprava základních dat:
$data = [];

// Váš API klíč:
$data['key'] = "dJyMc*53@687*wGhofIWi!WDcEEQUdmj";

// Váš email (příp. uživatelské jméno):
$data['email'] = "name@example.com";

// Data se uloží do formátu JSON:
$data_json = json_encode($data);

// Inicializace sezení
$url = 'https://www.fakturyweb.cz/api/init?data=' . urlencode($data_json);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$output = curl_exec($ch);


// Výsledek:
$result = json_decode($output, true);
if ($result['status'] != 1) {
    throw new Exception("Vyskytla se chyba č. " . $result['status']);
}


// Kód faktury:
$data['code'] = "14915945a66c8b7be74dac59c5badfbf";

// Data se uloží do formátu JSON:
$data_json = json_encode($data);


// Data se odešlou:
$url = 'https://www.fakturyweb.cz/api/status?data=' . urlencode($data_json);
curl_setopt($ch, CURLOPT_URL, $url);
$output = curl_exec($ch);


// Výsledek:
$result = json_decode($output, true);
if ($result['status'] == 1) {
    echo "Dodavatel: {$result['supplier']} \n";
    echo "Dodavatel IČO: {$result['supplier_ico']} \n";
    echo "Odběratel / Zákazník: {$result['customer']} \n";
    echo "Odběratel / Zákazník IČO: {$result['customer_ico']} \n";
    // Možnosti: faktura, zalohova_faktura, dobropis, danovy_doklad
    echo "Typ faktury: {$result['invoice_type']} \n";
    echo "Číslo faktury: {$result['invoice_number']} \n";
    echo "Částka bez DPH: {$result['invoice_amount']} \n";
    if (isset($result['invoice_amount_vat'])){
        echo "Částka s DPH: {$result['invoice_amount_vat']} \n";
    }
    echo "Měna: {$result['invoice_currency']} \n";
    echo "Datum vystavení: {$result['invoice_date_issue']} \n";
    echo "Datum dodání: {$result['invoice_date_delivery']} \n";
    echo "Datum splatnosti: {$result['invoice_date_due']} \n";
    // Možnosti: ano, ne, castecne
    echo "Faktura uhrazena: {$result['invoice_paid']} \n";
    if ($result['invoice_paid'] != 'ne'){
        echo "Uhrazena částka: {$result['invoice_paid_amount']} \n";
        echo "Datum úhrady: {$result['invoice_date_payment']} \n";
    }
    echo "Vlastní data z API: {$result['invoice_api_custom']} \n";
    if (isset($result['invoice_tags']) && is_array($result['invoice_tags'])){
        echo "Tagy faktury: ";
        echo implode(", ",$result['invoice_tags']);
    }
} else {
    echo "Vyskytla se chyba č." . $result['status'];
}



Response:
Array
(
    [status] => 1
    [supplier] => Moje společnost, s.r.o.
    [supplier_street] => Táborská 231/10
    [supplier_city] => Praha 4 - Nusle
    [supplier_zip] => 140 00
    [supplier_state] => Česká republika
    [supplier_ico] => 60991234
    [supplier_dic] => CZ60991234
    [supplier_info] => Zapsaná v obchodním rejstříku u Městského soudu v Praze, oddíl B, vložka 12345
    [supplier_bankaccount] => 12345678/0100
    [supplier_bank] => Komerční banka
    [supplier_iban] => CZ620100000000012345678
    [supplier_swift] => KOMBCZPP
    [supplier_email] => me@example.com
    [supplier_phone] => +420 601 111 111
    [supplier_web] => 
    [supplier_custom_key_1] => 
    [supplier_custom_value_1] => 
    [supplier_custom_key_2] => 
    [supplier_custom_value_2] => 
    [customer] =>  Petr Novák
    [customer_street] => Pod kaštany 2299/10
    [customer_city] => Brno - Žabovřesky
    [customer_zip] => 616 00
    [customer_state] => 
    [customer_ico] => 
    [customer_dic] => 
    [customer_email] => client@example.com
    [customer_info] => 
    [customer_delivery_name] => 
    [customer_delivery_street] => 
    [customer_delivery_city] => 
    [customer_delivery_zip] => 
    [customer_delivery_state] => 
    [customer_custom_key_1] => 
    [customer_custom_value_1] => 
    [customer_custom_key_2] => 
    [customer_custom_value_2] => 
    [invoice_type] => faktura
    [invoice_number] => 2022099
    [invoice_vs] => 2022099
    [invoice_ks] => 
    [invoice_payment_type] => prevod
    [invoice_currency] => Kč
    [invoice_date_issue] => 2022-04-27
    [invoice_date_delivery] => 2022-04-27
    [invoice_date_due] => 2022-05-04
    [invoice_order] => 
    [invoice_issued_by] => Martin Hrubý
    [invoice_note] => Poznámka pod položkami
    [invoice_note_above] => Poznámka nad položkami
    [invoice_amount] => 5336.19
    [invoice_amount_vat] => 6456.79
    [invoice_vat_reverse_c] => ne
    [invoice_paid_advanced] => 500
    [invoice_total_discount_perc] => 10
    [invoice_to_pay] => 5956.79
    [invoice_paid] => ne
    [invoice_api_custom] => 
    [invoice_language] => cz
    [items] => Array
        (
            [0] => Array
                (
                    [item_name] => Diamantový kotouč na obklady 
                    [item_unit] => ks
                    [item_quantity] => 8
                    [item_unit_price] => 518
                    [item_unit_price_total] => 626.78
                    [item_vat_rate] => 21
                    [item_vat_total] => 870.24
                    [item_unit_price_vat] => 626.78
                    [item_unit_price_totla_vat] => 5014.24
                    [item_api_custom] => 
                )

            [1] => Array
                (
                    [item_name] => Sada nylonových drátěných kartáčů
                    [item_unit] => ks
                    [item_quantity] => 10
                    [item_unit_price] => 178.51
                    [item_unit_price_total] => 216
                    [item_vat_rate] => 21
                    [item_vat_total] => 374.88
                    [item_unit_price_vat] => 216
                    [item_unit_price_totla_vat] => 2160
                    [item_api_custom] => 
                )

        )

    [invoice_tags] => Array
        (
            [0] => Tag 1
            [1] => Tag 2
        )

)

List of invoices

A session must be initialized before this call (see above). The following URLs return lists of invoices.
All invoices created in the period:
https://www.fakturyweb.cz/api/list/created?data={JSON}
All invoices with an issue date in the period:
https://www.fakturyweb.cz/api/list/issued?data={JSON}
All invoices with a delivery date in the period:
https://www.fakturyweb.cz/api/list/delivered?data={JSON}
All invoices with a payment date in the period:
https://www.fakturyweb.cz/api/list/paid?data={JSON}
Basic parameters:
Parameter Attribute Description
key required parameter API key.
email required parameter E-mail (or username) you use to log in to Fakturyweb.
from optional parameter Search date 'From'
Format: YYYY-MM-DD
to optional parameter Search date 'To'
Format: YYYY-MM-DD
Data format before sending:
Array
(
    [key] => vJyMc*4@2754*wGhofIWi!QDcEEQUdmj
    [email] => name@example.com
    [from] => 2021-01-01
)


List of return codes:
Status ID Meaning Description
1 OK Everything went fine
502 Error The data parameter was not sent via the GET method.
503 Error The API key is missing or has an invalid number of characters.
504 Error The API key is not entered correctly.
505 Error The email parameter is missing.
506 Error No session has been initialized
507 Error The initialized session is not valid
508 Error The username or the API key is not correct.
509 Error The user does not exist.
510 Error Invalid URL.
511 Error The 'From' date is not entered correctly.
512 Error The 'To' date is not entered correctly.
513 Error The requested list could not be identified, probably an error in the URL.
Sample source code:
<?php

// Příprava základních dat:
$data = [];

// Váš API klíč:
$data['key'] = "dJyMc*53@687*wGhofIWi!WDcEEQUdmj";

// Váš email (příp. uživatelské jméno):
$data['email'] = "name@example.com";

// Data se uloží do formátu JSON:
$data_json = json_encode($data);

// Inicializace sezení
$url = 'https://www.fakturyweb.cz/api/init?data=' . urlencode($data_json);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$output = curl_exec($ch);


// Výsledek:
$result = json_decode($output, true);
if ($result['status'] != 1) {
    throw new Exception("Vyskytla se chyba č. " . $result['status']);
}


// Data v kalendářním roce 2021
$data['from'] = '2021-01-01';
$data['to'] = '2021-12-31';
// Data se uloží do formátu JSON:
$data_json = json_encode($data);


// Data se odešlou:
$url = 'https://www.fakturyweb.cz/api/list/paid?data=' . urlencode($data_json);
curl_setopt($ch, CURLOPT_URL, $url);
$output = curl_exec($ch);


// Výsledek:
$result = json_decode($output, true);
if ($result['status'] == 1) {
    $faktury = $result['invoices'];
    foreach ($faktury as $faktura) {
        echo "Kód: {$faktura['code']} \n";
        echo "Dodavatel: {$faktura['supplier']} \n";
        echo "Dodavatel IČO: {$faktura['supplier_ico']} \n";
        echo "Odběratel  / Zákazník: {$faktura['customer']} \n";
        echo "Odběratel / Zákazník IČO: {$faktura['customer_ico']} \n";
        // Možnosti: faktura, zalohova_faktura, dobropis, danovy_doklad
        echo "Typ faktury: {$faktura['invoice_type']} \n";
        echo "Číslo faktury: {$faktura['invoice_number']} \n";
        echo "Částka bez DPH: {$faktura['invoice_amount']} \n";
        if (isset($faktura['invoice_amount_vat'])) {
            echo "Částka s DPH: {$faktura['invoice_amount_vat']} \n";
        }
        echo "Měna : {$faktura['invoice_currency']} \n";
        echo "Datum vystavení: {$faktura['invoice_date_issue']} \n";
        echo "Datum dodání: {$faktura['invoice_date_delivery']} \n";
        echo "Dátum splatnosti: {$faktura['invoice_date_due']} \n";
        // Možnosti: ano, ne, castecne
        echo "Faktura uhrazena: {$faktura['invoice_paid']} \n";
        if ($faktura['invoice_paid'] != 'ne') {
            echo "Uhrazena částka: {$faktura['invoice_paid_amount']} \n";
            echo "Datum úhrady: {$faktura['invoice_date_payment']} \n";
        }
        echo "Vlastní data z API: {$faktura['invoice_api_custom']} \n";
        echo "Tagy: {$faktura['tags']} \n";
    }
} else {
    echo "Vyskytla se chyba č." . $result['status'];
}



Response:
Array
(
    [status] => 1
    [invoices] => Array
        (
            [0] => Array
                (
                    [code] => 1a35b89cd48eaf8940a6409ff45a0cc5
                    [supplier] => Moje společnost, s.r.o.
                    [supplier_ico] => 60991234
                    [customer] => Petr Novák
                    [customer_ico] => 
                    [invoice_type] => faktura
                    [invoice_number] => 20210400
                    [invoice_amount] => 2000
                    [invoice_amount_vat] => 2420
                    [invoice_currency] => CZK
                    [invoice_date_issue] => 2021-01-10
                    [invoice_date_delivery] => 2021-01-10
                    [invoice_date_due] => 2021-01-25
                    [invoice_paid] => ano
                    [invoice_paid_amount] => 2420
                    [invoice_date_payment] => 2021-01-19
                    [invoice_api_custom] => data z API
                    [tags] => Tag1 ,Tag2
                )

        )

)

Creating a new quote

API call for creating a new quote:
https://www.fakturyweb.cz/api/ncn?data={JSON}
The following table lists the parameters you can use to create a new quote.

Basic parameters:
Parameter Attribute Description
key required parameter API key.
email required parameter E-mail (or username) you use to log in to Fakturyweb.
apitest optional parameter The apitest parameter specifies whether the created quote is for testing purposes only. This parameter should be used only by developers implementing the Fakturyweb API. The system will treat the created quote as a test one and will delete it within 5 to 10 minutes. We recommend keeping this value enabled while testing your API implementation. Disable this value in production, otherwise the quotes will be deleted automatically.
Possible values: 1 or 0
Default value: 0
Supplier parameters:
The supplier can be selected either by the d_id parameter, referring to a supplier stored in the My companies list (option 1), or by filling in all the required details in the parameters (option 2).
Parameter Attribute Description
d_id option 1 / required parameter Supplier ID (you will find the ID in the My companies list).
d_name option 2 / required parameter Supplier's business name.
d_street option 2 / optional parameter Supplier's street.
d_city option 2 / optional parameter Supplier's city.
d_state option 2 / optional parameter Supplier's country.
d_zip option 2 / optional parameter Supplier's postal code.
d_ico option 2 / optional parameter Supplier's Company ID (IČO).
d_dic option 2 / optional parameter Supplier's Tax ID (DIČ).
d_vatpayer option 2 / optional parameter VAT payer.
Possible values:
VAT payer: 1
Non-VAT payer: 0
Default value: 0
d_viewpayer option 2 / optional parameter Show on the quote whether the supplier is a VAT payer.
Possible values:
Yes: 1
No: 0
Default value: 1
d_info option 2 / optional parameter Supplier information.
d_bankaccount option 2 / optional parameter Supplier's bank account number.
d_bank option 2 / optional parameter Supplier's bank name.
d_iban option 2 / optional parameter Supplier's IBAN.
d_swift option 2 / optional parameter Supplier's SWIFT.
d_email option 2 / optional parameter Supplier's e-mail.
d_web option 2 / optional parameter Supplier's website.
d_phone option 2 / optional parameter Supplier's phone.
d_custom_key_1 option 2 / optional parameter Custom field no. 1 - key
d_custom_value_1 option 2 / optional parameter Custom field no. 1 - value
d_custom_key_2 option 2 / optional parameter Custom field no. 2 - key
d_custom_value_2 option 2 / optional parameter Custom field no. 2 - value
Customer parameters:
Parameter Attribute Description
o_name required parameter Customer's business name.
o_street optional parameter Customer's street.
o_city optional parameter Customer's city.
o_state optional parameter Customer's country.
o_zip optional parameter Customer's postal code.
o_ico optional parameter Customer's Company ID (IČO).
o_dic optional parameter Customer's Tax ID (DIČ).
o_email optional parameter Customer's e-mail.
o_name_d optional parameter Delivery address - business name.
o_street_d optional parameter Delivery address - street.
o_city_d optional parameter Delivery address - city.
o_state_d optional parameter Delivery address - country.
o_zip_d optional parameter Delivery address - postal code.
o_custom_key_1 optional parameter Custom field no. 1 - key
o_custom_value_1 optional parameter Custom field no. 1 - value
o_custom_key_2 optional parameter Custom field no. 2 - key
o_custom_value_2 optional parameter Custom field no. 2 - value
Quote parameters:
Parameter Attribute Description
po_rounding optional parameter Rounding of the total amount due
Possible values:
0: no rounding
1: round up to a whole number
2: round down to a whole number
4: arithmetic rounding to a whole number
Default value: 0
po_number optional parameter Quote number. If not provided, the number is automatically incremented by 1 from the most recently created quote (the issue date is decisive; the quote number must be numeric).
po_date_issue optional parameter Issue date. In the YYYY-MM-DD format.
Default value: current date
po_date_expiration optional parameter Quote validity date. In the YYYY-MM-DD format.
po_issued_by optional parameter Quote issued by.
po_note_above optional parameter Quote note. Displayed above the items.
po_note optional parameter Quote note. Displayed below the items. If the supplier is selected by the d_id parameter and po_note is empty, the note stored for that supplier is displayed.
po_internal_note optional parameter Internal note. For internal use only. It is not shown on the quote; it is visible only in the document detail in the system.
po_logo optional parameter Logo display. Possible values:
Not shown: 0
Shown: 1 (only if the supplier was loaded by d_id and has a logo stored)
po_stamp optional parameter Stamp display. Possible values:
Not shown: 0
Shown: 1 (only if the supplier was loaded by d_id and has a stamp stored)
po_currency optional parameter Quote currency. Currency code. The default value is Kč.
Default value: Kč
po_language optional parameter Quote language. Possible values:
CS, SK, EN, DE, ES, FR, IT, PL, HU, RU, NO, DK
Default value: CS
po_custom optional parameter Any text information sent via the API. It is shown as a separate column in the Excel export.
text, max. 50 characters
po_tags optional parameter A list (array) of tags from the My labels / tags list to be assigned to the document. Format:
Array
(
    [0] => Tag name 1
    [1] => Tag name 2
)
Quote item parameters:
Parameter Attribute Description
p_text required parameter Quote item text.
p_quantity required parameter Quantity. Number.
p_unit required parameter Unit of measure. For example kg, pcs, ...
p_price required parameter Amount per unit of measure excluding tax.
p_vat optional parameter Tax in percent. Fill in only if the supplier is a VAT payer.
p_pricevat optional parameter Amount per unit of measure including tax. Fill in only if the supplier is a VAT payer.
p_custom optional parameter Any text information sent via the API for the quote item. It is shown as a separate column in the Excel export.
text, max. 50 characters
Data format before sending:
Array
(
    [key] => vJyMc*4@2754*wGhofIWi!QDcEEQUdmj
    [email] => name@example.com
    [apitest] => 1
    [d] => Array
        (
            [d_name] => Moje společnost, s.r.o.
            [d_street] => Táborská 231/10
            [d_city] => Praha 4 - Nusle
            [d_zip] => 140 00
            [d_state] => Česká republika
            [d_ico] => 60991234
            [d_dic] => CZ60991234
            [d_vatpayer] => 1
            [d_viewpayer] => 0
            [d_info] => Zapsaná v obchodním rejstříku u Městského soudu v Praze, oddíl B, vložka 12345 
            [d_bankaccount] => 12345678/0100
            [d_bank] => Komerční banka
            [d_iban] => CZ620100000000012345678
            [d_swift] => KOMBCZPP
            [d_email] => info@example.com
            [d_web] => www.example.com
            [d_phone] => +420 601 111 111
        )

    [o] => Array
        (
            [o_name] => Petr Novák
            [o_street] => Pod kaštany 2299/10
            [o_city] => Brno - Žabovřesky
            [o_zip] => 616 00
            [o_state] => 
            [o_ico] => 
            [o_dic] => 
            [o_email] => client@example.com
        )

    [po] => Array
        (
            [po_number] => 2022099
            [po_date_issue] => 2022-01-01
            [po_date_expiration] => 2022-01-15
            [po_issued_by] => Martin Hrubý
            [po_note] => Nezávazná cenová nabídka platná 15 dní
            [po_currency] => Kč
            [po_language] => CZ
            [po_tags] => Array
                (
                    [0] => VIP klient
                    [1] => Doprava zdarma
                )

        )

    [p] => Array
        (
            [0] => Array
                (
                    [p_text] => Diamantový kotouč na obklady
                    [p_quantity] => 8
                    [p_unit] => ks
                    [p_price] => 518
                    [p_vat] => 21
                    [p_pricevat] => 626.78
                )

            [1] => Array
                (
                    [p_text] => Sada nylonových drátěných kartáčů
                    [p_quantity] => 10
                    [p_unit] => ks
                    [p_price] => 178.51
                    [p_vat] => 21
                    [p_pricevat] => 216
                )

        )

)


List of return codes:
Status ID Meaning Description
1 OK Everything went fine, the quote was created
602 Error The data parameter was not sent via the GET method.
603 Error The API key is missing or has an invalid number of characters.
604 Error The API key is not entered correctly.
605 Error The email parameter is missing.
606 Error The username or the API key is not correct.
607 Error The user does not exist.
608 Error The supplier ID or the supplier name must be provided.
609 Error The provided supplier ID is not correct.
610 Error The supplier name is missing.
611 Error The customer name is missing.
612 Error Quote data is missing.
613 Error Quote items are missing or not entered correctly.
614 Error Error in an item, a required value is missing.
615 Error The quantity in a quote item is not a number.
616 Error The amount excluding tax in an item is not a number.
617 Error The tax in percent is not entered correctly.
618 Error An item has neither an amount excluding tax nor an amount including tax.
619 Error Unsupported quote language.
620 Error An item has no amount excluding tax while the supplier is not a VAT payer.
621 Error The amount including tax in an item is not a number.
Sample source code:
<?php

// Příprava základních dat:
$data = [];

// Váš API klíč:
$data['key'] = "dJyMc*53@687*wGhofIWi!WDcEEQUdmj";

// Váš email (příp. uživatelské jméno):
$data['email'] = "name@example.com";

// V případě, že budeme testovat API, zvolíme hodnotu 1
// Znamená to, že všechny vytvořené cenové nabídky se automaticky smažou o 5 - 10 minut
$data['apitest'] = 1; //hodnota může být 1 nebo 0


// Příprava dat dodavatele
$dodavatel = [];

// Dodavatele můžeme použít již existujícího (uloženého v seznamu Moje společnosti)
// nebo dodavatele vytvoříme ručně vložením dat.
// Pokud použijeme stávajícího dodavatele, vložíme pouze jeho ID:
// $dodavatel['d_id'] = 123; // ID dodavatele najdeme v seznamu Moje společnosti

//nebo (ne obě) :
$dodavatel['d_name'] = "Moje společnost, s.r.o."; // Obchodní jméno dodavatele
$dodavatel['d_street'] = "Táborská 231/10"; // Ulice
$dodavatel['d_city'] = "Praha 4 - Nusle"; // Město
$dodavatel['d_zip'] = "140 00"; // PSČ
$dodavatel['d_state'] = "Česká republika"; // Stát
$dodavatel['d_ico'] = "60991234"; // IČO
$dodavatel['d_dic'] = "CZ60991234"; // DIČ
$dodavatel['d_vatpayer'] = "1"; // Plátce DPH. Pokud je dodavatel plátce DPH ponechte hodnotu 1,
// pokud není plátce DPH, napište 0.
$dodavatel['d_viewpayer'] = "1"; // Pokud chcete zobrazit informaci v nabídce,
// že dodavatel je plátcem/neplátcem DPH.
$dodavatel['d_info'] = "Zapsaná v obchodním rejstříku u Městského soudu v Praze, oddíl B";
//Info o dodavateli
$dodavatel['d_bankaccount'] = "12345678/0100"; // Číslo účtu
$dodavatel['d_bank'] = "Komerční banka"; // Název banky
$dodavatel['d_iban'] = "CZ620100000000012345678"; // IBAN
$dodavatel['d_swift'] = "KOMBCZPP"; // SWIFT
$dodavatel['d_email'] = "info@example.com"; // E-mail
$dodavatel['d_web'] = "www.example.com"; // WEB
$dodavatel['d_phone'] = "+420 601 111 111"; // Telefon

// Přidání dodavatele k datům:
$data['d'] = $dodavatel;


// Příprava dat odběratele
$odberatel = [];
$odberatel['o_name'] = "Petr Novák"; // Název odběratele
$odberatel['o_street'] = "Pod kaštany 2299/10"; // Ulice
$odberatel['o_city'] = "Brno - Žabovřesky"; // Město
$odberatel['o_zip'] = "616 00"; // PSČ
$odberatel['o_state'] = ""; // Stát
$odberatel['o_ico'] = ""; // IČO
$odberatel['o_dic'] = ""; // DIČ
$odberatel['o_email'] = "client@example.com"; // Email odběratele

// Přidání odběratele k datům:
$data['o'] = $odberatel;


// Příprava údajů cenové nabídky 
$cenovaNabidka = [];

// Číslo cenové nabídky můžeme zadat ručně :
$cenovaNabidka['po_number'] = "2022099";
// Pokud chceme vypočítat číslo automaticky, toto pole nevyplníme
$cenovaNabidka['po_date_issue'] = '2022-01-01'; // Datum vystavení ve formátu RRRR-MM-DD
$cenovaNabidka['po_date_expiration'] = '2022-01-15'; // Datum platnosti ve formátu RRRR-MM-DD
$cenovaNabidka['po_issued_by'] = "Martin Hrubý";  // Nabídku vystavil
$cenovaNabidka['po_logo'] = "1";   // Zobrazit logo dodavatele. Pouze v případě, že byl
// dodavatel vybrán pomocí ID a má přiřazeno logo.
$cenovaNabidka['po_stamp'] = "1";  // Zobrazit razítko dodavatele. Pouze v případě, že byl
// dodavatel vybran pomocí ID a má přiřazeno razítko
$cenovaNabidka['po_currency'] = "Kč";  // Měna cenové nabídky
$cenovaNabidka['po_language'] = "EN";   // Jazyk cenové nabídky
$cenovaNabidka['po_tags'] = ["VIP klient", "Doprava zdarma"];  // Přiřadit označení k nabídce

// Přidání údajů nabídky k datům:
$data['po'] = $cenovaNabidka;


// Příprava položek nabídky
$polozky = [];
// první položka:
$polozka = [];
$polozka['p_text'] = "Diamantový kotouč na obklady "; // Název služby nebo zboží
$polozka['p_quantity'] = "8"; // Množství
$polozka['p_unit'] = "ks"; // Měrná jednotka
$polozka['p_price'] = "518"; // Částka za jednu jednotku bez DPH
$polozka['p_vat'] = "21"; // Daň v %
// přiřazení k položkám:
$polozky[] = $polozka;

// druhá položka:
$polozka = [];
$polozka['p_text'] = "Sada nylonových drátěných kartáčů"; // Název služby nebo zboží
$polozka['p_quantity'] = "10"; // Množství
$polozka['p_unit'] = "ks"; // Měrná jednotka
$polozka['p_vat'] = "21"; // Daň v %
$polozka['p_pricevat'] = "216"; // Částka za jednu jednotku včetně DPH (Částka bez DPH se vypočítá)
// přiřazení k položkám:
$polozky[] = $polozka;

// přiřazení položek k datům:
$data['p'] = $polozky;


// Data se uloží do formátu JSON:
$data_json = json_encode($data);

// Data se odešlou:
$url = 'https://www.fakturyweb.cz/api/ncn?data=' . urlencode($data_json);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$output = curl_exec($ch);

// Výsledek:
$result = json_decode($output, true);
if ($result['status'] == 1) {
    echo "Uloženo, nová cenová má kód: " . $result['code'] . " <br />";
    echo "Číslo cenové nabídky: " . $result['number'] . " <br />";
    echo "Cenová nabídka vytvořená: " . $result['created'] . " <br />";
} else {
    echo "Vyskytla se chyba č." . $result['status'];
}

Response:
Array
(
    [status] => 1
    [code] => ca9658a5448a945059f44658bac985e5
    [number] => 2022099
    [created] => 2022-01-01 09:49:05
)

Displaying a quote

A session must be initialized before this call (see above). API call for displaying a quote:
https://www.fakturyweb.cz/api/zcn?data={JSON}

Basic parameters:
Parameter Attribute Description
key required parameter API key.
email required parameter E-mail (or username) you use to log in to Fakturyweb.
code required parameter Quote code (obtained from the API response when the quote was created)
Data format before sending:
Array
(
    [key] => vJyMc*4@2754*wGhofIWi!QDcEEQUdmj
    [email] => name@example.com
    [code] => aa9025bc0094c88445daa22b90eff3b
)


List of return codes:
Status ID Meaning Description
1 OK Everything went fine
702 Error The data parameter was not sent via the GET method.
703 Error The API key is missing or has an invalid number of characters.
704 Error The API key is not entered correctly.
705 Error The email parameter is missing.
706 Error No session has been initialized
707 Error The initialized session is not valid
708 Error The username or the API key is not correct.
709 Error The user does not exist.
710 Error The quote code is missing.
711 Error The quote code is not entered correctly.
712 Error Error while selecting the quote.
Sample source code:
<?php

// Příprava základních dat:
$data = [];

// Váš API klíč:
$data['key'] = "dJyMc*53@687*wGhofIWi!WDcEEQUdmj";

// Váš email (příp. uživatelské jméno):
$data['email'] = "name@example.com";

// Data se uloží do formátu JSON:
$data_json = json_encode($data);

// Inicializace sezení
$url = 'https://www.fakturyweb.cz/api/init?data=' . urlencode($data_json);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$output = curl_exec($ch);
$result = json_decode($output, true);

// Výsledek:
$result = json_decode($output, true);
if ($result['status'] != 1) {
    throw new Exception("Vyskytla se chyba č. " . $result['status']);
}

// Kód cenovej nabídky:
$data['code'] = "aa9025bc0094c88445daa22b90eff3b";

// Data se uloží do formátu JSON:
$data_json = json_encode($data);

// Data se odešlou:
$url = 'https://www.fakturyweb.cz/api/zcn?data=' . urlencode($data_json);
curl_setopt($ch, CURLOPT_URL, $url);
$output = curl_exec($ch);
$result = json_decode($output, true);
$url = $result['url'];
$cislo = $result['number'];


// Výsledek:
$result = json_decode($output, true);
if ($result['status'] != 1) {
    throw new Exception("Vyskytla se chyba č. " . $result['status']);
}

// pro zobrazení cenové nabídky:
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="' . $cislo . '.pdf"');
header('Cache-Control: private, max-age=0, must-revalidate');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
echo curl_exec($ch);



/*
// pro download cenové nabídky:
header('Content-Type: application/download');
header('Content-Disposition: inline; filename="'.$cislo.'.pdf"');
header('Cache-Control: private, max-age=0, must-revalidate');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
echo curl_exec($ch);
*/

Response:
Array
(
    [status] => 1
    [url] => https://www.fakturyweb.cz/cenove-nabidky/detail-soubor?cp=26915945a67c8b7ba74dac59c5badfbf
    [number] => 2022099
)

Quote status and detail

A session must be initialized before this call (see above). API call for displaying the quote status and detail:
https://www.fakturyweb.cz/api/cn-status?data={JSON}

Basic parameters:
Parameter Attribute Description
key required parameter API key.
email required parameter E-mail (or username) you use to log in to Fakturyweb.
code required parameter Quote code (obtained from the API response when the quote was created)
Data format before sending:
Array
(
    [key] => vJyMc*4@2754*wGhofIWi!QDcEEQUdmj
    [email] => name@example.com
    [code] => ae47ece062b0021144d768446b071fee
)


List of return codes:
Status ID Meaning Description
1 OK Everything went fine
802 Error The data parameter was not sent via the GET method.
803 Error The API key is missing or has an invalid number of characters.
804 Error The API key is not entered correctly.
805 Error The email parameter is missing.
806 Error No session has been initialized.
807 Error The initialized session is not valid.
808 Error The username or the API key is not correct.
809 Error The user does not exist.
810 Error The quote code is missing.
811 Error The quote code is not entered correctly.
812 Error Error while selecting the quote.
Sample source code:
<?php

// Příprava základních dat:
$data = [];

// Váš API klíč:
$data['key'] = "vJyMc*4@2754*wGhofIWi!QDcEEQUdmj";

// Váš email (příp. uživatelské jméno):
$data['email'] = "name@example.com";

// Data se uloží do formátu JSON:
$data_json = json_encode($data);

// Inicializace sezení
$url = 'https://www.fakturyweb.cz/api/init?data=' . urlencode($data_json);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$output = curl_exec($ch);

// Výsledek:
$result = json_decode($output, true);
if ($result['status'] != 1) {
    throw new Exception("Vyskytla se chyba č. " . $result['status']);
}

// Kód cenové nabídky:
$data['code'] = "ae47ece062b0021144d768446b071fee";

// Data se uloží do formátu JSON:
$data_json = json_encode($data);


// Data se odešlou:
$url = 'https://www.fakturyweb.cz/api/cn-status?data=' . urlencode($data_json);
curl_setopt($ch, CURLOPT_URL, $url);
$output = curl_exec($ch);


// Výsledek:
$result = json_decode($output, true);
if ($result['status'] == 1) {
    echo "Dodavatel: {$result['supplier']} \n";
    echo "Dodavatel IČO: {$result['supplier_ico']} \n";
    echo "Odběratel / Zákazník: {$result['customer']} \n";
    echo "Odběratel / Zákazník IČO: {$result['customer_ico']} \n";
    echo "Číslo cenové nabídky: {$result['offer_number']} \n";
    echo "Částka bez DPH: {$result['offer_amount']} \n";
    if (isset($result['offer_amount_vat'])){
        echo "Částka s DPH: {$result['offer_amount_vat']} \n";
    }
    echo "Měna: {$result['offer_currency']} \n";
    echo "Datum vystavení: {$result['offer_date_issue']} \n";
    echo "Datum platnosti: {$result['offer_date_expiration']} \n";
    echo "Vlastní data z API: {$result['offer_api_custom']} \n";
    if (isset($result['offer_tags']) && is_array($result['offer_tags'])){
        echo "Tagy cenové nabídky: ";
        echo implode(", ",$result['offer_tags']);
    }
} else {
    echo "Vyskytla se chyba č." . $result['status'];
}



Response:
Array
(
    [status] => 1
    [supplier] => Moje společnost, s.r.o.
    [supplier_street] => Táborská 231/10
    [supplier_city] => Praha 4 - Nusle
    [supplier_zip] => 140 00
    [supplier_state] => Česká republika
    [supplier_ico] => 60991234
    [supplier_dic] => CZ60991234
    [supplier_info] => Zapsaná v obchodním rejstříku u Městského soudu v Praze, oddíl B, vložka 12345
    [supplier_bankaccount] => 12345678/0100
    [supplier_bank] => Komerční banka
    [supplier_iban] => CZ620100000000012345678
    [supplier_swift] => KOMBCZPP
    [supplier_email] => me@example.com
    [supplier_phone] => +420 601 111 111
    [supplier_web] => 
    [supplier_custom_key_1] => 
    [supplier_custom_value_1] => 
    [supplier_custom_key_2] => 
    [supplier_custom_value_2] => 
    [customer] =>  Petr Novák
    [customer_street] => Pod kaštany 2299/10
    [customer_city] => Brno - Žabovřesky
    [customer_zip] => 616 00
    [customer_state] => 
    [customer_ico] => 
    [customer_dic] => 
    [customer_email] => client@example.com
    [customer_info] => 
    [customer_custom_key_1] => ID klienta
    [customer_custom_value_1] => 654
    [customer_custom_key_2] => 
    [customer_custom_value_2] => 
    [offer_number] => 2022003
    [offer_amount] => 5336.19
    [offer_amount_vat] => 6456.79
    [offer_total_discount_perc] => 10
    [offer_currency] => Kč
    [offer_date_issue] => 2022-03-01
    [offer_date_expiration] => 
    [offer_note] => Poznámka pod položkami
    [offer_note_above] => Poznámka nad položkami
    [offer_api_custom] => Test custom
    [offer_language] => cz
    [items] => Array
        (
            [0] => Array
                (
                    [item_name] => Diamantový kotouč na obklady 
                    [item_unit] => ks
                    [item_quantity] => 8
                    [item_unit_price] => 518
                    [item_unit_price_total] => 626.78
                    [item_vat_rate] => 21
                    [item_vat_total] => 870.24
                    [item_unit_price_vat] => 626.78
                    [item_unit_price_totla_vat] => 5014.24
                    [item_api_custom] => 
                )

            [1] => Array
                (
                    [item_name] => Sada nylonových drátěných kartáčů
                    [item_unit] => ks
                    [item_quantity] => 10
                    [item_unit_price] => 178.51
                    [item_unit_price_total] => 216
                    [item_vat_rate] => 21
                    [item_vat_total] => 374.88
                    [item_unit_price_vat] => 216
                    [item_unit_price_totla_vat] => 2160
                    [item_api_custom] => 
                )

        )

    [offer_tags] => Array
        (
            [0] => Tag 1
            [1] => Tag 2
        )

)

List of quotes

A session must be initialized before this call (see above). The following URLs return lists of quotes.
All quotes created in the period:
https://www.fakturyweb.cz/api/cn-list/created?data={JSON}
All quotes with an issue date in the period:
https://www.fakturyweb.cz/api/cn-list/issued?data={JSON}
Basic parameters:
Parameter Attribute Description
key required parameter API key.
email required parameter E-mail (or username) you use to log in to Fakturyweb.
from optional parameter Search date 'From'
Format: YYYY-MM-DD
to optional parameter Search date 'To'
Format: YYYY-MM-DD
Data format before sending:
Array
(
    [key] => vJyMc*4@2754*wGhofIWi!QDcEEQUdmj
    [email] => name@example.com
    [from] => 2022-01-01
    [to] => 2022-01-31
)


List of return codes:
Status ID Meaning Description
1 OK Everything went fine
902 Error The data parameter was not sent via the GET method.
903 Error The API key is missing or has an invalid number of characters.
904 Error The API key is not entered correctly.
905 Error The email parameter is missing.
906 Error No session has been initialized
907 Error The initialized session is not valid
908 Error The username or the API key is not correct.
909 Error The user does not exist.
910 Error Invalid URL.
911 Error The 'From' date is not entered correctly.
912 Error The 'To' date is not entered correctly.
913 Error The requested list could not be identified, probably an error in the URL.
Sample source code:
<?php

// Příprava základních dat:
$data = [];

// Váš API klíč:
$data['key'] = "dJyMc*53@687*wGhofIWi!WDcEEQUdmj";

// Váš email (příp. uživatelské jméno):
$data['email'] = "name@example.com";

// Data se uloží do formátu JSON:
$data_json = json_encode($data);

// Inicializace sezení
$url = 'https://www.fakturyweb.cz/api/init?data=' . urlencode($data_json);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$output = curl_exec($ch);


// Výsledek:
$result = json_decode($output, true);
if ($result['status'] != 1) {
    throw new Exception("Vyskytla se chyba č. " . $result['status']);
}


// Data v kalendářním roce 2022
$data['from'] = '2022-01-01';
$data['to'] = '2022-12-31';
// Data se uloží do formátu JSON:
$data_json = json_encode($data);


// Data se odešlou:
$url = 'https://www.fakturyweb.cz/api/cn-list/issued?data=' . urlencode($data_json);
curl_setopt($ch, CURLOPT_URL, $url);
$output = curl_exec($ch);



// Výsledek:
$result = json_decode($output, true);
if ($result['status'] == 1) {
    $cenovePonuky = $result['offers'];
    foreach ($cenovePonuky as $cenovaPonuka) {
        echo "Kód: {$cenovaPonuka['code']} \n";
        echo "Dodavatel: {$cenovaPonuka['supplier']} \n";
        echo "Dodavatel IČO: {$cenovaPonuka['supplier_ico']} \n";
        echo "Odběratel / Zákazník: {$cenovaPonuka['customer']} \n";
        echo "Odběratel / Zákazník IČO: {$cenovaPonuka['customer_ico']} \n";
        echo "Číslo cenové nabídky: {$cenovaPonuka['offer_number']} \n";
        echo "Částka bez DPH: {$cenovaPonuka['offer_amount']} \n";
        if (isset($cenovaPonuka['offer_amount_vat'])) {
            echo "Částka s DPH: {$cenovaPonuka['offer_amount_vat']} \n";
        }
        echo "Měna: {$cenovaPonuka['offer_currency']} \n";
        echo "Datum vystavení: {$cenovaPonuka['offer_date_issue']} \n";
        echo "Datum platnosti: {$cenovaPonuka['offer_date_expiration']} \n";
        echo "Vlastní data z API: {$cenovaPonuka['offer_api_custom']} \n";
        echo "Tagy cenové nabídky: {$cenovaPonuka['tags']} \n";
    }
} else {
    echo "Vyskytla se chyba č." . $result['status'];
}



Response:
Array
(
    [status] => 1
    [offers] => Array
        (
            [0] => Array
                (
                    [code] => ae47ece062b0021144d768446b071fee
                    [supplier] => Moje společnost, s.r.o.
                    [supplier_ico] => 60991234
                    [customer] => Petr Novák
                    [customer_ico] => 40436097
                    [offer_number] => 20220123
                    [offer_amount] => 2000
                    [offer_amount_vat] => 2420
                    [offer_currency] => CZK
                    [offer_date_issue] => 2022-01-10
                    [offer_date_expiration] => 2022-01-25
                    [offer_api_custom] => data z API
                    [tags] => Tag1 ,Tag2
                )

        )

)