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

# 搜索收件箱会话线程

> 使用全文查询搜索特定收件箱中的 AgentMail 会话线程。



## OpenAPI

````yaml openapi/zh/agentmail.json GET /agentmail/inboxes/{inbox_id}/threads/search
openapi: 3.1.0
info:
  title: AgentMail API
  version: 1.0.0
  description: 通过 AIsa 统一网关公开的 AgentMail 电子邮件 API 端点。改编自上游 docs.agentmail.to OpenAPI 规范。
servers:
  - url: https://api.aisa.one/apis/v1
security:
  - Bearer: []
paths:
  /agentmail/inboxes/{inbox_id}/threads/search:
    get:
      tags:
        - AgentMail
      summary: 搜索线程
      description: |-
        对收件箱中的会话进行全文搜索，并按相关性排序。
        查询会与发件人、收件人和主题（子字符串）以及
        消息正文（词元化全文）进行匹配。垃圾邮件、已删除、已屏蔽和
        未经身份验证的会话始终会被排除。`limit` 不能超过 100。
      operationId: get_agentmail_inboxes_inbox_id_threads_search
      parameters:
        - name: inbox_id
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/type_inboxes_InboxId'
        - name: q
          in: query
          required: true
          schema:
            $ref: '#/components/schemas/type__Query'
        - name: limit
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/type__Limit'
        - name: page_token
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/type__PageToken'
        - name: before
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/type__Before'
        - name: after
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/type__After'
        - name: Authorization
          in: header
          description: Bearer 身份验证
          required: true
          schema:
            type: string
      responses:
        '200':
          description: 状态码为 200 的响应
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_threads_SearchThreadsResponse'
        '400':
          description: 状态码为 400 的错误响应
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type__ValidationErrorResponse'
        '404':
          description: 状态码为 404 的错误响应
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type__ErrorResponse'
      security:
        - Bearer: []
