{
  "openapi": "3.1.0",
  "info": {
    "title": "Tudetic Agent Catalog API",
    "version": "1.0.0",
    "description": "Read-only product search and vehicle compatibility for Tudetic's seven specialist shops. Public calls expose only the normal public price. Customer pricing is resolved exclusively from an authenticated PrestaShop session; callers cannot select a group or tariff."
  },
  "servers": [
    {"url": "https://www.tudetic.com", "description": "Production"}
  ],
  "tags": [
    {"name": "Products"},
    {"name": "Compatibility"}
  ],
  "paths": {
    "/ai/v1/products/search/": {
      "get": {
        "operationId": "searchProducts",
        "summary": "Search products",
        "description": "Search by natural language, reference, brand, shop or vehicle. A focused query or complete vehicle is required; catalog enumeration is not supported.",
        "tags": ["Products"],
        "parameters": [
          {"$ref": "#/components/parameters/query"},
          {"$ref": "#/components/parameters/shop"},
          {"$ref": "#/components/parameters/lang"},
          {"name": "brand", "in": "query", "schema": {"type": "string", "maxLength": 70}},
          {"name": "category_id", "in": "query", "schema": {"type": "integer", "minimum": 1}},
          {"name": "min_price", "in": "query", "schema": {"type": "number", "minimum": 0}},
          {"name": "max_price", "in": "query", "schema": {"type": "number", "minimum": 0}},
          {"name": "in_stock", "in": "query", "schema": {"type": "boolean", "default": true}},
          {"name": "sort", "in": "query", "schema": {"type": "string", "enum": ["relevance", "price_asc", "price_desc", "name_asc", "name_desc"]}},
          {"name": "page", "in": "query", "schema": {"type": "integer", "minimum": 1, "maximum": 50, "default": 1}},
          {"name": "limit", "in": "query", "schema": {"type": "integer", "minimum": 1, "maximum": 20, "default": 10}},
          {"name": "registration", "in": "query", "schema": {"type": "string", "maxLength": 16}},
          {"name": "vehicle_make", "in": "query", "schema": {"type": "string", "maxLength": 80}},
          {"name": "vehicle_model", "in": "query", "schema": {"type": "string", "maxLength": 120}},
          {"name": "vehicle_year", "in": "query", "schema": {"type": "string", "maxLength": 20}},
          {"name": "vehicle_cc", "in": "query", "schema": {"type": "string", "maxLength": 30}},
          {"$ref": "#/components/parameters/pricing"}
        ],
        "responses": {
          "200": {"description": "Compact product results", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/SearchResponse"}}}},
          "400": {"$ref": "#/components/responses/Error"},
          "401": {"description": "Customer pricing requested without a valid logged-in PrestaShop session", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}},
          "429": {"$ref": "#/components/responses/Error"},
          "503": {"$ref": "#/components/responses/Error"}
        }
      }
    },
    "/ai/v1/products/get/": {
      "get": {
        "operationId": "getProduct",
        "summary": "Get a product",
        "tags": ["Products"],
        "parameters": [
          {"name": "product_id", "in": "query", "required": true, "schema": {"type": "integer", "minimum": 1}},
          {"name": "variant_id", "in": "query", "schema": {"type": "integer", "minimum": 0}},
          {"$ref": "#/components/parameters/shop"},
          {"$ref": "#/components/parameters/lang"},
          {"$ref": "#/components/parameters/pricing"}
        ],
        "responses": {
          "200": {"description": "Product details", "content": {"application/json": {"schema": {"type": "object"}}}},
          "400": {"$ref": "#/components/responses/Error"},
          "401": {"$ref": "#/components/responses/Error"},
          "404": {"$ref": "#/components/responses/Error"}
        }
      }
    },
    "/ai/v1/compatibility/check/": {
      "get": {
        "operationId": "checkVehicleCompatibility",
        "summary": "Find products compatible with a vehicle",
        "tags": ["Compatibility"],
        "parameters": [
          {"$ref": "#/components/parameters/query"},
          {"$ref": "#/components/parameters/shop"},
          {"$ref": "#/components/parameters/lang"},
          {"name": "registration", "in": "query", "schema": {"type": "string", "maxLength": 16}},
          {"name": "vehicle_make", "in": "query", "schema": {"type": "string", "maxLength": 80}},
          {"name": "vehicle_model", "in": "query", "schema": {"type": "string", "maxLength": 120}},
          {"name": "vehicle_year", "in": "query", "schema": {"type": "string", "maxLength": 20}},
          {"name": "vehicle_cc", "in": "query", "schema": {"type": "string", "maxLength": 30}},
          {"name": "limit", "in": "query", "schema": {"type": "integer", "minimum": 1, "maximum": 20, "default": 10}},
          {"$ref": "#/components/parameters/pricing"}
        ],
        "responses": {
          "200": {"description": "Compatibility results", "content": {"application/json": {"schema": {"type": "object"}}}},
          "400": {"$ref": "#/components/responses/Error"},
          "401": {"$ref": "#/components/responses/Error"}
        }
      }
    }
  },
  "components": {
    "parameters": {
      "query": {"name": "q", "in": "query", "description": "Natural-language product query, SKU, MPN or GTIN", "schema": {"type": "string", "maxLength": 160}},
      "shop": {"name": "shop", "in": "query", "schema": {"type": "string", "enum": ["tudetic", "mototic", "scubatic", "biketic", "autotic", "trekktic", "cubiertas"], "default": "tudetic"}},
      "lang": {"name": "lang", "in": "query", "schema": {"type": "string", "pattern": "^[a-z]{2}$", "default": "es"}},
      "pricing": {"name": "pricing", "in": "query", "description": "public returns the normal price. customer requires a valid logged-in PrestaShop session; the server derives the customer's group and never trusts a caller-supplied group.", "schema": {"type": "string", "enum": ["public", "customer"], "default": "public"}}
    },
    "schemas": {
      "ProductResult": {
        "type": "object",
        "required": ["id", "name", "price", "currency", "availability", "url"],
        "properties": {
          "id": {"type": "integer"},
          "name": {"type": "string"},
          "brand": {"type": "string"},
          "category": {"type": "string"},
          "references": {"type": "array", "items": {"type": "string"}, "maxItems": 5},
          "price": {"type": ["number", "null"]},
          "price_max": {"type": ["number", "null"]},
          "currency": {"type": "string", "examples": ["EUR"]},
          "availability": {"type": "string", "enum": ["in_stock", "out_of_stock"]},
          "available_variants": {"type": "array", "items": {"type": "object"}, "maxItems": 12},
          "image": {"type": "string", "format": "uri"},
          "url": {"type": "string", "format": "uri"}
        }
      },
      "SearchResponse": {
        "type": "object",
        "required": ["schema_version", "generated_at", "pricing", "results"],
        "properties": {
          "schema_version": {"type": "string"},
          "query": {"type": "string"},
          "generated_at": {"type": "string", "format": "date-time"},
          "shop": {"type": "string"},
          "language": {"type": "string"},
          "currency": {"type": "string"},
          "pricing": {"type": "object"},
          "total_results": {"type": "integer"},
          "page": {"type": "integer"},
          "next_page": {"type": ["integer", "null"]},
          "results": {"type": "array", "items": {"$ref": "#/components/schemas/ProductResult"}, "maxItems": 20}
        }
      },
      "Error": {
        "type": "object",
        "required": ["error"],
        "properties": {"error": {"type": "string"}, "message": {"type": "string"}}
      }
    },
    "responses": {
      "Error": {"description": "Error response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}
    }
  },
  "x-mcp": {
    "transport": "streamable-http",
    "url": "https://www.tudetic.com/mcp/",
    "readOnly": true
  }
}
