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

# Search knowledge-base chunks

> Find document chunks relevant to a query.

Supply a text `query`, optional document UUIDs, and a result limit (default 5, maximum 50). `min_similarity` ranges from 0 to 1. Search requires a configured embedding provider and documents processed for chunked retrieval.

The response contains chunks, the query, and `total_results`. No matches is a valid result. Full-document attachments do not imply searchable chunks exist.


## OpenAPI

````yaml POST /api/v1/knowledge-base/search
openapi: 3.1.0
info:
  title: Bandwidth Agent Builder API
  version: v1
  description: >-
    Manage agents, place calls, and retrieve conversation results in your
    workspace.
servers:
  - url: https://agents.labs.bandwidth.com
    description: Workspace API
security: []
paths:
  /api/v1/knowledge-base/search:
    post:
      tags:
        - knowledge-base
      summary: Search knowledge-base chunks
      description: >-
        **Authorization:** Accepts a Labs OAuth bearer token or a Labs API key.
        Workspace-scoped resources require membership in the requested
        workspace.


        Find document chunks relevant to a query.
      operationId: search_chunks_api_v1_knowledge_base_search_post
      parameters:
        - description: >-
            Required with X-BW-LABS-AGENTS-API-KEY: the positive local workspace
            ID to access. The key owner must be a current member. Missing or
            invalid IDs return 400; non-member workspaces return 403. Not
            required for bearer authentication, which uses the user's selected
            workspace.
          in: header
          name: X-VOAI-ORGANIZATION-ID
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              Required with X-BW-LABS-AGENTS-API-KEY: the positive local
              workspace ID to access. The key owner must be a current member.
              Missing or invalid IDs return 400; non-member workspaces return
              403. Not required for bearer authentication, which uses the user's
              selected workspace.
            title: X-Voai-Organization-Id
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChunkSearchRequestSchema'
            example:
              query: How do I reschedule an appointment?
              limit: 5
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChunkSearchResponseSchema'
          description: Successful Response
        '400':
          description: Invalid request or missing/invalid workspace header with an API key.
        '401':
          description: Missing, invalid, or expired credential.
        '403':
          description: >-
            The account lacks access to the workspace, resource, or required
            role.
        '404':
          description: Not found
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Validation Error
      security:
        - LabsAuth: []
        - LabsApiKey: []
components:
  schemas:
    ChunkSearchRequestSchema:
      properties:
        document_uuids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Document Uuids
        limit:
          default: 5
          maximum: 50
          minimum: 1
          title: Limit
          type: integer
        min_similarity:
          anyOf:
            - maximum: 1
              minimum: 0
              type: number
            - type: 'null'
          title: Min Similarity
        query:
          title: Query
          type: string
      required:
        - query
      title: ChunkSearchRequestSchema
      type: object
    ChunkSearchResponseSchema:
      properties:
        chunks:
          items:
            $ref: '#/components/schemas/ChunkResponseSchema'
          title: Chunks
          type: array
        query:
          title: Query
          type: string
        total_results:
          title: Total Results
          type: integer
      required:
        - chunks
        - query
        - total_results
      title: ChunkSearchResponseSchema
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    ChunkResponseSchema:
      properties:
        chunk_index:
          title: Chunk Index
          type: integer
        chunk_metadata:
          additionalProperties: true
          title: Chunk Metadata
          type: object
        chunk_text:
          title: Chunk Text
          type: string
        contextualized_text:
          anyOf:
            - type: string
            - type: 'null'
          title: Contextualized Text
        document_id:
          title: Document Id
          type: integer
        document_uuid:
          title: Document Uuid
          type: string
        filename:
          title: Filename
          type: string
        id:
          title: Id
          type: integer
        similarity:
          title: Similarity
          type: number
      required:
        - id
        - document_id
        - chunk_text
        - contextualized_text
        - chunk_index
        - chunk_metadata
        - filename
        - document_uuid
        - similarity
      title: ChunkResponseSchema
      type: object
    ValidationError:
      properties:
        ctx:
          title: Context
          type: object
        input:
          title: Input
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          title: Location
          type: array
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
      type: object
  securitySchemes:
    LabsAuth:
      description: >-
        Bandwidth Labs OAuth access token. Uses the user's selected workspace;
        the workspace header is not required. Do not also send an API key.
        Bearer-only operations may additionally require the Labs `super_user`
        role.
      scheme: bearer
      type: http
    LabsApiKey:
      description: >-
        Bandwidth Labs API key. Also send `X-VOAI-ORGANIZATION-ID` with a
        positive local workspace ID belonging to the key owner. Access follows
        the owner's current workspace role. Do not also send a bearer token. API
        keys cannot access bearer-only or Labs `super_user` operations.
      in: header
      name: X-BW-LABS-AGENTS-API-KEY
      type: apiKey

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.