components:
  schemas:
    type_inboxes_InboxId:
      type: string
      description: 收件箱的 ID。
      title: InboxId
    type__Query:
      type: string
      description: |-
        全文搜索查询。匹配发件人、收件人、
        主题（子字符串）和消息正文（词元化全文）。
      title: Query
    type__Limit:
      type: integer
      description: 返回项目数量的上限。
      title: Limit
    type__PageToken:
      type: string
      description: 用于分页的页面 token。
      title: PageToken
    type__Before:
      type: string
      format: date-time
      description: 用于筛选的截止时间戳。
      title: Before
    type__After:
      type: string
      format: date-time
      description: 用于筛选此时间戳之后数据的时间戳。
      title: After
    type_threads_SearchThreadsResponse:
      type: object
      properties:
        count:
          $ref: '#/components/schemas/type__Count'
        limit:
          $ref: '#/components/schemas/type__Limit'
        next_page_token:
          $ref: '#/components/schemas/type__PageToken'
        threads:
          type: array
          items:
            $ref: '#/components/schemas/type_threads_SearchThreadItem'
          description: 按相关性排序，最佳匹配项优先。
      required:
        - count
        - threads
      title: SearchThreadsResponse
    type__ValidationErrorResponse:
      type: object
      properties:
        name:
          $ref: '#/components/schemas/type__ErrorName'
        errors:
          description: 验证错误。
      required:
        - name
        - errors
      title: ValidationErrorResponse
    type__ErrorResponse:
      type: object
      properties:
        name:
          $ref: '#/components/schemas/type__ErrorName'
        message:
          $ref: '#/components/schemas/type__ErrorMessage'
      required:
        - name
        - message
      title: ErrorResponse
    type__Count:
      type: integer
      description: 返回的项目数量。
      title: Count
    type_threads_SearchThreadItem:
      type: object
      properties:
        inbox_id:
          $ref: '#/components/schemas/type_inboxes_InboxId'
        thread_id:
          $ref: '#/components/schemas/type_threads_ThreadId'
        labels:
          $ref: '#/components/schemas/type_threads_ThreadLabels'
        timestamp:
          $ref: '#/components/schemas/type_threads_ThreadTimestamp'
        received_timestamp:
          $ref: '#/components/schemas/type_threads_ThreadReceivedTimestamp'
        sent_timestamp:
          $ref: '#/components/schemas/type_threads_ThreadSentTimestamp'
        senders:
          $ref: '#/components/schemas/type_threads_ThreadSenders'
        recipients:
          $ref: '#/components/schemas/type_threads_ThreadRecipients'
        subject:
          $ref: '#/components/schemas/type_threads_ThreadSubject'
        preview:
          $ref: '#/components/schemas/type_threads_ThreadPreview'
        attachments:
          $ref: '#/components/schemas/type_threads_ThreadAttachments'
        last_message_id:
          $ref: '#/components/schemas/type_threads_ThreadLastMessageId'
        message_count:
          $ref: '#/components/schemas/type_threads_ThreadMessageCount'
        size:
          $ref: '#/components/schemas/type_threads_ThreadSize'
        updated_at:
          $ref: '#/components/schemas/type_threads_ThreadUpdatedAt'
        created_at:
          $ref: '#/components/schemas/type_threads_ThreadCreatedAt'
        highlights:
          $ref: '#/components/schemas/type_threads_SearchThreadHighlights'
          description: 每个字段中匹配的片段。仅当查询匹配索引字段时存在。
      required:
        - inbox_id
        - thread_id
        - labels
        - timestamp
        - senders
        - recipients
        - last_message_id
        - message_count
        - size
        - updated_at
        - created_at
      title: SearchThreadItem
    type__ErrorName:
      type: string
      description: 错误名称。
      title: ErrorName
    type__ErrorMessage:
      type: string
      description: 错误消息。
      title: ErrorMessage
    type_threads_ThreadId:
      type: string
      description: 会话 ID。
      title: ThreadId
    type_threads_ThreadLabels:
      type: array
      items:
        type: string
      description: 会话标签。
      title: ThreadLabels
    type_threads_ThreadTimestamp:
      type: string
      format: date-time
      description: 最后发送或接收消息的时间戳。
      title: ThreadTimestamp
    type_threads_ThreadReceivedTimestamp:
      type: string
      format: date-time
      description: 最后收到消息的时间戳。
      title: ThreadReceivedTimestamp
    type_threads_ThreadSentTimestamp:
      type: string
      format: date-time
      description: 最后发送消息的时间戳。
      title: ThreadSentTimestamp
    type_threads_ThreadSenders:
      type: array
      items:
        type: string
      description: >-
        会话中的发件人。格式为 `username@domain.com` 或 `Display Name
        <username@domain.com>`。
      title: ThreadSenders
    type_threads_ThreadRecipients:
      type: array
      items:
        type: string
      description: >-
        会话中的收件人。格式为 `username@domain.com` 或 `Display Name
        <username@domain.com>`。
      title: ThreadRecipients
    type_threads_ThreadSubject:
      type: string
      description: 会话主题。
      title: ThreadSubject
    type_threads_ThreadPreview:
      type: string
      description: 会话中最后一条消息的文本预览。
      title: ThreadPreview
    type_threads_ThreadAttachments:
      type: array
      items:
        $ref: '#/components/schemas/type_attachments_Attachment'
      description: 线程中的附件。
      title: ThreadAttachments
    type_threads_ThreadLastMessageId:
      type: string
      description: 会话串中最后一条消息的 ID。
      title: ThreadLastMessageId
    type_threads_ThreadMessageCount:
      type: integer
      description: 会话中的消息数量。
      title: ThreadMessageCount
    type_threads_ThreadSize:
      type: integer
      description: 线程大小（以字节为单位）。
      title: ThreadSize
    type_threads_ThreadUpdatedAt:
      type: string
      format: date-time
      description: 线程上次更新的时间。
      title: ThreadUpdatedAt
    type_threads_ThreadCreatedAt:
      type: string
      format: date-time
      description: 会话串的创建时间。
      title: ThreadCreatedAt
    type_threads_SearchThreadHighlights:
      type: object
      properties:
        from:
          type: array
          items:
            type: string
          description: 线程中发件人地址的匹配片段。
        recipients:
          type: array
          items:
            type: string
          description: 与会话中收件人地址（to、cc 或 bcc）匹配的片段。
        subject:
          type: array
          items:
            type: string
          description: 主题中匹配的片段。
        text:
          type: array
          items:
            type: string
          description: 线程中消息正文的匹配片段。
      description: >-
        线程搜索结果中每个字段的匹配片段，匹配的词语用 `**`
        包裹。仅当查询与某个字段匹配时，才会出现该字段键，因此已出现的键也会表明哪些字段产生了匹配结果。
      title: SearchThreadHighlights
    type_attachments_Attachment:
      type: object
      properties:
        attachment_id:
          $ref: '#/components/schemas/type_attachments_AttachmentId'
        filename:
          $ref: '#/components/schemas/type_attachments_AttachmentFilename'
        size:
          $ref: '#/components/schemas/type_attachments_AttachmentSize'
        content_type:
          $ref: '#/components/schemas/type_attachments_AttachmentContentType'
        content_disposition:
          $ref: '#/components/schemas/type_attachments_AttachmentContentDisposition'
        content_id:
          $ref: '#/components/schemas/type_attachments_AttachmentContentId'
      required:
        - attachment_id
        - size
      title: Attachment
    type_attachments_AttachmentId:
      type: string
      description: 附件 ID。
      title: AttachmentId
    type_attachments_AttachmentFilename:
      type: string
      description: 附件文件名。
      title: AttachmentFilename
    type_attachments_AttachmentSize:
      type: integer
      description: 附件大小（字节）。
      title: AttachmentSize
    type_attachments_AttachmentContentType:
      type: string
      description: 附件的内容类型。
      title: AttachmentContentType
    type_attachments_AttachmentContentDisposition:
      type: string
      enum:
        - inline
        - attachment
      description: 附件的内容处置方式。
      title: AttachmentContentDisposition
    type_attachments_AttachmentContentId:
      type: string
      description: 附件的内容 ID。
      title: AttachmentContentId
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer

````