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

# Search knowledge cards

> Performs a semantic vector search over all knowledge cards in the collection. Optionally applies cross-encoder reranking. Results are proxied from the FastAPI parser service and token usage is tracked.



## OpenAPI

````yaml https://staging.aigmented.io/api/v1/openapi.json post /api/v1/collections/{id}/search
openapi: 3.1.0
info:
  title: Aigmented API
  version: 1.0.0
  description: >-
    REST API for Aigmented — manage knowledge collections, upload files, search
    knowledge cards, and ask questions with LLM-powered answers.
  contact:
    name: Aigmented Support
    url: https://aigmented.com
servers:
  - url: https://aigmented.io
    description: Production
security:
  - BearerAuth: []
tags:
  - name: Collections
    description: Create and manage knowledge collections
  - name: Files
    description: Upload and manage source documents
  - name: Search
    description: Semantic search over knowledge cards in a collection
  - name: Ask
    description: LLM-powered question answering over a collection
paths:
  /api/v1/collections/{id}/search:
    post:
      tags:
        - Search
      summary: Search knowledge cards
      description: >-
        Performs a semantic vector search over all knowledge cards in the
        collection. Optionally applies cross-encoder reranking. Results are
        proxied from the FastAPI parser service and token usage is tracked.
      operationId: searchCollection
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: Collection ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SearchRequest'
            example:
              query: What are the payment terms?
              top_k: 5
              rerank: true
              current_only: false
      responses:
        '200':
          description: Search results
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResponse'
        '400':
          description: Missing or invalid parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Collection not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Team token limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenLimitError'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    SearchRequest:
      type: object
      required:
        - query
      properties:
        query:
          type: string
          description: The search query string
          example: What are the main risk factors?
        top_k:
          type: integer
          default: 10
          minimum: 1
          maximum: 100
          description: Number of results to return
        rerank:
          type: boolean
          default: false
          description: Whether to apply cross-encoder reranking to results
        current_only:
          type: boolean
          default: false
          description: Restrict search to the most current document versions only
        filters:
          type: object
          description: Optional metadata filters to narrow the search scope
          additionalProperties: true
          example:
            document_type: standard
    SearchResponse:
      type: object
      properties:
        results:
          type: array
          items:
            $ref: '#/components/schemas/SearchResultItem'
        total_results:
          type: integer
          description: Number of results returned
        query_time_ms:
          type: number
          description: Time taken to execute the search in milliseconds
        tokens_used:
          type: object
          description: Token usage breakdown
          properties:
            embedding:
              type: integer
              description: Tokens used for query embedding
            rerank:
              type: integer
              description: Tokens used for reranking (0 if rerank=false)
            model_id:
              type: string
              description: Model used for embedding/reranking
    Error:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error message
      required:
        - error
    TokenLimitError:
      type: object
      properties:
        error:
          type: string
          example: Token limit exceeded
        remaining:
          type: integer
          description: Remaining included tokens
        reason:
          type: string
          description: Reason for the limit
      required:
        - error
    SearchResultItem:
      type: object
      properties:
        id:
          type: string
          description: Unique chunk/card identifier in the vector store
        score:
          type: number
          format: float
          description: Similarity or rerank score
        content:
          type: string
          description: Text content of the matched chunk
        metadata:
          type: object
          description: Source document metadata
          properties:
            document_id:
              type: string
            file_name:
              type: string
            page:
              type: integer
            chunk_index:
              type: integer
          additionalProperties: true
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API key (sk-...)
      description: >-
        Pass your API key as a Bearer token. Example: `Authorization: Bearer
        sk-xxxxxxxxxxxx`

````