{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/upriver-ai/json-schema/upriver-ai-category-search-response-schema.json",
  "title": "CategorySearchResponse",
  "description": "Response from category search endpoint.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/upriver-ai-taxonomy-api-openapi.yml#/components/schemas/CategorySearchResponse",
  "properties": {
    "matches": {
      "items": {
        "$ref": "#/$defs/CategoryMatch"
      },
      "type": "array",
      "title": "Matches",
      "description": "Ordered list of matched categories (highest confidence first)"
    },
    "query_text": {
      "type": "string",
      "title": "Query Text",
      "description": "The input text that was matched"
    }
  },
  "type": "object",
  "required": [
    "matches",
    "query_text"
  ],
  "$defs": {
    "CategoryMatch": {
      "properties": {
        "category_id": {
          "type": "string",
          "title": "Category Id",
          "description": "Category ID from taxonomy"
        },
        "display_name": {
          "type": "string",
          "title": "Display Name",
          "description": "Human-readable category name. Use this for embedding-based resolution in downstream endpoints."
        },
        "level": {
          "type": "integer",
          "title": "Level",
          "description": "Taxonomy level (1 or 2)"
        },
        "parent_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Parent Id",
          "description": "Parent category ID for L2 categories"
        },
        "confidence": {
          "type": "number",
          "maximum": 1.0,
          "minimum": 0.0,
          "title": "Confidence",
          "description": "Confidence score for this match"
        },
        "reason": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Reason",
          "description": "Explanation for why this category was chosen"
        }
      },
      "type": "object",
      "required": [
        "category_id",
        "display_name",
        "level",
        "confidence"
      ],
      "title": "CategoryMatch",
      "description": "A matched category with confidence score.\n\nNote: When passing the matched category to other endpoints that use\nembedding-based resolution (like /sponsors), use the display_name field\nrather than category_id for better embedding matches."
    }
  }
}