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

# Search Ticket Messages

> Search messages across tickets with filters for team, ticket, author, author role, and creation time range. This is the single-request alternative to listing tickets and calling List Ticket Messages per ticket — e.g. all messages authored by given team members in a given week, regardless of when their tickets were opened. Searches messages on non-archived tickets the caller can view; results are ordered newest first.



## OpenAPI

````yaml /sections/api-reference/openapi-spec-v2.yaml post /v2/ticket-messages/search
openapi: 3.1.0
info:
  title: Serval Public API
  description: Serval Public API
  contact:
    name: Serval
    url: https://serval.com
    email: support@serval.com
  license:
    name: Serval License
    url: https://serval.com/license
  version: 2.0.0
servers:
  - url: https://public.api.serval.com
security:
  - BearerAuth: []
tags:
  - name: Access Policy API
  - name: Access Policy Approval Procedure API
  - name: Access Profile API
  - name: Access Relationship API
  - name: Access Request API
  - name: Agent API
  - name: App Instance API
  - name: App Resource API
  - name: App Resource Role API
  - name: Approval Delegation API
  - name: Approval Request API
  - name: Audit Log API
  - name: Change Blackout API
  - name: Change Model API
  - name: Custom Field API
  - name: Custom Service API
  - name: Entity API
  - name: Entity Field Mapping API
  - name: Entity Ingestion Config API
  - name: Entity Scan Action API
  - name: Entity Type API
  - name: Folder API
  - name: Group API
  - name: Guidance API
  - name: Help Agent API
  - name: Journey API
  - name: Knowledge API
  - name: Knowledge Base API
  - name: Report API
  - name: SLA API
  - name: Schedule API
  - name: Tag API
  - name: Team API
  - name: Team Group API
  - name: Team User API
  - name: Ticket API
  - name: Topic API
  - name: User API
  - name: User Relationship API
  - name: Workflow API
  - name: Workflow Approval Procedure API
  - name: Workflow Run API
paths:
  /v2/ticket-messages/search:
    post:
      tags:
        - Ticket API
      summary: Search Ticket Messages
      description: >-
        Search messages across tickets with filters for team, ticket, author,
        author role, and creation time range. This is the single-request
        alternative to listing tickets and calling List Ticket Messages per
        ticket — e.g. all messages authored by given team members in a given
        week, regardless of when their tickets were opened. Searches messages on
        non-archived tickets the caller can view; results are ordered newest
        first.
      operationId: svrelay.publicv2.PublicAPIServiceV2.SearchTicketMessages
      requestBody:
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/svhelp.publicapi.SearchTicketMessagesRequest
        required: true
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/svhelp.publicapi.SearchTicketMessagesResponse
      security:
        - BearerAuth: []
