{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/call2me-app/json-schema/call2me-app-knowledge-base-schema.json",
  "title": "KnowledgeBase",
  "description": "Knowledge base response model - matches Retell's schema.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/call2me-app-knowledge-base-api-openapi.yml#/components/schemas/KnowledgeBase",
  "properties": {
    "knowledge_base_id": {
      "type": "string",
      "title": "Knowledge Base Id",
      "description": "Unique identifier"
    },
    "knowledge_base_name": {
      "type": "string",
      "maxLength": 40,
      "title": "Knowledge Base Name",
      "description": "Name of the knowledge base"
    },
    "status": {
      "$ref": "#/$defs/KnowledgeBaseStatus",
      "description": "Processing status"
    },
    "knowledge_base_sources": {
      "items": {
        "anyOf": [
          {
            "$ref": "#/$defs/KnowledgeBaseTextSource"
          },
          {
            "$ref": "#/$defs/KnowledgeBaseUrlSource"
          },
          {
            "$ref": "#/$defs/KnowledgeBaseDocumentSource"
          }
        ]
      },
      "type": "array",
      "title": "Knowledge Base Sources",
      "description": "Sources in this knowledge base"
    },
    "enable_auto_refresh": {
      "type": "boolean",
      "title": "Enable Auto Refresh",
      "description": "Auto-refresh URLs every 12 hours",
      "default": false
    },
    "last_refreshed_timestamp": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Last Refreshed Timestamp",
      "description": "Last refresh timestamp (ms since epoch)"
    },
    "agent_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Agent Id",
      "description": "Agent this knowledge base is linked to"
    },
    "chunk_count": {
      "type": "integer",
      "title": "Chunk Count",
      "description": "Number of chunks in this knowledge base",
      "default": 0
    },
    "source_count": {
      "type": "integer",
      "title": "Source Count",
      "description": "Number of sources",
      "default": 0
    },
    "created_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Created At",
      "description": "Creation timestamp"
    }
  },
  "type": "object",
  "required": [
    "knowledge_base_id",
    "knowledge_base_name",
    "status"
  ],
  "$defs": {
    "KnowledgeBaseDocumentSource": {
      "properties": {
        "type": {
          "type": "string",
          "const": "document",
          "title": "Type",
          "default": "document"
        },
        "source_id": {
          "type": "string",
          "title": "Source Id",
          "description": "Unique identifier for this source"
        },
        "filename": {
          "type": "string",
          "title": "Filename",
          "description": "Original filename"
        },
        "file_url": {
          "type": "string",
          "title": "File Url",
          "description": "URL to access the file"
        },
        "file_size": {
          "type": "integer",
          "title": "File Size",
          "description": "File size in bytes"
        }
      },
      "type": "object",
      "required": [
        "source_id",
        "filename",
        "file_url",
        "file_size"
      ],
      "title": "KnowledgeBaseDocumentSource",
      "description": "Document/file source in a knowledge base."
    },
    "KnowledgeBaseStatus": {
      "type": "string",
      "enum": [
        "in_progress",
        "complete",
        "error",
        "refreshing_in_progress"
      ],
      "title": "KnowledgeBaseStatus",
      "description": "Status of a knowledge base."
    },
    "KnowledgeBaseTextSource": {
      "properties": {
        "type": {
          "type": "string",
          "const": "text",
          "title": "Type",
          "default": "text"
        },
        "source_id": {
          "type": "string",
          "title": "Source Id",
          "description": "Unique identifier for this source"
        },
        "title": {
          "type": "string",
          "title": "Title",
          "description": "Title of the text content"
        },
        "content": {
          "type": "string",
          "title": "Content",
          "description": "Text content"
        }
      },
      "type": "object",
      "required": [
        "source_id",
        "title",
        "content"
      ],
      "title": "KnowledgeBaseTextSource",
      "description": "Text source in a knowledge base."
    },
    "KnowledgeBaseUrlSource": {
      "properties": {
        "type": {
          "type": "string",
          "const": "url",
          "title": "Type",
          "default": "url"
        },
        "source_id": {
          "type": "string",
          "title": "Source Id",
          "description": "Unique identifier for this source"
        },
        "url": {
          "type": "string",
          "title": "Url",
          "description": "URL that was scraped"
        }
      },
      "type": "object",
      "required": [
        "source_id",
        "url"
      ],
      "title": "KnowledgeBaseUrlSource",
      "description": "URL source in a knowledge base."
    }
  }
}