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

# Search Chat History

> Perform raw semantic search across all imported chat conversations. Returns matched chunks with scores and surrounding context. For most use cases, use the Recall endpoint (`POST /api/chat-history/inject`) instead — it performs search and AI synthesis in one step.

## Overview

Perform semantic search across all imported chat conversations. This endpoint uses hybrid vector + keyword search with AI reranking for high relevance results.

### How it works

1. Your query is embedded and compared against all conversation chunks using vector similarity
2. Results are enriched with surrounding context messages
3. An AI reranker scores and orders results by relevance (can be skipped for faster responses)

### Example

```bash theme={null}
curl -X POST https://www.memoryplugin.com/api/chat-history/search \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "how to set up authentication",
    "limit": 10,
    "provider": "all"
  }'
```


## OpenAPI

````yaml POST /api/chat-history/search
openapi: 3.1.0
info:
  title: MemoryPlugin
  version: 1.0.0
  description: API for managing and querying user memories
servers:
  - url: https://www.memoryplugin.com
security: []
paths:
  /api/chat-history/search:
    post:
      summary: Search chat history (raw)
      description: >-
        Perform raw semantic search across all imported chat conversations.
        Returns matched chunks with scores and surrounding context. For most use
        cases, use the Recall endpoint (`POST /api/chat-history/inject`) instead
        — it performs search and AI synthesis in one step.
      operationId: SearchChatHistory
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatHistorySearchInput'
      responses:
        '200':
          description: Search results
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatHistorySearchResponse'
        '400':
          description: Invalid parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    ChatHistorySearchInput:
      type: object
      properties:
        query:
          type: string
          description: >-
            The search query. Semantic search is performed across all imported
            conversations.
          example: how to set up authentication
        limit:
          type: integer
          default: 20
          minimum: 1
          maximum: 100
          description: Maximum number of results to return.
        provider:
          type: string
          default: all
          description: >-
            Filter results by platform. 'all' searches everything, or specify a
            platform ID (e.g., 'chatgpt', 'claude', 'custom').
        contextChunks:
          type: integer
          default: 4
          description: >-
            Number of surrounding message chunks to include for context around
            each result.
        skipRerank:
          type: boolean
          default: false
          description: >-
            Skip the AI reranking step. Faster but potentially less relevant
            ordering.
      required:
        - query
    ChatHistorySearchResponse:
      type: object
      properties:
        results:
          type: array
          items:
            type: object
            properties:
              conversationId:
                type: string
                description: Internal conversation ID.
              title:
                type: string
                description: Conversation title.
              text:
                type: string
                description: The matched text chunk.
              score:
                type: number
                description: Relevance score.
              timestamp:
                type: string
                format: date-time
                description: When the matched message was sent.
              sender:
                type: string
                enum:
                  - human
                  - assistant
                description: Who sent the matched message.
              context:
                type: array
                items:
                  type: object
                  properties:
                    text:
                      type: string
                    sender:
                      type: string
                    timestamp:
                      type: string
                description: Surrounding messages for context.
        totalResults:
          type: integer
          description: Total number of results found.
        query:
          type: string
          description: The original query.
        provider:
          type: string
          description: Platform filter applied.
        processingTime:
          type: integer
          description: Time taken in milliseconds.
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
        text:
          type: string
        score:
          type: number
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````