> ## Documentation Index
> Fetch the complete documentation index at: https://apidocs.writesonic.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Search knowledge sources

> Semantic search over the project's knowledge sources (kih-hub RAG).

Returns the matched chunks and, when generate_answer is True, a generated
answer; set it False to get raw chunks only. Optionally scope the search to
specific source_ids/folder_ids/tag_ids or workflow_status; omit all to
search the whole project. A source is only indexed here once it finishes
syncing, so an unscoped query already excludes sources still queued,
syncing, or failed - no source_ids scoping needed to search "synced only".



## OpenAPI

````yaml https://mcp.agent.writesonic.com/openapi.json post /api/v1/business/knowledge/search
openapi: 3.1.0
info:
  title: hq-backend — Business API
  description: Public business tool endpoints (API-key auth).
  version: 0.1.0
servers: []
security: []
paths:
  /api/v1/business/knowledge/search:
    post:
      tags:
        - business
      summary: Search knowledge sources
      description: >-
        Semantic search over the project's knowledge sources (kih-hub RAG).


        Returns the matched chunks and, when generate_answer is True, a
        generated

        answer; set it False to get raw chunks only. Optionally scope the search
        to

        specific source_ids/folder_ids/tag_ids or workflow_status; omit all to

        search the whole project. A source is only indexed here once it finishes

        syncing, so an unscoped query already excludes sources still queued,

        syncing, or failed - no source_ids scoping needed to search "synced
        only".
      operationId: search_knowledge_api_v1_business_knowledge_search_post
      parameters:
        - name: query
          in: query
          required: true
          schema:
            type: string
            description: Search text to match against knowledge source content.
            title: Query
        - name: top_k
          in: query
          required: false
          schema:
            type: integer
            description: Maximum number of matched chunks to return.
            default: 5
            title: Top K
        - name: generate_answer
          in: query
          required: false
          schema:
            type: boolean
            description: >-
              If True, also return a generated answer; if False, return raw
              matched chunks only.
            default: true
            title: Generate Answer
        - name: x-project-id
          in: header
          required: true
          schema:
            type: string
            format: uuid
            description: Project ID for tenant scoping
            title: X-Project-Id
          description: Project ID for tenant scoping
        - name: X-Workspace-Id
          in: header
          required: false
          schema:
            anyOf:
              - type: string
                format: uuid
              - type: 'null'
            description: Overrides the key's workspace
            title: X-Workspace-Id
          description: Overrides the key's workspace
        - name: X-API-Key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: User API key
            title: X-Api-Key
          description: User API key
      requestBody:
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/Body_search_knowledge_api_v1_business_knowledge_search_post
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QueryResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    Body_search_knowledge_api_v1_business_knowledge_search_post:
      properties:
        source_ids:
          anyOf:
            - items:
                type: string
                format: uuid
              type: array
            - type: 'null'
          title: Source Ids
        folder_ids:
          anyOf:
            - items:
                type: string
                format: uuid
              type: array
            - type: 'null'
          title: Folder Ids
        tag_ids:
          anyOf:
            - items:
                type: string
                format: uuid
              type: array
            - type: 'null'
          title: Tag Ids
        workflow_status:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Workflow Status
      type: object
      title: Body_search_knowledge_api_v1_business_knowledge_search_post
    QueryResponse:
      properties:
        query_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Query Id
        chunks:
          items:
            $ref: '#/components/schemas/Chunk'
          type: array
          title: Chunks
          default: []
        citations:
          items:
            $ref: '#/components/schemas/Citation'
          type: array
          title: Citations
          default: []
        answer:
          anyOf:
            - type: string
            - type: 'null'
          title: Answer
        reasoning:
          type: string
          title: Reasoning
          default: ''
        usage_instruction:
          type: string
          title: Usage Instruction
          default: ''
        strategy:
          type: string
          title: Strategy
          default: SIMPLE
        leafmerger_rolled_up:
          type: boolean
          title: Leafmerger Rolled Up
          default: false
        bm25_fired:
          type: boolean
          title: Bm25 Fired
          default: false
        cache_hit:
          type: boolean
          title: Cache Hit
          default: false
      type: object
      title: QueryResponse
      description: Retrieval response. `answer` is null in chunks-only mode.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    Chunk:
      properties:
        node_id:
          type: string
          format: uuid
          title: Node Id
        document_id:
          type: string
          format: uuid
          title: Document Id
        text:
          type: string
          title: Text
        cert_score:
          type: number
          title: Cert Score
        fusion_score:
          type: number
          title: Fusion Score
        layer:
          type: string
          title: Layer
        cluster_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Cluster Id
      type: object
      required:
        - node_id
        - document_id
        - text
        - cert_score
        - fusion_score
        - layer
      title: Chunk
    Citation:
      properties:
        source_id:
          type: string
          format: uuid
          title: Source Id
        node_id:
          type: string
          format: uuid
          title: Node Id
        text_excerpt:
          type: string
          title: Text Excerpt
        score:
          type: number
          title: Score
      type: object
      required:
        - source_id
        - node_id
        - text_excerpt
        - score
      title: Citation
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````