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

# Context Search

> Endpoint to search contexts with flexible filtering options and smart word-based matching.
Note: Only returns contexts matching the criteria and does not include the description field.

Args:
    query (Optional[str]): Search query to match against name, summary, type, and description.
                           Splits into words and matches if ANY word is found.
    type (Optional[str]): Filter contexts by specific type.
    status (Optional[str]): Filter by status (default: "active").
    max_results (int): Maximum number of results to return (default: 5).

Returns:
    List[ContextListItem]: A list of `ContextListItem` model instances matching the search criteria,
                           sorted by relevance score (number of matching words).

Raises:
    HTTPException 500: If an error occurs while retrieving contexts from the database.

Examples:
    - /context/search?query=keyword - Search for "keyword" in name, summary, type
    - /context/search?type=Skill - Filter by type "Skill"
    - /context/search?query=api&type=Tool - Search for "api" within "Tool" type
    - /context/search?status=disabled&max_results=10 - Get top 10 disabled contexts



## OpenAPI

````yaml get /api/context/search
openapi: 3.1.0
info:
  title: Apigene
  description: Apigene API
  version: 1.0.0
  contact:
    name: Apigene Support
    url: https://app.apigene.ai
    email: support@apigene.ai
servers:
  - url: https://app.apigene.ai
security:
  - BearerAuth: []
paths:
  /api/context/search:
    get:
      tags:
        - Context
      summary: Context Search
      description: >-
        Endpoint to search contexts with flexible filtering options and smart
        word-based matching.

        Note: Only returns contexts matching the criteria and does not include
        the description field.


        Args:
            query (Optional[str]): Search query to match against name, summary, type, and description.
                                   Splits into words and matches if ANY word is found.
            type (Optional[str]): Filter contexts by specific type.
            status (Optional[str]): Filter by status (default: "active").
            max_results (int): Maximum number of results to return (default: 5).

        Returns:
            List[ContextListItem]: A list of `ContextListItem` model instances matching the search criteria,
                                   sorted by relevance score (number of matching words).

        Raises:
            HTTPException 500: If an error occurs while retrieving contexts from the database.

        Examples:
            - /context/search?query=keyword - Search for "keyword" in name, summary, type
            - /context/search?type=Skill - Filter by type "Skill"
            - /context/search?query=api&type=Tool - Search for "api" within "Tool" type
            - /context/search?status=disabled&max_results=10 - Get top 10 disabled contexts
      operationId: context_search
      parameters:
        - name: query
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Search query for name, summary, or type
            title: Query
          description: Search query for name, summary, or type
        - name: type
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Filter by context type
            title: Type
          description: Filter by context type
        - name: status
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Filter by status (active/disabled)
            default: active
            title: Status
          description: Filter by status (active/disabled)
        - name: max_results
          in: query
          required: false
          schema:
            type: integer
            description: Maximum number of results to return
            default: 5
            title: Max Results
          description: Maximum number of results to return
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ContextListItem'
                title: Response Context Search
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - BearerAuth: []
components:
  schemas:
    ContextListItem:
      properties:
        id:
          type: string
          title: Id
          description: Unique identifier for the context
        name:
          type: string
          title: Name
          description: Name of the context
        apps:
          items:
            type: string
          type: array
          title: Apps
          description: List of associated apps
          default: []
        summary:
          type: string
          title: Summary
          description: A short summary about the context
          default: ''
        when_to_use:
          type: string
          title: When To Use
          description: A short summary explaining to LLM when to apply the context
          default: ''
        type:
          type: string
          title: Type
          description: A string to classify the context type
          default: ''
        status:
          type: string
          title: Status
          description: 'Status of the context: active or disabled'
          default: active
        created_by:
          type: string
          title: Created By
          description: User who created the context
        created_at:
          type: string
          format: date-time
          title: Created At
          description: The date and time when the context was created.
        updated_at:
          type: string
          format: date-time
          title: Updated At
          description: The date and time when the context was last updated.
      type: object
      required:
        - id
        - name
        - created_by
        - created_at
        - updated_at
      title: ContextListItem
    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
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        JWT Authorization header using the Bearer scheme. Example:
        'Authorization: Bearer {token}'

````