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

# Search Knowledge Base

> Search a knowledge base and return matching snippets or pages.



## OpenAPI

````yaml https://app.stainless.com/api/spec/documented/profound/openapi.documented.yml post /v1/knowledge-bases/{knowledge_base_id}/search
openapi: 3.1.0
info:
  title: External API
  version: 8a280fe080bc62612cfa4d9ac5672343e0a2f720
servers:
  - url: https://api.tryprofound.com
    description: Production Server
security: []
paths:
  /v1/knowledge-bases/{knowledge_base_id}/search:
    post:
      tags:
        - Knowledge bases
      summary: Search Knowledge Base
      description: Search a knowledge base and return matching snippets or pages.
      operationId: search_knowledge_base_v1_knowledge_bases__knowledge_base_id__search_post
      parameters:
        - name: knowledge_base_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            description: Unique knowledge base ID.
            title: Knowledge Base Id
          description: Unique knowledge base ID.
        - name: organization_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
                format: uuid
              - type: 'null'
            description: >-
              Organization scope for API keys that can access multiple
              organizations.
            title: Organization Id
          description: >-
            Organization scope for API keys that can access multiple
            organizations.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SearchKnowledgeBaseRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KnowledgeBaseSearchResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
        - BearerAuth: []
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Profound from '@profoundai/client';


            const client = new Profound({
              apiKey: process.env['PROFOUND_API_KEY'], // This is the default and can be omitted
            });


            const response = await
            client.knowledgeBases.search('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
            {
              query: 'x',
              top_k: 1,
            });


            console.log(response.data);
        - lang: Python
          source: |-
            import os
            from profound import Profound

            client = Profound(
                api_key=os.environ.get("PROFOUND_API_KEY"),  # This is the default and can be omitted
            )
            response = client.knowledge_bases.search(
                knowledge_base_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
                query="x",
                top_k=1,
            )
            print(response.data)
components:
  schemas:
    SearchKnowledgeBaseRequest:
      properties:
        query:
          type: string
          minLength: 1
          title: Query
          description: Search query.
        top_k:
          type: integer
          maximum: 100
          minimum: 1
          title: Top K
          description: Maximum number of results to return.
        return_full_page:
          type: boolean
          title: Return Full Page
          description: Return full page content instead of snippets.
          default: false
        filters:
          anyOf:
            - $ref: '#/components/schemas/SearchKnowledgeBaseFilters'
            - type: 'null'
          description: Optional search filters.
      additionalProperties: false
      type: object
      required:
        - query
        - top_k
      title: SearchKnowledgeBaseRequest
    KnowledgeBaseSearchResponse:
      properties:
        data:
          items:
            $ref: '#/components/schemas/KnowledgeBaseSearchResult'
          type: array
          title: Data
          description: Knowledge base search results.
        pagination:
          $ref: '#/components/schemas/CursorPagination'
          description: Pagination metadata.
      additionalProperties: false
      type: object
      required:
        - data
      title: KnowledgeBaseSearchResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    SearchKnowledgeBaseFilters:
      properties:
        tags:
          anyOf:
            - items:
                type: string
                minLength: 1
              type: array
              minItems: 1
            - type: 'null'
          title: Tags
          description: >-
            Optional tags to match. Documents with any matching tag are
            included.
        folders:
          anyOf:
            - items:
                type: string
                minLength: 1
              type: array
              maxItems: 1
              minItems: 1
            - type: 'null'
          title: Folders
          description: >-
            Optional folder paths to search within. Currently limited to one
            folder.
      additionalProperties: false
      type: object
      title: SearchKnowledgeBaseFilters
    KnowledgeBaseSearchResult:
      properties:
        id:
          type: string
          title: Id
          description: Document or chunk path.
        score:
          type: number
          title: Score
          description: Relevance score.
        metadata:
          additionalProperties: true
          type: object
          title: Metadata
          description: Result metadata, including folder path.
        content:
          type: string
          title: Content
          description: Matched content.
      additionalProperties: false
      type: object
      required:
        - id
        - score
        - metadata
        - content
      title: KnowledgeBaseSearchResult
    CursorPagination:
      properties:
        limit:
          type: integer
          maximum: 50000
          exclusiveMinimum: 0
          title: Limit
          description: >-
            Maximum number of results to return. Default is 10,000, maximum is
            50,000.
          default: 10000
        next_cursor:
          anyOf:
            - type: string
            - type: 'null'
          title: Next Cursor
          description: Token for the next page, if more results are available.
      additionalProperties: false
      type: object
      title: CursorPagination
      description: Cursor-based pagination metadata.
    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
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key
    BearerAuth:
      type: http
      scheme: bearer

````