{
  "openapi": "3.1.0",
  "info": {
    "title": "mrickwood.cz REST API",
    "version": "2.1.0",
    "description": "Public API pro Tendero LEADS, accounts management, webhooks. Full docs: https://mrickwood.cz/docs",
    "contact": {
      "email": "michal@rickwood.cz",
      "url": "https://mrickwood.cz/docs"
    },
    "license": {
      "name": "Proprietary"
    }
  },
  "servers": [
    {
      "url": "https://mrickwood.cz",
      "description": "Production"
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Api-Key",
        "description": "API kl\u00ed\u010d (mrw_live_\u2026 nebo mrw_mgmt_\u2026) vygenerovan\u00fd v dashboardu po registraci a verifikaci e-mailu."
      }
    },
    "schemas": {
      "ApiError": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "UNAUTHENTICATED",
                  "UNAUTHORIZED",
                  "FORBIDDEN",
                  "NOT_FOUND",
                  "VALIDATION_ERROR",
                  "CONFLICT",
                  "RATE_LIMITED",
                  "INTERNAL"
                ]
              },
              "message": {
                "type": "string"
              },
              "details": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        }
      },
      "Pagination": {
        "type": "object",
        "properties": {
          "nextCursor": {
            "type": "string",
            "nullable": true
          },
          "totalCount": {
            "type": "integer"
          }
        }
      },
      "AccountOverview": {
        "type": "object",
        "properties": {
          "account": {
            "type": "object",
            "properties": {
              "email": {
                "type": "string",
                "format": "email"
              },
              "name": {
                "type": "string",
                "nullable": true
              },
              "phone": {
                "type": "string",
                "nullable": true
              },
              "company": {
                "type": "string",
                "nullable": true
              },
              "ico": {
                "type": "string",
                "nullable": true
              },
              "dic": {
                "type": "string",
                "nullable": true
              },
              "address": {
                "type": "string",
                "nullable": true
              },
              "country": {
                "type": "string",
                "nullable": true
              },
              "locale": {
                "type": "string"
              },
              "isComplete": {
                "type": "boolean"
              }
            }
          },
          "subscriptions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Subscription"
            }
          },
          "apiKey": {
            "type": "object",
            "nullable": true,
            "properties": {
              "keyPrefix": {
                "type": "string"
              },
              "lastUsedAt": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              },
              "requestsMonth": {
                "type": "integer"
              },
              "requestsLimit": {
                "type": "integer"
              },
              "monthResetAt": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        }
      },
      "Subscription": {
        "type": "object",
        "properties": {
          "service": {
            "type": "string",
            "enum": [
              "LEADS",
              "PRICING",
              "PROCUREMENT"
            ]
          },
          "scope": {
            "type": "string",
            "nullable": true,
            "description": "Country code pro multi-country (CZ/SK/FR/DE). Aktu\u00e1ln\u011b jen CZ."
          },
          "state": {
            "type": "string",
            "enum": [
              "TRIAL",
              "ACTIVE",
              "PAST_DUE",
              "SUSPENDED",
              "CANCELED"
            ]
          },
          "tier": {
            "type": "string",
            "enum": [
              "FREE",
              "PAID"
            ]
          },
          "trialEndsAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "paidUntil": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "cancelAtPeriodEnd": {
            "type": "boolean"
          }
        }
      },
      "LeadFilter": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "regions": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "NUTS leaf codes (CZ010, \u2026)"
          },
          "industryTags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "categories": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "CPV prefixes (legacy)"
          },
          "keywords": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "minValue": {
            "type": "number",
            "nullable": true
          },
          "maxValue": {
            "type": "number",
            "nullable": true
          },
          "emailDigest": {
            "type": "boolean"
          },
          "active": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "LeadFilterInput": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "regions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "industryTags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "categories": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "keywords": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "minValue": {
            "type": "number",
            "nullable": true
          },
          "maxValue": {
            "type": "number",
            "nullable": true
          },
          "emailDigest": {
            "type": "boolean",
            "default": true
          },
          "active": {
            "type": "boolean",
            "default": true
          }
        }
      },
      "LeadMatch": {
        "type": "object",
        "properties": {
          "matchId": {
            "type": "string",
            "description": "cm\u2026 (pre-computed) nebo live-<tenderId> (synthetic)"
          },
          "filterId": {
            "type": "string",
            "nullable": true
          },
          "filterName": {
            "type": "string",
            "nullable": true
          },
          "matchedAt": {
            "type": "string",
            "format": "date-time"
          },
          "viewedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "delivered": {
            "type": "boolean"
          },
          "tender": {
            "$ref": "#/components/schemas/Tender"
          }
        }
      },
      "Tender": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "estimatedValue": {
            "type": "number",
            "nullable": true
          },
          "deadlineAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "publishedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "firstSeenAt": {
            "type": "string",
            "format": "date-time"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "portalType": {
            "type": "string"
          },
          "cpvCode": {
            "type": "string",
            "nullable": true
          },
          "tenderType": {
            "type": "string",
            "nullable": true
          },
          "contractingAuthority": {
            "type": "object",
            "properties": {
              "ico": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "region": {
                "type": "string",
                "nullable": true
              },
              "district": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "documents": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "url": {
                  "type": "string",
                  "format": "uri"
                },
                "fileType": {
                  "type": "string",
                  "nullable": true
                },
                "fileSizeBytes": {
                  "type": "integer",
                  "nullable": true
                }
              }
            }
          },
          "starred": {
            "type": "boolean"
          },
          "excluded": {
            "type": "boolean"
          }
        }
      },
      "Webhook": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "enabledEvents": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "isActive": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Profile": {
        "type": "object",
        "description": "User profile s billing \u00fadaji a consent flag.",
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "company": {
            "type": "string",
            "nullable": true
          },
          "ico": {
            "type": "string",
            "nullable": true,
            "description": "I\u010cO / Tax ID"
          },
          "dic": {
            "type": "string",
            "nullable": true,
            "description": "DI\u010c / VAT ID"
          },
          "address": {
            "type": "string",
            "nullable": true
          },
          "country": {
            "type": "string",
            "nullable": true,
            "description": "ISO 3166-1 alpha-2"
          },
          "locale": {
            "type": "string",
            "enum": [
              "cs",
              "en",
              "de"
            ]
          },
          "isComplete": {
            "type": "boolean",
            "description": "True pokud profile m\u00e1 name + country + ico"
          },
          "consentRequired": {
            "type": "boolean",
            "description": "True pokud user dosud nem\u00e1 VOP+GDPR consent proof (OAuth flow). UI mus\u00ed zobrazit checkboxy."
          }
        }
      },
      "ProfileUpdate": {
        "type": "object",
        "description": "Profile update body. Pro OAuth users s consentRequired=true vy\u017eaduje consentVop+consentGdpr.",
        "properties": {
          "name": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "company": {
            "type": "string"
          },
          "ico": {
            "type": "string"
          },
          "dic": {
            "type": "string"
          },
          "address": {
            "type": "string"
          },
          "country": {
            "type": "string"
          },
          "consentVop": {
            "type": "boolean",
            "description": "Vy\u017eadovan\u00e9 pro OAuth users p\u0159i prvn\u00edm update"
          },
          "consentGdpr": {
            "type": "boolean",
            "description": "Vy\u017eadovan\u00e9 pro OAuth users p\u0159i prvn\u00edm update"
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Account",
      "description": "Profil, p\u0159edplatn\u00e9, fakturace, webhooks"
    },
    {
      "name": "Leads",
      "description": "Filtry, matches, tendery, taxonomie"
    }
  ],
  "paths": {
    "/api/v2/account/me": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Kombinovan\u00fd overview \u2014 profile + subscriptions + apiKey usage",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AccountOverview"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/account/subscriptions": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "List subscriptions",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Subscription"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Aktivuje trial pro slu\u017ebu",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "service",
                  "mode"
                ],
                "properties": {
                  "service": {
                    "type": "string",
                    "enum": [
                      "LEADS",
                      "PRICING",
                      "PROCUREMENT"
                    ]
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "trial"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Subscription vytvo\u0159ena",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Subscription"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/account/webhooks": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "List webhooks",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Webhook"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Vytvo\u0159\u00ed webhook \u2014 secret se vr\u00e1t\u00ed jen jednou",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url",
                  "enabledEvents"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "enabledEvents": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "description": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created"
          }
        }
      }
    },
    "/api/v2/leads/filters": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "List filters",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/LeadFilter"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Leads"
        ],
        "summary": "Vytvo\u0159\u00ed filter",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LeadFilterInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created"
          }
        }
      }
    },
    "/api/v2/leads/filters/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "Detail filteru",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "delete": {
        "tags": [
          "Leads"
        ],
        "summary": "Sma\u017ee filter",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          }
        }
      },
      "patch": {
        "tags": [
          "Leads"
        ],
        "summary": "Update filteru",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LeadFilterInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v2/leads/matches": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "List matches s filtry / search",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "filterId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "qText",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Full-text search (p\u0159ep\u00ed\u0161e filterId mode)"
          },
          {
            "name": "since",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Vr\u00e1t\u00ed jen matches s matchedAt >= since (ISO 8601)"
          },
          {
            "name": "view",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "starred",
                "excluded"
              ]
            }
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "newest",
                "deadline",
                "value"
              ],
              "default": "newest"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 50,
              "maximum": 1000
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "regions",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "CSV (CZ010,CZ020)"
          },
          {
            "name": "industryTags",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "CSV"
          },
          {
            "name": "cpvPrefixes",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "CSV"
          },
          {
            "name": "minValue",
            "in": "query",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "maxValue",
            "in": "query",
            "schema": {
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/LeadMatch"
                      }
                    },
                    "pagination": {
                      "$ref": "#/components/schemas/Pagination"
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "LEADS service neaktivn\u00ed"
          }
        }
      }
    },
    "/api/v2/leads/taxonomy/industry": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "Industry taxonomy (areas + tags)",
        "parameters": [
          {
            "name": "locale",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "cs",
                "en",
                "de"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v2/leads/taxonomy/cpv": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "Full CPV catalog",
        "parameters": [
          {
            "name": "locale",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v2/feedback": {
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Po\u0161le feedback / bug report",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "kind",
                  "message"
                ],
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "BUG",
                      "IDEA",
                      "OTHER",
                      "MISSING_TENDER"
                    ]
                  },
                  "message": {
                    "type": "string"
                  },
                  "page": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created"
          }
        }
      }
    },
    "/api/v2/onboarding/ico-check": {
      "get": {
        "tags": [
          "Onboarding"
        ],
        "summary": "Pre-flight trial eligibility check pro I\u010cO",
        "description": "Vr\u00e1t\u00ed jestli je dan\u00e9 I\u010cO je\u0161t\u011b eligible pro 14denn\u00ed trial. Pou\u017eito v /onboarding/profile flow (debounced) \u2014 pokud non-eligible, UI uk\u00e1\u017ee warning a po dokon\u010den\u00ed profilu redirect na paywall m\u00edsto trial.",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "ico",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "service",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "LEADS",
                "PRICING",
                "PROCUREMENT"
              ],
              "default": "LEADS"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "trialEligible": {
                          "type": "boolean"
                        },
                        "reason": {
                          "type": "string",
                          "enum": [
                            "USED_BY_OTHER_USER"
                          ]
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/account/profile": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Get profile (s consent requirement flag)",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Profile"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Account"
        ],
        "summary": "Update profile (s consent capture pro OAuth users)",
        "description": "Pro OAuth users, kte\u0159\u00ed nemaj\u00ed consent proof v DB, je p\u0159i prvn\u00edm PATCH vy\u017eadov\u00e1no consentVop=true + consentGdpr=true v body. Server ulo\u017e\u00ed timestamps + version + IP + UA. Email+heslo users u\u017e maj\u00ed consent z registrace.",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProfileUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Profile"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error or consent required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/account/subscriptions/batch": {
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Atomick\u00e1 aktivace trial pro N LEADS zem\u00ed najednou",
        "description": "Multi-country onboarding \u2014 vytvo\u0159\u00ed N Subscription rows v jedn\u00e9 DB transakci. Pokud user u\u017e m\u00e1 sub pro n\u011bkterou zemi, silently skipnuta (idempotent). Pokud user nem\u00e1 kompletn\u00ed profil (name + country + ico) \u2192 400. Pokud I\u010cO u\u017e pou\u017eit\u00e9 jin\u00fdm userem \u2192 409 (anti-abuse).",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "service",
                  "scopes",
                  "mode"
                ],
                "properties": {
                  "service": {
                    "type": "string",
                    "enum": [
                      "LEADS"
                    ]
                  },
                  "scopes": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "description": "ISO 3166-1 alpha-2 country code"
                    },
                    "example": [
                      "CZ",
                      "SK",
                      "DE"
                    ]
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "trial"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Subscription"
                      }
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "I\u010cO already used for trial by another user",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/account/keys": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "List API keys",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Create new API key (raw vr\u00e1cen jen jednou)",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "label": {
                    "type": "string",
                    "maxLength": 80
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "key": {
                          "type": "string",
                          "description": "Raw API key, returned ONCE \u2014 store immediately"
                        },
                        "keyPrefix": {
                          "type": "string"
                        },
                        "label": {
                          "type": "string",
                          "nullable": true
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/account/keys/{id}": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Key detail",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "patch": {
        "tags": [
          "Account"
        ],
        "summary": "Update label",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "delete": {
        "tags": [
          "Account"
        ],
        "summary": "Revoke key (soft delete)",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Revoked"
          }
        }
      }
    },
    "/api/v2/account/keys/{id}/rotate": {
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Rotate \u2014 vygeneruje nov\u00fd raw key, hash p\u0159eps\u00e1n",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rotated"
          }
        }
      }
    },
    "/api/v2/account/usage": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Denn\u00ed agreg\u00e1t po\u010dtu API vol\u00e1n\u00ed",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 30,
              "maximum": 365
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "date": {
                            "type": "string",
                            "format": "date"
                          },
                          "calls": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/account/billing": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Current billing state (profile, card, invoice)",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "patch": {
        "tags": [
          "Account"
        ],
        "summary": "Update billing mode, cycle, currency, profile",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Updated"
          }
        }
      }
    },
    "/api/v2/account/billing/checkout": {
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Stripe Checkout URL pro p\u0159id\u00e1n\u00ed karty",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "delete": {
        "tags": [
          "Account"
        ],
        "summary": "Odpojit kartu (detach Stripe payment method)",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "204": {
            "description": "Detached"
          }
        }
      }
    },
    "/api/v2/account/billing/customer-portal": {
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Stripe Customer Portal URL (spr\u00e1va karty + faktury + p\u0159edplatn\u00e9)",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v2/account/billing/proforma": {
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Vystav\u00ed z\u00e1lohovou fakturu",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "cycle"
                ],
                "properties": {
                  "cycle": {
                    "type": "string",
                    "enum": [
                      "MONTHLY",
                      "YEARLY"
                    ]
                  },
                  "currency": {
                    "type": "string",
                    "enum": [
                      "CZK",
                      "EUR"
                    ]
                  },
                  "scopes": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Ad-hoc LEADS scopes pro paywall flow bez existing subs"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Issued"
          }
        }
      },
      "delete": {
        "tags": [
          "Account"
        ],
        "summary": "Smazat aktivn\u00ed proformu",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          }
        }
      }
    },
    "/api/v2/account/billing/invoices": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "List v\u0161ech faktur (PROFORMA + TAX_DOC)",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v2/account/billing/invoices/{invoiceId}": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "St\u00e1hne PDF faktury (signed URL)",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "PDF binary",
            "content": {
              "application/pdf": {}
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Account"
        ],
        "summary": "Smazat fakturu z historie",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          }
        }
      }
    },
    "/api/v2/account/webhooks/{id}": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Webhook endpoint detail",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "patch": {
        "tags": [
          "Account"
        ],
        "summary": "Update URL, events, isActive",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "delete": {
        "tags": [
          "Account"
        ],
        "summary": "Smazat endpoint (+cascade deliveries)",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          }
        }
      }
    },
    "/api/v2/account/webhooks/{id}/rotate-secret": {
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Rotate secret \u2014 star\u00fd okam\u017eit\u011b invalidn\u00ed",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rotated"
          }
        }
      }
    },
    "/api/v2/account/webhooks/{id}/test": {
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Synthetic webhook.test event \u2014 ov\u011b\u0159 \u017ee receiver vrac\u00ed 2xx",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Delivered"
          }
        }
      }
    },
    "/api/v2/account/webhooks/{id}/deliveries": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Historie pokus\u016f o doru\u010den\u00ed",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v2/account/webhooks/{id}/deliveries/{deliveryId}/replay": {
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Manu\u00e1ln\u00ed replay selhan\u00e9ho delivery",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "deliveryId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Replayed"
          }
        }
      }
    },
    "/api/v2/leads/coverage": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "Po\u010det aktivn\u00edch tendr\u016f per zem\u011b (public)",
        "description": "Server cache 1h. Ve\u0159ejn\u00fd \u2014 \u017e\u00e1dn\u00e1 auth.",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v2/leads/countries": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "Sjednocen\u00fd katalog LEADS zem\u00ed (labels + pricing + sources + coverage)",
        "description": "Server cache 1h. Ve\u0159ejn\u00fd.",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v2/leads/regions": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "NUTS regiony pro zemi (?country=CZ) s labels per locale",
        "parameters": [
          {
            "name": "country",
            "in": "query",
            "schema": {
              "type": "string",
              "description": "ISO 3166-1 alpha-2"
            }
          },
          {
            "name": "locale",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "cs",
                "en",
                "de"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v2/leads/regions/catalog": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "Pln\u00fd NUTS strom zem\u011b (v\u0161echny \u00farovn\u011b NUTS-1/2/3)",
        "parameters": [
          {
            "name": "country",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "locale",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "cs",
                "en",
                "de"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v2/leads/zadavatele": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "Autocomplete kontrakta\u010dn\u00edch autorit (zadavatel\u016f)",
        "description": "Prefix match. Limit 30. Respektuje active LEADS countries.",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "include",
            "in": "query",
            "schema": {
              "type": "string",
              "description": "CSV I\u010cO pro sticky preselect"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v2/leads/tenders/search": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "Live full-text search nap\u0159\u00ed\u010d tenders",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v2/leads/tenders/{id}": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "Tender detail (enriched)",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/api/v2/leads/tenders/{id}/email": {
      "post": {
        "tags": [
          "Leads"
        ],
        "summary": "Po\u0161li summary konkr\u00e9tn\u00edho tenderu na user email",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sent"
          }
        }
      }
    },
    "/api/v2/leads/documents/preview": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "Konverze DOCX/XLSX tender dokumentu na HTML",
        "description": "302 redirect na signed URL (TTL 10 min) na cached HTML. Host allowlist: NEN, E-ZAK, Tender Arena, Gemin, ProfilZadavatele.",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uri"
            }
          },
          {
            "name": "kind",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "docx",
                "xlsx"
              ]
            }
          }
        ],
        "responses": {
          "302": {
            "description": "Redirect to cached HTML"
          }
        }
      }
    },
    "/api/v2/leads/matches/{matchId}": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "Match detail",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "matchId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/v2/leads/matches/{matchId}/star": {
      "post": {
        "tags": [
          "Leads"
        ],
        "summary": "Toggle star (sledov\u00e1no)",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "matchId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "starred"
                ],
                "properties": {
                  "starred": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Updated"
          }
        }
      }
    },
    "/api/v2/leads/matches/{matchId}/exclude": {
      "post": {
        "tags": [
          "Leads"
        ],
        "summary": "Toggle exclude (skryto)",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "matchId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "excluded"
                ],
                "properties": {
                  "excluded": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Updated"
          }
        }
      }
    },
    "/api/v2/leads/matches/{matchId}/view": {
      "post": {
        "tags": [
          "Leads"
        ],
        "summary": "Mark match viewed (no-op pro live-* synthetic IDs)",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "matchId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Updated"
          }
        }
      }
    },
    "/api/v2/leads/filters/{id}/matches/export": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "Export match\u016f do CSV / XLSX / JSON",
        "description": "Max 5000 \u0159\u00e1dk\u016f. Respektuje active LEADS countries + filter regions/cpv/industry.",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "filterId nebo 'all' (virtual filter)"
            }
          },
          {
            "name": "format",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "csv",
                "xlsx",
                "json"
              ],
              "default": "csv"
            }
          },
          {
            "name": "view",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "starred",
                "excluded"
              ],
              "default": "all"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Export"
          }
        }
      }
    },
    "/api/v2/leads/preferences": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "All starred + excluded tender IDs (mobile sync)",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  }
}
