{
  "openapi": "3.1.0",
  "info": {
    "title": "MyTempo API",
    "version": "1.0.0-navrh",
    "description": "NÁVRH – API zatím neběží. Česká účetní aplikace MyTempo: čtení a koncepty dokladů."
  },
  "servers": [
    {
      "url": "https://api.mytempo.cz/v1"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "tags": [
    {
      "name": "Identita",
      "description": "Kdo volá a co token smí. První volání každé integrace."
    },
    {
      "name": "Firmy a období",
      "description": "Firmy, ke kterým má token přístup, jejich údaje a účetní období."
    },
    {
      "name": "Číselníky",
      "description": "Kódy DPH, měny, způsoby platby, osnova, položky daňové evidence, dimenze a kurzy ČNB."
    },
    {
      "name": "Adresář",
      "description": "Partneři firmy – odběratelé a dodavatelé, jejich bankovní účty a údaje z ARES."
    },
    {
      "name": "Doklady",
      "description": "Faktury, zálohové listy, interní a pokladní doklady. Přes API jen čtení a koncepty."
    },
    {
      "name": "Přílohy a poznámky",
      "description": "Soubory a poznámky u dokladů."
    },
    {
      "name": "Saldo a peníze",
      "description": "Neuhrazené pohledávky a závazky a zůstatky peněz napříč firmami."
    },
    {
      "name": "Banka",
      "description": "Bankovní účty, výpisy, pohyby a import výpisu ze souboru."
    },
    {
      "name": "Účetnictví a výkazy",
      "description": "Deník, obraty účtů, rozvaha, výsledovka a přehled DPH – jen čtení."
    },
    {
      "name": "Pošta",
      "description": "Přijatá a odeslaná pošta."
    },
    {
      "name": "Vytěžování",
      "description": "Nahrání dokladu k vytěžení a stav úlohy."
    },
    {
      "name": "Události",
      "description": "Kanál změn a webhooky."
    }
  ],
  "paths": {
    "/me": {
      "get": {
        "operationId": "me",
        "summary": "Kdo jsem",
        "description": "Vrátí uživatele, organizaci a rozsah tokenu (firmy, práva, platnost). Použijte jako první volání každé integrace a pro ověření, že token platí.",
        "tags": [
          "Identita"
        ],
        "x-tempo-phase": "Beta",
        "x-tempo-scope": "libovolný",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "user": {
                    "id": "5b1c…",
                    "name": "Jana Nováková"
                  },
                  "organization": {
                    "id": "a3f0…",
                    "name": "Účetní kancelář Vzor"
                  },
                  "token": {
                    "name": "Zkouška API",
                    "scopes": [
                      "read"
                    ],
                    "companies": [
                      "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
                    ],
                    "expires_at": "2026-11-18"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          }
        }
      }
    },
    "/companies": {
      "get": {
        "operationId": "companies-list",
        "summary": "Seznam firem",
        "description": "Firmy, ke kterým má token přístup (průnik oprávnění uživatele a rozsahu tokenu).",
        "tags": [
          "Firmy a období"
        ],
        "x-tempo-phase": "Beta",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Počet záznamů na stránku, 1–500.",
            "schema": {
              "type": "integer",
              "default": "100"
            },
            "example": "100"
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Hodnota `next_cursor` z předchozí odpovědi.",
            "schema": {
              "type": "string"
            },
            "example": "eyJpZCI6Ijk…"
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "data": [
                    {
                      "id": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04",
                      "name": "Vzor s.r.o.",
                      "ico": "12345678",
                      "dic": "CZ12345678",
                      "organization_id": "a3f0b1c2-…",
                      "method": "accounting",
                      "vat_payer": true,
                      "vat_period": "month",
                      "currency": "CZK"
                    }
                  ],
                  "next_cursor": "eyJpZCI6Ijk…"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/companies/{company_id}": {
      "get": {
        "operationId": "companies-get",
        "summary": "Detail firmy",
        "description": "Údaje firmy včetně metody vedení, plátcovství DPH a měny účetnictví.",
        "tags": [
          "Firmy a období"
        ],
        "x-tempo-phase": "Beta",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "id": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04",
                  "name": "Vzor s.r.o.",
                  "ico": "12345678",
                  "dic": "CZ12345678",
                  "organization_id": "a3f0b1c2-…",
                  "method": "accounting",
                  "vat_payer": true,
                  "vat_period": "month",
                  "currency": "CZK"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          }
        }
      }
    },
    "/companies/{company_id}/periods": {
      "get": {
        "operationId": "periods-list",
        "summary": "Účetní období",
        "description": "Období firmy seřazená od nejnovějšího se stavem (otevřené / uzavřené / uzamčené).",
        "tags": [
          "Firmy a období"
        ],
        "x-tempo-phase": "Beta",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "data": [
                    {
                      "id": "p26…",
                      "name": "2026",
                      "date_from": "2026-01-01",
                      "date_to": "2026-12-31",
                      "status": "open"
                    }
                  ],
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/companies/{company_id}/vat-codes": {
      "get": {
        "operationId": "vat-codes",
        "summary": "Kódy DPH",
        "description": "Kódy DPH firmy platné k datu, se sazbou a řádkem přiznání / oddílem KH.",
        "tags": [
          "Číselníky"
        ],
        "x-tempo-phase": "Beta",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "date",
            "in": "query",
            "required": false,
            "description": "Platnost k datu; výchozí dnes.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "data": [
                    {
                      "code": "21",
                      "name": "Tuzemsko 21 %",
                      "rate": "21",
                      "direction": "output",
                      "vat_return_line": "1",
                      "kh_section": "A.4/A.5"
                    }
                  ],
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/companies/{company_id}/currencies": {
      "get": {
        "operationId": "currencies",
        "summary": "Měny",
        "description": "Měny používané ve firmě.",
        "tags": [
          "Číselníky"
        ],
        "x-tempo-phase": "Beta",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "data": [
                    {
                      "code": "CZK",
                      "name": "Česká koruna",
                      "decimals": 2
                    },
                    {
                      "code": "EUR",
                      "name": "Euro",
                      "decimals": 2
                    }
                  ],
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/companies/{company_id}/payment-methods": {
      "get": {
        "operationId": "payment-methods",
        "summary": "Způsoby platby",
        "description": "Způsoby platby firmy.",
        "tags": [
          "Číselníky"
        ],
        "x-tempo-phase": "Beta",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "data": [
                    {
                      "code": "PREVOD",
                      "name": "Převodem",
                      "active": true
                    }
                  ],
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/companies/{company_id}/accounts": {
      "get": {
        "operationId": "accounts",
        "summary": "Účtová osnova",
        "description": "Účty období (jen firmy s účetnictvím). Účty se vždy zobrazují jako „číslo – název“.",
        "tags": [
          "Číselníky"
        ],
        "x-tempo-phase": "Beta",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "period_id",
            "in": "query",
            "required": false,
            "description": "Účetní období; bez zadání aktuální období podle dnešního data.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "active",
            "in": "query",
            "required": false,
            "description": "Jen aktivní účty.",
            "schema": {
              "type": "boolean",
              "default": "true"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "data": [
                    {
                      "number": "311000",
                      "name": "Odběratelé",
                      "kind": "receivables",
                      "active": true
                    }
                  ],
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/companies/{company_id}/tax-categories": {
      "get": {
        "operationId": "tax-categories",
        "summary": "Položky daňové evidence",
        "description": "Položky období (jen firmy s daňovou evidencí); technické položky se nevrací.",
        "tags": [
          "Číselníky"
        ],
        "x-tempo-phase": "Beta",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "period_id",
            "in": "query",
            "required": false,
            "description": "Účetní období; bez zadání aktuální období podle dnešního data.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "data": [
                    {
                      "code": "P01",
                      "name": "Příjmy z prodeje služeb",
                      "kind": "income"
                    }
                  ],
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/companies/{company_id}/dimensions": {
      "get": {
        "operationId": "dimensions",
        "summary": "Dimenze",
        "description": "Typy dimenzí (středisko, zakázka, vozidlo…) a jejich hodnoty.",
        "tags": [
          "Číselníky"
        ],
        "x-tempo-phase": "Beta",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "data": [
                    {
                      "type": "STR",
                      "name": "Středisko",
                      "values": [
                        {
                          "code": "01",
                          "name": "Praha"
                        }
                      ]
                    }
                  ],
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/exchange-rates": {
      "get": {
        "operationId": "exchange-rates",
        "summary": "Kurzy ČNB",
        "description": "Kurzovní lístek ČNB k datu (platí poslední vyhlášený kurz).",
        "tags": [
          "Číselníky"
        ],
        "x-tempo-phase": "Beta",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "date",
            "in": "query",
            "required": false,
            "description": "Datum; výchozí dnes.",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "example": "2026-11-11"
          },
          {
            "name": "currency",
            "in": "query",
            "required": false,
            "description": "Jen jedna měna (ISO 4217).",
            "schema": {
              "type": "string"
            },
            "example": "EUR"
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "date": "2026-11-11",
                  "rates": [
                    {
                      "currency": "EUR",
                      "amount": 1,
                      "rate": "24.315"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/companies/{company_id}/partners": {
      "get": {
        "operationId": "partners-list",
        "summary": "Seznam partnerů",
        "description": "Partneři z Adresáře firmy. Hledání podle názvu, IČO nebo e-mailu.",
        "tags": [
          "Adresář"
        ],
        "x-tempo-phase": "Beta",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Hledaný text (název, IČO, e-mail).",
            "schema": {
              "type": "string"
            },
            "example": "odběratel"
          },
          {
            "name": "ico",
            "in": "query",
            "required": false,
            "description": "Přesné IČO.",
            "schema": {
              "type": "string"
            },
            "example": "87654321"
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "description": "Jen záznamy změněné od zadaného času (pro pravidelnou synchronizaci).",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "example": "2026-11-01T00:00:00+01:00"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Počet záznamů na stránku, 1–500.",
            "schema": {
              "type": "integer",
              "default": "100"
            },
            "example": "100"
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Hodnota `next_cursor` z předchozí odpovědi.",
            "schema": {
              "type": "string"
            },
            "example": "eyJpZCI6Ijk…"
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "data": [
                    {
                      "id": "c0d4a7b2-1e3f-4a5b-8c9d-0e1f2a3b4c5d",
                      "kind": "company",
                      "name": "Odběratel a.s.",
                      "ico": "87654321",
                      "dic": "CZ87654321",
                      "address": {
                        "street": "Hlavní 12",
                        "city": "Brno",
                        "zip": "60200",
                        "country": "CZ"
                      },
                      "email": "fakturace@odberatel.example",
                      "bank_accounts": [
                        {
                          "account_number": "123456789",
                          "bank_code": "0100",
                          "iban": "CZ65 0100 0000 0001 2345 6789",
                          "currency": "CZK"
                        }
                      ],
                      "tags": [
                        "velkoodběr"
                      ],
                      "version": 3,
                      "updated_at": "2026-10-20T09:14:00+02:00"
                    }
                  ],
                  "next_cursor": "eyJpZCI6Ijk…"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "post": {
        "operationId": "partners-create",
        "summary": "Založit partnera",
        "description": "Založí partnera. Když zadáte jen IČO a `from_ares: true`, údaje se doplní z ARES. Partner se stejným IČO vrátí `409 partner_exists` s odkazem na existujícího.",
        "tags": [
          "Adresář"
        ],
        "x-tempo-phase": "Připravujeme",
        "x-tempo-scope": "partners:write",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Jedinečný klíč požadavku (UUID, číslo objednávky). Opakování se stejným klíčem nic nezaloží podruhé.",
            "schema": {
              "type": "string"
            },
            "example": "objednavka-2026-004512"
          }
        ],
        "responses": {
          "201": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "id": "c0d4a7b2-1e3f-4a5b-8c9d-0e1f2a3b4c5d",
                  "kind": "company",
                  "name": "Odběratel a.s.",
                  "ico": "87654321",
                  "dic": "CZ87654321",
                  "address": {
                    "street": "Hlavní 12",
                    "city": "Brno",
                    "zip": "60200",
                    "country": "CZ"
                  },
                  "email": "fakturace@odberatel.example",
                  "bank_accounts": [
                    {
                      "account_number": "123456789",
                      "bank_code": "0100",
                      "iban": "CZ65 0100 0000 0001 2345 6789",
                      "currency": "CZK"
                    }
                  ],
                  "tags": [
                    "velkoodběr"
                  ],
                  "version": 3,
                  "updated_at": "2026-10-20T09:14:00+02:00"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "kind"
                ],
                "properties": {
                  "kind": {
                    "type": "string",
                    "description": "`company` nebo `person`."
                  },
                  "name": {
                    "type": "string",
                    "description": "Název (u `from_ares` nepovinný)."
                  },
                  "ico": {
                    "type": "string",
                    "description": "IČO."
                  },
                  "from_ares": {
                    "type": "boolean",
                    "description": "Doplnit údaje z ARES."
                  },
                  "address": {
                    "type": "string",
                    "description": "Sídlo."
                  },
                  "email": {
                    "type": "string",
                    "description": "E-mail."
                  },
                  "bank_accounts": {
                    "type": "string",
                    "description": "Bankovní účty."
                  }
                }
              },
              "example": {
                "kind": "company",
                "ico": "87654321",
                "from_ares": true,
                "email": "fakturace@odberatel.example"
              }
            }
          }
        }
      }
    },
    "/companies/{company_id}/partners/{partner_id}": {
      "get": {
        "operationId": "partners-get",
        "summary": "Detail partnera",
        "description": "Partner včetně bankovních účtů a štítků. Odpověď nese `ETag` pro následnou úpravu.",
        "tags": [
          "Adresář"
        ],
        "x-tempo-phase": "Beta",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "partner_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor partnera.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "id": "c0d4a7b2-1e3f-4a5b-8c9d-0e1f2a3b4c5d",
                  "kind": "company",
                  "name": "Odběratel a.s.",
                  "ico": "87654321",
                  "dic": "CZ87654321",
                  "address": {
                    "street": "Hlavní 12",
                    "city": "Brno",
                    "zip": "60200",
                    "country": "CZ"
                  },
                  "email": "fakturace@odberatel.example",
                  "bank_accounts": [
                    {
                      "account_number": "123456789",
                      "bank_code": "0100",
                      "iban": "CZ65 0100 0000 0001 2345 6789",
                      "currency": "CZK"
                    }
                  ],
                  "tags": [
                    "velkoodběr"
                  ],
                  "version": 3,
                  "updated_at": "2026-10-20T09:14:00+02:00"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          }
        }
      },
      "patch": {
        "operationId": "partners-update",
        "summary": "Upravit partnera",
        "description": "Změní jen zaslaná pole. Vyžaduje `If-Match`; při souběžné změně vrátí `409 version_conflict`.",
        "tags": [
          "Adresář"
        ],
        "x-tempo-phase": "Připravujeme",
        "x-tempo-scope": "partners:write",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "partner_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor partnera.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": true,
            "description": "Hodnota `ETag` / `version` z posledního načtení záznamu.",
            "schema": {
              "type": "string"
            },
            "example": "\"7\""
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "id": "c0d4a7b2-1e3f-4a5b-8c9d-0e1f2a3b4c5d",
                  "kind": "company",
                  "name": "Odběratel a.s.",
                  "ico": "87654321",
                  "dic": "CZ87654321",
                  "address": {
                    "street": "Hlavní 12",
                    "city": "Brno",
                    "zip": "60200",
                    "country": "CZ"
                  },
                  "email": "fakturace@odberatel.example",
                  "bank_accounts": [
                    {
                      "account_number": "123456789",
                      "bank_code": "0100",
                      "iban": "CZ65 0100 0000 0001 2345 6789",
                      "currency": "CZK"
                    }
                  ],
                  "tags": [
                    "velkoodběr"
                  ],
                  "version": 4,
                  "updated_at": "2026-10-20T09:14:00+02:00"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [],
                "properties": {
                  "email": {
                    "type": "string",
                    "description": "E-mail."
                  },
                  "address": {
                    "type": "string",
                    "description": "Sídlo."
                  },
                  "tags": {
                    "type": "string",
                    "description": "Štítky."
                  }
                }
              },
              "example": {
                "email": "nova.fakturace@odberatel.example"
              }
            }
          }
        }
      }
    },
    "/ares/{ico}": {
      "get": {
        "operationId": "ares",
        "summary": "Údaje z ARES",
        "description": "Načte subjekt z ARES (název, sídlo, DIČ, právní forma). Nic neukládá.",
        "tags": [
          "Adresář"
        ],
        "x-tempo-phase": "Beta",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "ico",
            "in": "path",
            "required": true,
            "description": "IČO (8 číslic).",
            "schema": {
              "type": "string"
            },
            "example": "87654321"
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "ico": "87654321",
                  "name": "Odběratel a.s.",
                  "dic": "CZ87654321",
                  "legal_form": "121",
                  "kind": "company",
                  "address": {
                    "street": "Hlavní 12",
                    "city": "Brno",
                    "zip": "60200",
                    "country": "CZ"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/companies/{company_id}/documents": {
      "get": {
        "operationId": "documents-list",
        "summary": "Seznam dokladů",
        "description": "Doklady firmy napříč obdobími, seřazené od nejnovějšího. Seznam neobsahuje řádky – ty vrací detail.",
        "tags": [
          "Doklady"
        ],
        "x-tempo-phase": "Beta",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "document_type",
            "in": "query",
            "required": false,
            "description": "Druh dokladu, více hodnot čárkou.",
            "schema": {
              "type": "string"
            },
            "example": "FV,ZFV"
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "`draft`, `registered`, `booked`, `locked`, `cancelled`; více čárkou.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "book",
            "in": "query",
            "required": false,
            "description": "Kód knihy.",
            "schema": {
              "type": "string"
            },
            "example": "FV"
          },
          {
            "name": "date_from",
            "in": "query",
            "required": false,
            "description": "Datum účetního případu od.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "required": false,
            "description": "Datum účetního případu do.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "partner_id",
            "in": "query",
            "required": false,
            "description": "Partner.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "variable_symbol",
            "in": "query",
            "required": false,
            "description": "Variabilní symbol (přesná shoda).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Hledání v čísle, popisu a partnerovi.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "description": "Jen záznamy změněné od zadaného času (pro pravidelnou synchronizaci).",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "example": "2026-11-01T00:00:00+01:00"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Počet záznamů na stránku, 1–500.",
            "schema": {
              "type": "integer",
              "default": "100"
            },
            "example": "100"
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Hodnota `next_cursor` z předchozí odpovědi.",
            "schema": {
              "type": "string"
            },
            "example": "eyJpZCI6Ijk…"
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "data": [
                    {
                      "id": "e71a3b2c-4d5e-4f60-8a7b-9c0d1e2f3a4b",
                      "document_type": "FV",
                      "status": "registered",
                      "number": "FV2026-0142",
                      "book": {
                        "id": "b1…",
                        "code": "FV",
                        "name": "Vydané faktury"
                      },
                      "partner": {
                        "id": "c0d4a7b2-1e3f-4a5b-8c9d-0e1f2a3b4c5d",
                        "name": "Odběratel a.s.",
                        "ico": "87654321"
                      },
                      "issue_date": "2026-10-17",
                      "accounting_date": "2026-10-17",
                      "taxable_supply_date": "2026-10-17",
                      "due_date": "2026-10-31",
                      "variable_symbol": "20260142",
                      "currency": "CZK",
                      "exchange_rate": null,
                      "amount_base": "10000.00",
                      "amount_vat": "2100.00",
                      "amount_total": "12100.00",
                      "remaining": "12100.00",
                      "source": "app",
                      "version": 5,
                      "updated_at": "2026-10-17T10:02:11+02:00",
                      "app_url": "https://app.mytempo.cz/doklady/e71a3b2c-4d5e-4f60-8a7b-9c0d1e2f3a4b"
                    }
                  ],
                  "next_cursor": "eyJpZCI6Ijk…"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "post": {
        "operationId": "documents-create",
        "summary": "Založit koncept dokladu",
        "description": "Založí **koncept** dokladu (FV, FP, ZFV, ZFP, ID, PO). Koncept nemá číslo, nikde se nepočítá a zařadí ho člověk v aplikaci. Platí stejné kontroly a práva ke knize jako v aplikaci; odpověď obsahuje odkaz na koncept.",
        "tags": [
          "Doklady"
        ],
        "x-tempo-phase": "Připravujeme",
        "x-tempo-scope": "documents:write",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Jedinečný klíč požadavku (UUID, číslo objednávky). Opakování se stejným klíčem nic nezaloží podruhé.",
            "schema": {
              "type": "string"
            },
            "example": "objednavka-2026-004512"
          }
        ],
        "responses": {
          "201": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "id": "e71a3b2c-4d5e-4f60-8a7b-9c0d1e2f3a4b",
                  "document_type": "FV",
                  "status": "draft",
                  "number": null,
                  "amount_total": "3630.00",
                  "source": "api",
                  "version": 1,
                  "app_url": "https://app.mytempo.cz/doklady/e71a3b2c-4d5e-4f60-8a7b-9c0d1e2f3a4b"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "document_type",
                  "lines"
                ],
                "properties": {
                  "document_type": {
                    "type": "string",
                    "description": "`FV`, `FP`, `ZFV`, `ZFP`, `ID` nebo `PO`."
                  },
                  "book_code": {
                    "type": "string",
                    "description": "Kód knihy; bez zadání výchozí kniha druhu."
                  },
                  "partner_id": {
                    "type": "string",
                    "description": "Partner z Adresáře (u FV / FP povinný při zařazení)."
                  },
                  "issue_date": {
                    "type": "string",
                    "description": "Datum vystavení; výchozí dnes."
                  },
                  "due_date": {
                    "type": "string",
                    "description": "Splatnost; výchozí podle partnera / firmy."
                  },
                  "taxable_supply_date": {
                    "type": "string",
                    "description": "DUZP."
                  },
                  "variable_symbol": {
                    "type": "string",
                    "description": "VS; bez zadání se doplní z čísla při zařazení."
                  },
                  "supplier_number": {
                    "type": "string",
                    "description": "Číslo dokladu dodavatele (FP, ZFP)."
                  },
                  "currency": {
                    "type": "string",
                    "description": "Měna; výchozí měna firmy."
                  },
                  "note": {
                    "type": "string",
                    "description": "Poznámka k dokladu."
                  },
                  "lines": {
                    "type": "string",
                    "description": "Řádky: `description`, `quantity`, `unit`, `unit_price`, `vat_code`, `dimensions`."
                  }
                }
              },
              "example": {
                "document_type": "FV",
                "book_code": "FV",
                "partner_id": "c0d4a7b2-1e3f-4a5b-8c9d-0e1f2a3b4c5d",
                "issue_date": "2026-11-11",
                "due_date": "2026-11-25",
                "variable_symbol": "2026004512",
                "currency": "CZK",
                "note": "Objednávka e-shopu 004512",
                "lines": [
                  {
                    "description": "Konzultace",
                    "quantity": "2",
                    "unit": "hod",
                    "unit_price": "1500.00",
                    "vat_code": "21"
                  }
                ]
              }
            }
          }
        }
      }
    },
    "/companies/{company_id}/documents/{document_id}": {
      "get": {
        "operationId": "documents-get",
        "summary": "Detail dokladu",
        "description": "Hlavička, řádky, rekapitulace DPH a zaúčtování (účty jen ke čtení). Odpověď nese `ETag`.",
        "tags": [
          "Doklady"
        ],
        "x-tempo-phase": "Beta",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "document_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor dokladu.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "id": "e71a3b2c-4d5e-4f60-8a7b-9c0d1e2f3a4b",
                  "document_type": "FV",
                  "status": "registered",
                  "number": "FV2026-0142",
                  "book": {
                    "id": "b1…",
                    "code": "FV",
                    "name": "Vydané faktury"
                  },
                  "partner": {
                    "id": "c0d4a7b2-1e3f-4a5b-8c9d-0e1f2a3b4c5d",
                    "name": "Odběratel a.s.",
                    "ico": "87654321"
                  },
                  "issue_date": "2026-10-17",
                  "accounting_date": "2026-10-17",
                  "taxable_supply_date": "2026-10-17",
                  "due_date": "2026-10-31",
                  "variable_symbol": "20260142",
                  "currency": "CZK",
                  "exchange_rate": null,
                  "amount_base": "10000.00",
                  "amount_vat": "2100.00",
                  "amount_total": "12100.00",
                  "remaining": "12100.00",
                  "source": "app",
                  "version": 5,
                  "updated_at": "2026-10-17T10:02:11+02:00",
                  "app_url": "https://app.mytempo.cz/doklady/e71a3b2c-4d5e-4f60-8a7b-9c0d1e2f3a4b",
                  "lines": [
                    {
                      "id": "l1…",
                      "description": "Vedení účetnictví 10/2026",
                      "quantity": "1",
                      "unit": "měs.",
                      "unit_price": "10000.00",
                      "vat_code": "21",
                      "vat_rate": "21",
                      "amount_base": "10000.00",
                      "amount_vat": "2100.00",
                      "account": "602100",
                      "tax_category": null,
                      "dimensions": {
                        "STR": "01"
                      }
                    }
                  ],
                  "vat_summary": [
                    {
                      "vat_rate": "21",
                      "base": "10000.00",
                      "vat": "2100.00"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          }
        }
      },
      "patch": {
        "operationId": "documents-update",
        "summary": "Upravit koncept",
        "description": "Změní koncept, který vznikl přes API nebo je ještě nezařazený. Zařazený doklad vrátí `409 document_not_draft`.",
        "tags": [
          "Doklady"
        ],
        "x-tempo-phase": "Připravujeme",
        "x-tempo-scope": "documents:write",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "document_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor dokladu.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": true,
            "description": "Hodnota `ETag` / `version` z posledního načtení záznamu.",
            "schema": {
              "type": "string"
            },
            "example": "\"7\""
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "id": "e71a3b2c-4d5e-4f60-8a7b-9c0d1e2f3a4b",
                  "document_type": "FV",
                  "status": "draft",
                  "number": null,
                  "amount_total": "3630.00",
                  "source": "api",
                  "version": 2,
                  "app_url": "https://app.mytempo.cz/doklady/e71a3b2c-4d5e-4f60-8a7b-9c0d1e2f3a4b"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [],
                "properties": {
                  "due_date": {
                    "type": "string",
                    "description": "Splatnost."
                  },
                  "note": {
                    "type": "string",
                    "description": "Poznámka."
                  },
                  "lines": {
                    "type": "string",
                    "description": "Řádky – nahradí všechny řádky."
                  }
                }
              },
              "example": {
                "due_date": "2026-11-30"
              }
            }
          }
        }
      }
    },
    "/companies/{company_id}/documents/{document_id}/pdf": {
      "get": {
        "operationId": "documents-pdf",
        "summary": "PDF vydané faktury",
        "description": "Tisk vydané faktury, zálohového listu nebo daňového dokladu k platbě ve formátu PDF (stejný jako v aplikaci).",
        "tags": [
          "Doklady"
        ],
        "x-tempo-phase": "Beta",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "document_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor dokladu.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "PDF",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          }
        }
      }
    },
    "/companies/{company_id}/documents/{document_id}/attachments": {
      "get": {
        "operationId": "attachments-list",
        "summary": "Přílohy dokladu",
        "description": "Seznam příloh s krátkodobou adresou ke stažení (platí 5 minut).",
        "tags": [
          "Přílohy a poznámky"
        ],
        "x-tempo-phase": "Beta",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "document_id",
            "in": "path",
            "required": true,
            "description": "Doklad.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "data": [
                    {
                      "id": "a1…",
                      "file_name": "faktura.pdf",
                      "mime_type": "application/pdf",
                      "size": 84211,
                      "download_url": "https://api.mytempo.cz/v1/files/…",
                      "download_expires_at": "2026-11-11T10:05:00+01:00"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          }
        }
      },
      "post": {
        "operationId": "attachments-create",
        "summary": "Přidat přílohu",
        "description": "Nahraje soubor k dokladu (`multipart/form-data`, nejvýš 20 MB). Platí pravidla panelu dokladu (koncept / zařazený / zaúčtovaný).",
        "tags": [
          "Přílohy a poznámky"
        ],
        "x-tempo-phase": "Připravujeme",
        "x-tempo-scope": "documents:write",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "document_id",
            "in": "path",
            "required": true,
            "description": "Doklad.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Jedinečný klíč požadavku (UUID, číslo objednávky). Opakování se stejným klíčem nic nezaloží podruhé.",
            "schema": {
              "type": "string"
            },
            "example": "objednavka-2026-004512"
          }
        ],
        "responses": {
          "201": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "id": "a2…",
                  "file_name": "objednavka.pdf",
                  "size": 51200
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "413": {
            "$ref": "#/components/responses/E413"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "description": "Soubor (PDF, ISDOC, obrázek…)."
                  },
                  "description": {
                    "type": "string",
                    "description": "Popis přílohy."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/companies/{company_id}/documents/{document_id}/notes": {
      "post": {
        "operationId": "notes-create",
        "summary": "Přidat poznámku",
        "description": "Přidá poznámku do panelu dokladu.",
        "tags": [
          "Přílohy a poznámky"
        ],
        "x-tempo-phase": "Připravujeme",
        "x-tempo-scope": "documents:write",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "document_id",
            "in": "path",
            "required": true,
            "description": "Doklad.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Jedinečný klíč požadavku (UUID, číslo objednávky). Opakování se stejným klíčem nic nezaloží podruhé.",
            "schema": {
              "type": "string"
            },
            "example": "objednavka-2026-004512"
          }
        ],
        "responses": {
          "201": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "id": "n1…",
                  "text": "Zákazník žádá splatnost 30 dní.",
                  "created_at": "2026-11-11T10:00:00+01:00"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "text"
                ],
                "properties": {
                  "text": {
                    "type": "string",
                    "description": "Text poznámky (nejvýš 4 000 znaků)."
                  }
                }
              },
              "example": {
                "text": "Zákazník žádá splatnost 30 dní."
              }
            }
          }
        }
      }
    },
    "/companies/{company_id}/open-items": {
      "get": {
        "operationId": "open-items",
        "summary": "Neuhrazené pohledávky a závazky",
        "description": "Otevřené položky salda – faktury a zálohové listy, které nejsou plně uhrazené, k datu.",
        "tags": [
          "Saldo a peníze"
        ],
        "x-tempo-phase": "Beta",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "side",
            "in": "query",
            "required": true,
            "description": "`receivable` (pohledávky) nebo `payable` (závazky).",
            "schema": {
              "type": "string"
            },
            "example": "receivable"
          },
          {
            "name": "overdue",
            "in": "query",
            "required": false,
            "description": "Jen po splatnosti.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "as_of",
            "in": "query",
            "required": false,
            "description": "Stav k datu; výchozí dnes.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "partner_id",
            "in": "query",
            "required": false,
            "description": "Jen jeden partner.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Počet záznamů na stránku, 1–500.",
            "schema": {
              "type": "integer",
              "default": "100"
            },
            "example": "100"
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Hodnota `next_cursor` z předchozí odpovědi.",
            "schema": {
              "type": "string"
            },
            "example": "eyJpZCI6Ijk…"
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "data": [
                    {
                      "document_id": "e71a3b2c-4d5e-4f60-8a7b-9c0d1e2f3a4b",
                      "document_type": "FV",
                      "number": "FV2026-0142",
                      "partner": {
                        "id": "c0d4a7b2-1e3f-4a5b-8c9d-0e1f2a3b4c5d",
                        "name": "Odběratel a.s."
                      },
                      "variable_symbol": "20260142",
                      "due_date": "2026-10-31",
                      "days_overdue": 11,
                      "currency": "CZK",
                      "amount": "12100.00",
                      "remaining": "12100.00"
                    }
                  ],
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/cash-balances": {
      "get": {
        "operationId": "cash-balances",
        "summary": "Zůstatky peněz napříč firmami",
        "description": "Zůstatky pokladen a bankovních účtů všech firem v rozsahu tokenu k datu a součet přepočtený na CZK kurzem ČNB.",
        "tags": [
          "Saldo a peníze"
        ],
        "x-tempo-phase": "Beta",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "date",
            "in": "query",
            "required": false,
            "description": "Datum; výchozí dnes.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "company_id",
            "in": "query",
            "required": false,
            "description": "Jen vybrané firmy (parametr lze opakovat).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "date": "2026-11-11",
                  "total_czk": "1284530.20",
                  "items": [
                    {
                      "company_id": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04",
                      "company": "Vzor s.r.o.",
                      "kind": "bank",
                      "name": "Fio – běžný",
                      "currency": "CZK",
                      "balance": "842100.50",
                      "balance_czk": "842100.50"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/companies/{company_id}/bank-accounts": {
      "get": {
        "operationId": "bank-accounts",
        "summary": "Bankovní účty firmy",
        "description": "Bankovní účty (knihy banky) firmy a stav napojení na banku.",
        "tags": [
          "Banka"
        ],
        "x-tempo-phase": "Beta",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "data": [
                    {
                      "id": "ba1…",
                      "name": "Fio – běžný",
                      "account_number": "2900123456/2010",
                      "currency": "CZK",
                      "connection": "fio_api",
                      "last_statement_date": "2026-11-10"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/companies/{company_id}/bank-statements": {
      "get": {
        "operationId": "bank-statements",
        "summary": "Bankovní výpisy",
        "description": "Výpisy s počátečním a konečným zůstatkem.",
        "tags": [
          "Banka"
        ],
        "x-tempo-phase": "Beta",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "bank_account_id",
            "in": "query",
            "required": false,
            "description": "Bankovní účet.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "date_from",
            "in": "query",
            "required": false,
            "description": "Od data.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "required": false,
            "description": "Do data.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Počet záznamů na stránku, 1–500.",
            "schema": {
              "type": "integer",
              "default": "100"
            },
            "example": "100"
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Hodnota `next_cursor` z předchozí odpovědi.",
            "schema": {
              "type": "string"
            },
            "example": "eyJpZCI6Ijk…"
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "data": [
                    {
                      "id": "bs1…",
                      "bank_account_id": "ba1…",
                      "number": "2026/215",
                      "date_from": "2026-11-10",
                      "date_to": "2026-11-10",
                      "opening_balance": "830000.00",
                      "closing_balance": "842100.50",
                      "movements": 4
                    }
                  ],
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/companies/{company_id}/bank-movements": {
      "get": {
        "operationId": "bank-movements",
        "summary": "Pohyby na účtu",
        "description": "Pohyby bankovních účtů. Filtr `matched=false` vrátí pohyby, které ještě nejsou spárované.",
        "tags": [
          "Banka"
        ],
        "x-tempo-phase": "Beta",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "bank_account_id",
            "in": "query",
            "required": false,
            "description": "Bankovní účet.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "matched",
            "in": "query",
            "required": false,
            "description": "Jen spárované / nespárované.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "date_from",
            "in": "query",
            "required": false,
            "description": "Od data.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "required": false,
            "description": "Do data.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Počet záznamů na stránku, 1–500.",
            "schema": {
              "type": "integer",
              "default": "100"
            },
            "example": "100"
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Hodnota `next_cursor` z předchozí odpovědi.",
            "schema": {
              "type": "string"
            },
            "example": "eyJpZCI6Ijk…"
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "data": [
                    {
                      "id": "bm1…",
                      "bank_account_id": "ba1…",
                      "date": "2026-11-10",
                      "amount": "12100.00",
                      "currency": "CZK",
                      "counter_account": "123456789/0100",
                      "variable_symbol": "20260142",
                      "message": "FV2026-0142",
                      "matched": false,
                      "document_id": null
                    }
                  ],
                  "next_cursor": "eyJpZCI6Ijk…"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/companies/{company_id}/bank-statements/import": {
      "post": {
        "operationId": "bank-import",
        "summary": "Import výpisu ze souboru",
        "description": "Nahraje výpis ve formátu GPC (ABO) nebo camt.053 (XML). Překrývající se výpis TEMPO odmítne; párování dělá člověk v aplikaci.",
        "tags": [
          "Banka"
        ],
        "x-tempo-phase": "Připravujeme",
        "x-tempo-scope": "bank:import",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Jedinečný klíč požadavku (UUID, číslo objednávky). Opakování se stejným klíčem nic nezaloží podruhé.",
            "schema": {
              "type": "string"
            },
            "example": "objednavka-2026-004512"
          }
        ],
        "responses": {
          "201": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "batch_id": "ib1…",
                  "statements": 1,
                  "movements": 4,
                  "duplicates_skipped": 0
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "413": {
            "$ref": "#/components/responses/E413"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "bank_account_id",
                  "file"
                ],
                "properties": {
                  "bank_account_id": {
                    "type": "string",
                    "description": "Bankovní účet."
                  },
                  "file": {
                    "type": "string",
                    "description": "Soubor výpisu (nejvýš 20 MB)."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/companies/{company_id}/journal": {
      "get": {
        "operationId": "journal",
        "summary": "Účetní deník",
        "description": "Řádky deníku za období (jen firmy s účetnictvím).",
        "tags": [
          "Účetnictví a výkazy"
        ],
        "x-tempo-phase": "Verze 1",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "period_id",
            "in": "query",
            "required": true,
            "description": "Účetní období; bez zadání aktuální období podle dnešního data.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "account",
            "in": "query",
            "required": false,
            "description": "Jen účet (i syntetika, např. `311`).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "date_from",
            "in": "query",
            "required": false,
            "description": "Od data.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "required": false,
            "description": "Do data.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Počet záznamů na stránku, 1–500.",
            "schema": {
              "type": "integer",
              "default": "100"
            },
            "example": "100"
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Hodnota `next_cursor` z předchozí odpovědi.",
            "schema": {
              "type": "string"
            },
            "example": "eyJpZCI6Ijk…"
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "data": [
                    {
                      "date": "2026-10-17",
                      "document_id": "e71a3b2c-4d5e-4f60-8a7b-9c0d1e2f3a4b",
                      "document_number": "FV2026-0142",
                      "description": "Vedení účetnictví 10/2026",
                      "account_debit": "311000",
                      "account_credit": "602100",
                      "amount": "10000.00"
                    }
                  ],
                  "next_cursor": "eyJpZCI6Ijk…"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/companies/{company_id}/account-balances": {
      "get": {
        "operationId": "account-balances",
        "summary": "Obraty a zůstatky účtů",
        "description": "Počáteční stav, obraty MD / DAL a konečný zůstatek účtů za období (u daňové evidence položky).",
        "tags": [
          "Účetnictví a výkazy"
        ],
        "x-tempo-phase": "Verze 1",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "period_id",
            "in": "query",
            "required": true,
            "description": "Účetní období; bez zadání aktuální období podle dnešního data.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "required": false,
            "description": "Zůstatky k datu uvnitř období.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "data": [
                    {
                      "account": "221001",
                      "name": "Fio – běžný",
                      "opening": "512000.00",
                      "debit": "1420000.00",
                      "credit": "1089899.50",
                      "closing": "842100.50"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/companies/{company_id}/reports/{report}": {
      "get": {
        "operationId": "reports",
        "summary": "Rozvaha a výsledovka",
        "description": "Výkaz podle šablony firmy. Těžká sestava – má vlastní nižší limit (30 za hodinu).",
        "tags": [
          "Účetnictví a výkazy"
        ],
        "x-tempo-phase": "Verze 1",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "report",
            "in": "path",
            "required": true,
            "description": "`balance-sheet` (rozvaha) nebo `profit-and-loss` (výsledovka).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "period_id",
            "in": "query",
            "required": false,
            "description": "Účetní období; bez zadání aktuální období podle dnešního data.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "required": false,
            "description": "Výkaz k datu.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "compare_period_id",
            "in": "query",
            "required": false,
            "description": "Srovnávací období (sloupec minulé období).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "description": "`full` (plný) nebo `short` (zkrácený).",
            "schema": {
              "type": "string",
              "default": "short"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "report": "profit-and-loss",
                  "date_to": "2026-09-30",
                  "rows": [
                    {
                      "line": "I.",
                      "name": "Tržby z prodeje výrobků a služeb",
                      "current": "1250000.00",
                      "previous": "1104000.00"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/companies/{company_id}/vat-summary": {
      "get": {
        "operationId": "vat-summary",
        "summary": "Přehled DPH a KH",
        "description": "Řádky přiznání k DPH a oddíly kontrolního hlášení za měsíc nebo čtvrtletí. Jen čtení – podání a XML jen v aplikaci.",
        "tags": [
          "Účetnictví a výkazy"
        ],
        "x-tempo-phase": "Verze 1",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "period",
            "in": "query",
            "required": true,
            "description": "Měsíc `YYYY-MM` nebo čtvrtletí `YYYY-Qn`.",
            "schema": {
              "type": "string"
            },
            "example": "2026-10"
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "period": "2026-10",
                  "lines": [
                    {
                      "line": "1",
                      "base": "250000.00",
                      "vat": "52500.00"
                    }
                  ],
                  "kh": [
                    {
                      "section": "A.4",
                      "documents": 12
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          }
        }
      }
    },
    "/companies/{company_id}/mail-items": {
      "get": {
        "operationId": "mail-list",
        "summary": "Seznam zásilek",
        "description": "Přijatá a odeslaná pošta firmy. Osobní zásilky vidí jen přidělený uživatel, vlastník a správce.",
        "tags": [
          "Pošta"
        ],
        "x-tempo-phase": "Verze 1",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "direction",
            "in": "query",
            "required": false,
            "description": "`incoming` nebo `outgoing`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Stav (např. `to_process`, `done`).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Počet záznamů na stránku, 1–500.",
            "schema": {
              "type": "integer",
              "default": "100"
            },
            "example": "100"
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Hodnota `next_cursor` z předchozí odpovědi.",
            "schema": {
              "type": "string"
            },
            "example": "eyJpZCI6Ijk…"
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "data": [
                    {
                      "id": "m1…",
                      "number": "P2026/0451",
                      "direction": "incoming",
                      "received_date": "2026-11-10",
                      "sender": "Dodavatel s.r.o.",
                      "description": "Faktura 2026118",
                      "status": "to_process",
                      "assigned_to": "Jana Nováková"
                    }
                  ],
                  "next_cursor": "eyJpZCI6Ijk…"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "post": {
        "operationId": "mail-create",
        "summary": "Založit přijatou zásilku",
        "description": "Zaeviduje přijatou zásilku se skenem (`multipart/form-data`). Číslo přidělí TEMPO z řady organizace.",
        "tags": [
          "Pošta"
        ],
        "x-tempo-phase": "Připravujeme",
        "x-tempo-scope": "mail:write",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Jedinečný klíč požadavku (UUID, číslo objednávky). Opakování se stejným klíčem nic nezaloží podruhé.",
            "schema": {
              "type": "string"
            },
            "example": "objednavka-2026-004512"
          }
        ],
        "responses": {
          "201": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "id": "m2…",
                  "number": "P2026/0452",
                  "status": "registered"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "received_date",
                  "sender"
                ],
                "properties": {
                  "received_date": {
                    "type": "string",
                    "description": "Datum přijetí."
                  },
                  "sender": {
                    "type": "string",
                    "description": "Odesílatel."
                  },
                  "description": {
                    "type": "string",
                    "description": "Popis."
                  },
                  "creates_liability": {
                    "type": "boolean",
                    "description": "Vzniká závazek."
                  },
                  "file": {
                    "type": "string",
                    "description": "Sken."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/companies/{company_id}/extractions": {
      "post": {
        "operationId": "extraction-create",
        "summary": "Nahrát doklad k vytěžení",
        "description": "Nahraje soubor k vytěžení. Výsledek je návrh konceptu – uloží ho člověk v aplikaci. Platí limity vytěžování firmy.",
        "tags": [
          "Vytěžování"
        ],
        "x-tempo-phase": "Připravujeme",
        "x-tempo-scope": "extraction:write",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Jedinečný klíč požadavku (UUID, číslo objednávky). Opakování se stejným klíčem nic nezaloží podruhé.",
            "schema": {
              "type": "string"
            },
            "example": "objednavka-2026-004512"
          }
        ],
        "responses": {
          "202": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "id": "x1…",
                  "status": "queued"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "413": {
            "$ref": "#/components/responses/E413"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "description": "PDF, ISDOC nebo obrázek (nejvýš 20 MB)."
                  },
                  "document_type": {
                    "type": "string",
                    "description": "Očekávaný druh (`FP`, `PO`…)."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/companies/{company_id}/extractions/{extraction_id}": {
      "get": {
        "operationId": "extraction-get",
        "summary": "Stav vytěžení",
        "description": "Stav úlohy (`queued`, `processing`, `done`, `failed`) a odkaz na návrh v aplikaci.",
        "tags": [
          "Vytěžování"
        ],
        "x-tempo-phase": "Verze 1",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "required": true,
            "description": "Identifikátor firmy (z `GET /companies`).",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04"
          },
          {
            "name": "extraction_id",
            "in": "path",
            "required": true,
            "description": "Úloha vytěžení.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "id": "x1…",
                  "status": "done",
                  "app_url": "https://app.mytempo.cz/vytezovani/x1…"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          }
        }
      }
    },
    "/events": {
      "get": {
        "operationId": "events",
        "summary": "Kanál změn",
        "description": "Události od posledního kurzoru (vznik, zařazení, úhrada dokladu, nová pošta…). Uchovávají se 30 dní; nic se neztratí ani při výpadku příjemce.",
        "tags": [
          "Události"
        ],
        "x-tempo-phase": "Připravujeme",
        "x-tempo-scope": "read",
        "parameters": [
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "Kurzor poslední zpracované události.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "types",
            "in": "query",
            "required": false,
            "description": "Typy událostí čárkou.",
            "schema": {
              "type": "string"
            },
            "example": "invoice.paid,mail.received"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Počet záznamů na stránku, 1–500.",
            "schema": {
              "type": "integer",
              "default": "100"
            },
            "example": "100"
          }
        ],
        "responses": {
          "200": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "data": [
                    {
                      "id": "ev_10452",
                      "type": "invoice.paid",
                      "occurred_at": "2026-11-11T09:12:00+01:00",
                      "company_id": "9d42c1e0-5b7a-4f1e-9c3d-2a8b7e6f1d04",
                      "object": {
                        "kind": "document",
                        "id": "e71a3b2c-4d5e-4f60-8a7b-9c0d1e2f3a4b",
                        "number": "FV2026-0142"
                      }
                    }
                  ],
                  "next_cursor": "ev_10452"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/webhooks": {
      "post": {
        "operationId": "webhooks-create",
        "summary": "Založit webhook",
        "description": "Zaregistruje adresu `https://`, na kterou TEMPO posílá vybrané události podepsané HMAC-SHA256 (Standard Webhooks). Tajemství se zobrazí jen jednou.",
        "tags": [
          "Události"
        ],
        "x-tempo-phase": "Připravujeme",
        "x-tempo-scope": "webhooks:manage",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Jedinečný klíč požadavku (UUID, číslo objednávky). Opakování se stejným klíčem nic nezaloží podruhé.",
            "schema": {
              "type": "string"
            },
            "example": "objednavka-2026-004512"
          }
        ],
        "responses": {
          "201": {
            "description": "Úspěch",
            "content": {
              "application/json": {
                "example": {
                  "id": "wh1…",
                  "url": "https://hooks.example/tempo",
                  "events": [
                    "invoice.paid"
                  ],
                  "secret": "whsec_… (jen jednou)"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url",
                  "events"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "description": "Adresa příjemce (jen https)."
                  },
                  "events": {
                    "type": "string",
                    "description": "Typy událostí."
                  },
                  "company_ids": {
                    "type": "string",
                    "description": "Jen vybrané firmy."
                  }
                }
              },
              "example": {
                "url": "https://hooks.example/tempo",
                "events": [
                  "invoice.paid"
                ]
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Company": {
        "type": "object",
        "properties": {
          "id": {
            "description": "uuid – Identifikátor firmy."
          },
          "name": {
            "description": "string – Název firmy."
          },
          "ico": {
            "description": "string – IČO."
          },
          "dic": {
            "description": "string | null – DIČ."
          },
          "organization_id": {
            "description": "uuid – Organizace, do které firma patří."
          },
          "method": {
            "description": "enum – `accounting` (účetnictví) nebo `tax_records` (daňová evidence)."
          },
          "vat_payer": {
            "description": "boolean – Je ke dnešnímu dni plátce DPH."
          },
          "vat_period": {
            "description": "enum | null – `month` nebo `quarter` – periodicita DPH."
          },
          "currency": {
            "description": "string – Měna účetnictví (ISO 4217)."
          }
        }
      },
      "Period": {
        "type": "object",
        "properties": {
          "id": {
            "description": "uuid – Identifikátor období."
          },
          "name": {
            "description": "string – Název, např. `2026`."
          },
          "date_from": {
            "description": "date – První den období."
          },
          "date_to": {
            "description": "date – Poslední den období."
          },
          "status": {
            "description": "enum – `open`, `closed` (uzavřené) nebo `locked` (uzamčené)."
          }
        }
      },
      "Partner": {
        "type": "object",
        "properties": {
          "id": {
            "description": "uuid – Identifikátor partnera."
          },
          "kind": {
            "description": "enum – `company` (firma) nebo `person` (osoba)."
          },
          "name": {
            "description": "string – Název nebo jméno a příjmení."
          },
          "ico": {
            "description": "string | null – IČO."
          },
          "dic": {
            "description": "string | null – DIČ."
          },
          "address": {
            "description": "Address – Sídlo: `street`, `city`, `zip`, `country` (ISO 3166-1 alpha-2)."
          },
          "email": {
            "description": "string | null – E-mail pro doklady."
          },
          "bank_accounts": {
            "description": "array – Bankovní účty: `account_number`, `bank_code`, `iban`, `bic`, `currency`."
          },
          "tags": {
            "description": "array of string – Štítky."
          },
          "version": {
            "description": "integer – Verze záznamu pro `If-Match`."
          },
          "updated_at": {
            "description": "date-time – Čas poslední změny."
          }
        }
      },
      "Document": {
        "type": "object",
        "properties": {
          "id": {
            "description": "uuid – Identifikátor dokladu."
          },
          "document_type": {
            "description": "string – Druh dokladu: `FV`, `FP`, `ZFV`, `ZFP`, `DDPZ`, `DDPOZ`, `ID`, `PO`, `BA`…"
          },
          "status": {
            "description": "enum – `draft` · `registered` · `booked` · `locked` · `cancelled`."
          },
          "number": {
            "description": "string | null – Číslo dokladu (koncept ho nemá – přidělí ho zařazení)."
          },
          "book": {
            "description": "object – Kniha: `id`, `code`, `name`."
          },
          "partner": {
            "description": "object | null – Partner: `id`, `name`, `ico`."
          },
          "issue_date": {
            "description": "date – Datum vystavení."
          },
          "accounting_date": {
            "description": "date – Datum účetního případu."
          },
          "taxable_supply_date": {
            "description": "date | null – DUZP."
          },
          "due_date": {
            "description": "date | null – Splatnost."
          },
          "variable_symbol": {
            "description": "string | null – Variabilní symbol."
          },
          "currency": {
            "description": "string – Měna dokladu."
          },
          "exchange_rate": {
            "description": "decimal (text) | null – Kurz (jen u cizí měny)."
          },
          "amount_base": {
            "description": "decimal (text) – Základ celkem."
          },
          "amount_vat": {
            "description": "decimal (text) – DPH celkem."
          },
          "amount_total": {
            "description": "decimal (text) – Celkem k úhradě."
          },
          "remaining": {
            "description": "decimal (text) | null – Zbývá uhradit (jen FV, FP, ZFV, ZFP)."
          },
          "lines": {
            "description": "array of DocumentLine – Řádky – jen v detailu dokladu."
          },
          "vat_summary": {
            "description": "array – Rekapitulace DPH po sazbách – jen v detailu."
          },
          "source": {
            "description": "enum – Odkud doklad vznikl: `app`, `api`, `ai`, `extraction`, `recurring`, `bank_import`."
          },
          "version": {
            "description": "integer – Verze pro `If-Match`."
          },
          "updated_at": {
            "description": "date-time – Čas poslední změny."
          },
          "app_url": {
            "description": "string – Odkaz na doklad v aplikaci."
          }
        }
      },
      "DocumentLine": {
        "type": "object",
        "properties": {
          "id": {
            "description": "uuid – Identifikátor řádku."
          },
          "description": {
            "description": "string – Popis."
          },
          "quantity": {
            "description": "decimal (text) – Množství."
          },
          "unit": {
            "description": "string | null – Jednotka."
          },
          "unit_price": {
            "description": "decimal (text) – Cena za jednotku."
          },
          "vat_code": {
            "description": "string | null – Kód DPH z číselníku firmy."
          },
          "vat_rate": {
            "description": "decimal (text) | null – Sazba DPH v %."
          },
          "amount_base": {
            "description": "decimal (text) – Základ řádku."
          },
          "amount_vat": {
            "description": "decimal (text) – DPH řádku."
          },
          "account": {
            "description": "string | null – Účet (u účetnictví) – jen čtení."
          },
          "tax_category": {
            "description": "string | null – Položka daňové evidence – jen čtení."
          },
          "dimensions": {
            "description": "object – Dimenze řádku (`středisko`, `zakázka`…) – kód typu → kód hodnoty."
          }
        }
      },
      "OpenItem": {
        "type": "object",
        "properties": {
          "document_id": {
            "description": "uuid – Doklad."
          },
          "document_type": {
            "description": "string – Druh dokladu."
          },
          "number": {
            "description": "string – Číslo dokladu."
          },
          "partner": {
            "description": "object – Partner: `id`, `name`."
          },
          "variable_symbol": {
            "description": "string | null – Variabilní symbol."
          },
          "due_date": {
            "description": "date – Splatnost."
          },
          "days_overdue": {
            "description": "integer – Počet dní po splatnosti (0 = ve splatnosti)."
          },
          "currency": {
            "description": "string – Měna."
          },
          "amount": {
            "description": "decimal (text) – Částka dokladu."
          },
          "remaining": {
            "description": "decimal (text) – Zbývá uhradit."
          }
        }
      },
      "BankMovement": {
        "type": "object",
        "properties": {
          "id": {
            "description": "uuid – Identifikátor pohybu."
          },
          "bank_account_id": {
            "description": "uuid – Bankovní účet firmy."
          },
          "date": {
            "description": "date – Datum pohybu."
          },
          "amount": {
            "description": "decimal (text) – Částka (příjem kladně, výdaj záporně)."
          },
          "currency": {
            "description": "string – Měna."
          },
          "counter_account": {
            "description": "string | null – Protiúčet."
          },
          "variable_symbol": {
            "description": "string | null – VS."
          },
          "message": {
            "description": "string | null – Zpráva pro příjemce."
          },
          "matched": {
            "description": "boolean – Je pohyb spárovaný s dokladem."
          },
          "document_id": {
            "description": "uuid | null – Doklad banky, který pohyb zaúčtoval."
          }
        }
      },
      "Problem": {
        "type": "object",
        "properties": {
          "type": {
            "description": "string – Odkaz na popis chyby."
          },
          "title": {
            "description": "string – Krátký název chyby (česky)."
          },
          "status": {
            "description": "integer – Stav HTTP."
          },
          "code": {
            "description": "string – Stabilní kód chyby – podle něj se řiďte v programu."
          },
          "detail": {
            "description": "string – Vysvětlení pro člověka (česky)."
          },
          "errors": {
            "description": "array | null – Chyby po polích: `field`, `code`, `message`."
          }
        }
      }
    },
    "responses": {
      "E400": {
        "description": "Chybný požadavek – formát, neznámý parametr.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "E401": {
        "description": "Chybí, vypršel nebo byl zrušen token.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "E403": {
        "description": "Token nemá rozsah, nebo uživatel nemá oprávnění.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "E404": {
        "description": "Záznam neexistuje, nebo k němu nemáte přístup.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "E409": {
        "description": "Souběžná změna, opakovaný klíč s jiným obsahem, uzavřené období.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "E413": {
        "description": "Soubor je větší než 20 MB.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "E422": {
        "description": "Údaje neprošly kontrolou – podrobnosti v `errors`.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "E429": {
        "description": "Překročený limit – počkejte podle `Retry-After`.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      }
    },
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Osobní token `tempo_pat_…` nebo přístupový token OAuth."
      }
    }
  }
}