# Search for similar chunks

> POST /api/v1/knowledge-base/search — request parameters and responses from the Menace Voice API schema.

`POST /api/v1/knowledge-base/search`

{/* Generated by scripts/sync_docs_api.mjs. Edit the API schema source to change the contract. */}

See [authentication](/api-reference/authentication) for workspace API access. Public embed and artifact endpoints use their documented session or access tokens.

## API contract for documentation tools

Generated from the OpenAPI schema. Do not infer a different parameter type from an example. Authentication headers are alternatives as explained in the authentication guide.

### Parameters

| Name | Location | Type | Required | Description and constraints |
| --- | --- | --- | --- | --- |
| authorization | header | string or null | no |  |
| X-API-Key | header | string or null | no |  |

### Request body: application/json

Required body. Schema: ChunkSearchRequestSchema (object).

| Field | Type | Required | Description and constraints |
| --- | --- | --- | --- |
| query | string | yes | Search query text |
| limit | integer | no | Maximum number of results default: 5; minimum: 1; maximum: 50 |
| document_uuids | array of string or null | no | Filter by specific document UUIDs |
| min_similarity | number or null | no | Minimum similarity threshold |

### Response 200

Successful Response

application/json: ChunkSearchResponseSchema (object).

| Field | Type | Required | Description and constraints |
| --- | --- | --- | --- |
| chunks | array of ChunkResponseSchema (object) | yes |  |
| query | string | yes |  |
| total_results | integer | yes |  |

### Response 404

Not found

### Response 422

Validation Error

application/json: HTTPValidationError (object).

| Field | Type | Required | Description and constraints |
| --- | --- | --- | --- |
| detail | array of ValidationError (object) | no |  |

## OpenAPI

````yaml api-reference/openapi.json post /api/v1/knowledge-base/search
openapi: 3.1.0
info:
  title: Menace Voice API
  description: API for Menace Voice agents
  version: 1.0.0
servers:
  - url: https://voice.menaceui.com
    description: Production
  - url: http://localhost:8000
    description: Local development
paths:
  /api/v1/knowledge-base/search:
    post:
      tags:
        - main
        - knowledge-base
      summary: Search for similar chunks
      description: |-
        Search for document chunks similar to the query.

        This endpoint uses vector similarity search to find relevant chunks.
        Results are returned without threshold filtering - apply similarity
        thresholds at the application layer after optional reranking.

        Access Control:
        * Users can only search documents from their organization.
      operationId: search_chunks_api_v1_knowledge_base_search_post
      parameters:
        - name: authorization
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: "null"
            title: Authorization
        - name: X-API-Key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: "null"
            title: X-Api-Key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ChunkSearchRequestSchema"
      responses:
        "200":
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ChunkSearchResponseSchema"
        "404":
          description: Not found
        "422":
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HTTPValidationError"
components:
  schemas:
    ChunkResponseSchema:
      properties:
        id:
          type: integer
          title: Id
        document_id:
          type: integer
          title: Document Id
        chunk_text:
          type: string
          title: Chunk Text
        contextualized_text:
          anyOf:
            - type: string
            - type: "null"
          title: Contextualized Text
        chunk_index:
          type: integer
          title: Chunk Index
        chunk_metadata:
          additionalProperties: true
          type: object
          title: Chunk Metadata
        filename:
          type: string
          title: Filename
        document_uuid:
          type: string
          title: Document Uuid
        similarity:
          type: number
          title: Similarity
      type: object
      required:
        - id
        - document_id
        - chunk_text
        - contextualized_text
        - chunk_index
        - chunk_metadata
        - filename
        - document_uuid
        - similarity
      title: ChunkResponseSchema
      description: Response schema for a document chunk.
    ChunkSearchRequestSchema:
      properties:
        query:
          type: string
          title: Query
          description: Search query text
        limit:
          type: integer
          maximum: 50
          minimum: 1
          title: Limit
          description: Maximum number of results
          default: 5
        document_uuids:
          anyOf:
            - items:
                type: string
              type: array
            - type: "null"
          title: Document Uuids
          description: Filter by specific document UUIDs
        min_similarity:
          anyOf:
            - type: number
              maximum: 1
              minimum: 0
            - type: "null"
          title: Min Similarity
          description: Minimum similarity threshold
      type: object
      required:
        - query
      title: ChunkSearchRequestSchema
      description: Request schema for searching similar chunks.
    ChunkSearchResponseSchema:
      properties:
        chunks:
          items:
            $ref: "#/components/schemas/ChunkResponseSchema"
          type: array
          title: Chunks
        query:
          type: string
          title: Query
        total_results:
          type: integer
          title: Total Results
      type: object
      required:
        - chunks
        - query
        - total_results
      title: ChunkSearchResponseSchema
      description: Response schema for chunk search results.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: "#/components/schemas/ValidationError"
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    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
````
