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

# Get Search History

> Fetch past search queries for the authenticated user.

Args:
    limit: Maximum number of queries to return (default 100)
    filter_days: Only return queries from the last N days (optional)

Returns:
    SearchHistoryResponse with list of search queries, ordered by most recent first.

<Info>
  **Required permission:** Search — Read (`read:search`), which `basic` includes, so any signed-in user has it.
  A limited [Personal Access Token](/developers/overview#personal-access-tokens) needs the Search — Read scope.
</Info>

<Note>
  Returns only the calling user's own queries, most recent first,
  and only those sent through [Handle Send Search Message](/developers/api_reference/search/handle_send_search_message)
  — chat messages and `POST /search` calls are not recorded here. A `limit` outside 1–1000,
  or a `filter_days` of zero or less, is rejected with `400`.
</Note>


## OpenAPI

````yaml GET /search/search-history
openapi: 3.1.0
info:
  title: Onyx API
  description: Onyx API for AI-powered enterprise search and chat
  version: Development
servers:
  - url: https://cloud.onyx.app/api
security: []
paths:
  /search/search-history:
    get:
      tags:
        - public
      summary: Get Search History
      description: |-
        Fetch past search queries for the authenticated user.

        Args:
            limit: Maximum number of queries to return (default 100)
            filter_days: Only return queries from the last N days (optional)

        Returns:
            SearchHistoryResponse with list of search queries, ordered by most recent first.
      operationId: get_search_history
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            default: 100
            title: Limit
          description: Maximum number of queries to return, from 1 to 1000.
        - name: filter_days
          in: query
          required: false
          schema:
            anyOf:
              - type: integer
              - type: 'null'
            title: Filter Days
          description: Only return queries from the last N days. Omit for no time limit.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchHistoryResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - BearerAuth: []
components:
  schemas:
    SearchHistoryResponse:
      properties:
        search_queries:
          items:
            $ref: '#/components/schemas/SearchQueryResponse'
          type: array
          title: Search Queries
      type: object
      required:
        - search_queries
      title: SearchHistoryResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    SearchQueryResponse:
      properties:
        query:
          type: string
          title: Query
          description: The query as the user typed it.
        query_expansions:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Query Expansions
          description: >-
            Extra keyword queries generated for this search, or `null` when
            expansion was not run.
        created_at:
          type: string
          format: date-time
          title: Created At
          description: When the query was run.
      type: object
      required:
        - query
        - query_expansions
        - created_at
      title: SearchQueryResponse
    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
      description: Authorization header with Bearer token

````