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

# Search Messages

> Search for messages within a thread that contain the given text query.



## OpenAPI

````yaml /api-reference/openapi.json get /threads/{thread_id}/messages/search
openapi: 3.1.0
info:
  title: Puppeteer Core API
  description: >-
    Core API for the Puppeteer AI platform. Manages domain models,
    conversations, voice calls, simulations, and integrations.


    [Documentation](https://docs.puppeteerai.com)
  version: 1.0.0
servers:
  - url: https://api.puppeteerai.com
    description: Production
security: []
tags:
  - name: Auth
    description: JWT token generation and organization creation.
  - name: Messages
    description: >-
      Send and receive messages, retrieve conversation history, search, and
      create messages in threads.
  - name: Threads
    description: Create and manage threads, aliases, scheduled events, and bulk operations.
  - name: Voice
    description: Voice call handling, scheduling, batch calls, and WebSocket LLM.
paths:
  /threads/{thread_id}/messages/search:
    get:
      tags:
        - Messages
      summary: Search Messages
      description: Search for messages within a thread that contain the given text query.
      operationId: search_messages_threads__thread_id__messages_search_get
      parameters:
        - name: thread_id
          in: path
          required: true
          schema:
            type: string
            title: Thread Id
        - name: query
          in: query
          required: true
          schema:
            type: string
            description: The text to search for within messages.
            title: Query
          description: The text to search for within messages.
        - name: cursor
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              Base64-encoded pagination cursor. If not provided, retrieves the
              first batch of results.
            title: Cursor
          description: >-
            Base64-encoded pagination cursor. If not provided, retrieves the
            first batch of results.
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            description: Maximum number of search results to return per page.
            default: 20
            title: Limit
          description: Maximum number of search results to return per page.
        - name: context_size
          in: query
          required: false
          schema:
            type: integer
            description: >-
              Number of messages to include before and after each match to
              provide conversation context.
            default: 10
            title: Context Size
          description: >-
            Number of messages to include before and after each match to provide
            conversation context.
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
            title: Authorization
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchMessagesResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    SearchMessagesResponse:
      properties:
        matches:
          items:
            $ref: '#/components/schemas/SearchMatch'
          type: array
          title: Matches
          description: List of search matches with context.
        pagination:
          $ref: '#/components/schemas/routers__conversations__CursorPagination'
      type: object
      required:
        - matches
        - pagination
      title: SearchMessagesResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    SearchMatch:
      properties:
        message_id:
          type: string
          title: Message Id
          description: Unique identifier of the matched message.
        prev_cursor:
          anyOf:
            - type: string
            - type: 'null'
          title: Prev Cursor
          description: Cursor to navigate to later messages.
        next_cursor:
          anyOf:
            - type: string
            - type: 'null'
          title: Next Cursor
          description: Cursor to navigate to earlier messages.
        context:
          items:
            $ref: '#/components/schemas/SearchContextMessage'
          type: array
          title: Context
          description: Messages surrounding the match for context.
      type: object
      required:
        - message_id
        - prev_cursor
        - next_cursor
        - context
      title: SearchMatch
    routers__conversations__CursorPagination:
      properties:
        cursor:
          anyOf:
            - type: string
            - type: 'null'
          title: Cursor
          description: >-
            Base64-encoded cursor for the next batch of messages. Null if no
            more results.
      type: object
      required:
        - cursor
      title: CursorPagination
    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
    SearchContextMessage:
      properties:
        message_id:
          type: string
          title: Message Id
          description: Unique identifier of the message.
        role:
          type: string
          title: Role
          description: 'The role of the sender: "user", "AI", or "admin".'
        message:
          type: string
          title: Message
          description: The message text.
        timestamp:
          type: integer
          title: Timestamp
          description: Unix timestamp (seconds) when the message was sent.
        conversation_id:
          anyOf:
            - type: integer
            - type: 'null'
          title: Conversation Id
          description: Conversation ID for grouping.
        conversation_end_time:
          anyOf:
            - type: string
            - type: 'null'
          title: Conversation End Time
          description: >-
            ISO timestamp the parent conversation ended at, or null if still
            active.
      type: object
      required:
        - message_id
        - role
        - message
        - timestamp
      title: SearchContextMessage

````