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

# Search

> Perform a search across different contexts (Inbox, Library, Files, Clients, To-do, Plans, Community, People, or Global). Results are sorted by relevance score and saved to search history.



## OpenAPI

````yaml /api-reference/cx/swagger.json post /magic/_search
openapi: 3.0.0
info:
  description: CX API.
  title: CX API
  contact:
    name: API Support
    url: https://stax.ai
    email: support@stax.ai
  version: '1.0'
servers:
  - url: https://api.cx.stax.ai
security: []
paths:
  /magic/_search:
    post:
      tags:
        - magic
      summary: Search
      description: >-
        Perform a search across different contexts (Inbox, Library, Files,
        Clients, To-do, Plans, Community, People, or Global). Results are sorted
        by relevance score and saved to search history.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/pkg_routes_magic.SearchRequest'
        description: >-
          Search request with query, optional context, target, and search
          completed flag
        required: true
      responses:
        '200':
          description: Search results sorted by relevance
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/pkg_routes_magic.SearchResponse'
        '400':
          description: Bad request - invalid request body
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
      security:
        - ApiKeyAuth: []
components:
  schemas:
    pkg_routes_magic.SearchRequest:
      type: object
      properties:
        c:
          type: string
        q:
          type: string
        sc:
          type: boolean
        t:
          type: string
    pkg_routes_magic.SearchResponse:
      type: object
      properties:
        results:
          type: array
          items:
            $ref: '#/components/schemas/types.SearchResult'
    types.SearchResult:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/types.SearchResultData'
        highlights:
          type: array
          items:
            $ref: '#/components/schemas/types.SearchHighlight'
        score:
          type: number
        type:
          type: string
    types.SearchResultData:
      type: object
      properties:
        _id:
          type: string
        assignee:
          description: For projects
          type: string
        clients:
          description: For contacts
          type: array
          items:
            $ref: '#/components/schemas/types.ClientRole'
        date:
          type: string
        detail:
          description: Email 1-line summary, task/project description/notes, file path
          type: string
        due:
          type: string
        email:
          type: string
        flags:
          type: array
          items:
            type: string
        incomplete_projects:
          type: integer
        incomplete_tasks:
          type: integer
        name:
          type: string
        overdue_projects:
          type: integer
        overdue_tasks:
          type: integer
        parent:
          description: For files
          type: string
        person:
          description: User/contact data if available
          type: string
        pulse:
          description: For clients
          type: integer
        role:
          type: string
        size:
          type: integer
        status:
          type: string
        subject:
          description: For emails
          type: string
        subtitle:
          type: string
        tags:
          type: array
          items:
            type: string
        total_tasks:
          type: integer
        type:
          type: string
    types.SearchHighlight:
      type: object
      properties:
        path:
          type: string
        score:
          description: The score of the highlight
          type: number
        texts:
          description: The text to highlight
          type: array
          items:
            $ref: '#/components/schemas/types.SearchHighlightText'
    types.ClientRole:
      type: object
      properties:
        _id:
          type: string
        inactive:
          type: boolean
        name:
          type: string
        role:
          type: string
    types.SearchHighlightText:
      type: object
      properties:
        type:
          type: string
        value:
          type: string
  securitySchemes:
    ApiKeyAuth:
      description: CX API key. Create one in CX under Settings → Advanced → API Keys.
      in: header
      name: x-api-key
      type: apiKey

````

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