components:
  schemas:
    svhelp.publicapi.SearchTicketMessagesRequest:
      type: object
      properties:
        teamIds:
          type: array
          items:
            type: string
          title: team_ids
          description: |-
            Optional. Filter to messages on tickets in these teams. If not
             provided, searches all teams the caller can view tickets in.
          x-stainless-terraform-configurability: optional
        ticketIds:
          type: array
          items:
            type: string
          title: ticket_ids
          description: |-
            Optional. Only return messages on any of these tickets. This is the
             batch alternative to calling List Ticket Messages per ticket.
          x-stainless-terraform-configurability: optional
        authorUserIds:
          type: array
          items:
            type: string
          title: author_user_ids
          description: |-
            Optional. Only return messages authored by any of these users.
             Assistant and system messages have no author user and never match.
          x-stainless-terraform-configurability: optional
        authorRoles:
          type: array
          items:
            $ref: '#/components/schemas/svhelp.models.MessageAuthorRole'
          title: author_roles
          description: >-
            Optional. Filter by author roles. Returns messages matching ANY of
            the
             specified roles (e.g. USER_ROLE for human messages, INTERNAL_NOTE_ROLE
             for internal notes).
          x-stainless-terraform-configurability: optional
        createdAfter:
          oneOf:
            - $ref: '#/components/schemas/google.protobuf.Timestamp'
            - type: 'null'
          title: created_after
          description: Optional. Only include messages created at or after this time.
          x-stainless-terraform-configurability: optional
        createdBefore:
          oneOf:
            - $ref: '#/components/schemas/google.protobuf.Timestamp'
            - type: 'null'
          title: created_before
          description: Optional. Only include messages created at or before this time.
          x-stainless-terraform-configurability: optional
        pageSize:
          type:
            - integer
            - 'null'
          title: page_size
          format: int32
          description: >-
            Maximum number of results to return. Default is 100, maximum is
            1000.
          x-stainless-terraform-configurability: computed_optional
        pageToken:
          type:
            - string
            - 'null'
          title: page_token
          description: Token for pagination. Leave empty for the first request.
          x-stainless-terraform-configurability: optional
      title: SearchTicketMessagesRequest
      additionalProperties: false
    svhelp.publicapi.SearchTicketMessagesResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/svhelp.pubapimodels.Message'
          title: data
          x-stainless-terraform-configurability: optional
        nextPageToken:
          type:
            - string
            - 'null'
          title: next_page_token
          description: >-
            Token for retrieving the next page of results. Empty if no more
            results.
          x-stainless-terraform-configurability: optional
      title: SearchTicketMessagesResponse
      additionalProperties: false
    svhelp.models.MessageAuthorRole:
      type: string
      title: MessageAuthorRole
      enum:
        - USER_ROLE
        - ASSISTANT_ROLE
        - SYSTEM_INFO_ROLE
        - INTERNAL_NOTE_ROLE
    google.protobuf.Timestamp:
      type: string
      examples:
        - '2025-01-15T01:30:15.000Z'
        - '2025-06-01T00:00:00.000Z'
      format: date-time
      description: A timestamp in RFC 3339 format (e.g., "2025-01-15T01:30:15Z").
    svhelp.pubapimodels.Message:
      type: object
      properties:
        id:
          type: string
          title: id
          description: The ID of the Serval message.
          readOnly: true
          x-stainless-terraform-configurability: computed
        user:
          $ref: '#/components/schemas/svhelp.pubapimodels.User'
          title: user
          description: The user who sent the message.
          x-stainless-terraform-configurability: optional
        authorRole:
          $ref: '#/components/schemas/svhelp.models.MessageAuthorRole'
          title: author_role
          description: The role of the user who sent the message.
          x-stainless-terraform-configurability: optional
        content:
          type: string
          title: content
          description: The content of the message.
          x-stainless-terraform-configurability: optional
        createdAt:
          $ref: '#/components/schemas/google.protobuf.Timestamp'
          title: created_at
          description: The timestamp of the message.
          readOnly: true
          x-stainless-terraform-configurability: computed
        attachments:
          type: array
          items:
            $ref: '#/components/schemas/svhelp.pubapimodels.Attachment'
          title: attachments
          description: Attachments associated with the message.
          x-stainless-terraform-configurability: optional
        ticketId:
          type: string
          title: ticket_id
          description: The ID of the ticket this message belongs to.
          readOnly: true
          x-stainless-terraform-configurability: computed
      title: Message
      additionalProperties: false
    svhelp.pubapimodels.User:
      type: object
      properties:
        id:
          type: string
          title: id
          description: The ID of the Serval user.
          readOnly: true
          x-stainless-terraform-configurability: computed
        email:
          type: string
          title: email
          description: The email address of the Serval user.
          x-stainless-terraform-configurability: optional
      title: User
      additionalProperties: false
    svhelp.pubapimodels.Attachment:
      type: object
      properties:
        id:
          type: string
          title: id
          description: The unique identifier for the attachment.
          readOnly: true
          x-stainless-terraform-configurability: computed
        name:
          type: string
          title: name
          description: The name of the attachment file.
          x-stainless-terraform-configurability: optional
        contentType:
          type: string
          title: content_type
          description: >-
            The MIME type of the attachment (e.g., "image/png",
            "application/pdf").
          x-stainless-terraform-configurability: optional
        url:
          type: string
          title: url
          description: >-
            A presigned URL to download the attachment. This URL expires after
            15 minutes.
          readOnly: true
          x-stainless-terraform-configurability: computed
        isInline:
          type: boolean
          title: is_inline
          description: |-
            True for attachments that arrived as Content-Disposition: inline on
             an inbound email (typically CID-referenced images embedded in the
             HTML body). Inline attachments are also referenced from the message
             body via cid: URLs that get rewritten to fresh presigned URLs by the
             ticket-detail API.
          readOnly: true
          x-stainless-terraform-configurability: computed
        contentId:
          type: string
          title: content_id
          description: |-
            The RFC 2392 CID (Content-ID header value, brackets stripped) used
             to resolve cid: references in the message body to this attachment's
             url. Empty when the part has no Content-ID.
          readOnly: true
          x-stainless-terraform-configurability: computed
      title: Attachment
      additionalProperties: false
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````