> ## 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}/messages/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}/messages/search:
    get:
      tags:
        - AgentMail
      summary: 搜索消息
      description: |-
        对收件箱中的消息执行全文搜索，并按相关性排序。查询将
        与发件人、收件人和主题（子字符串）
        以及消息正文（词元化全文）进行匹配。垃圾邮件、已删除、已屏蔽和
        未经身份验证的消息始终会被排除。`limit` 不能超过 100。
      operationId: get_agentmail_inboxes_inbox_id_messages_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_messages_SearchMessagesResponse'
        '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_messages_SearchMessagesResponse:
      type: object
      properties:
        count:
          $ref: '#/components/schemas/type__Count'
        limit:
          $ref: '#/components/schemas/type__Limit'
        next_page_token:
          $ref: '#/components/schemas/type__PageToken'
        messages:
          type: array
          items:
            $ref: '#/components/schemas/type_messages_SearchMessageItem'
          description: 按相关性排序，最佳匹配项优先。
      required:
        - count
        - messages
      title: SearchMessagesResponse
    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_messages_SearchMessageItem:
      type: object
      properties:
        inbox_id:
          $ref: '#/components/schemas/type_inboxes_InboxId'
        thread_id:
          $ref: '#/components/schemas/type_threads_ThreadId'
        message_id:
          $ref: '#/components/schemas/type_messages_MessageId'
        labels:
          $ref: '#/components/schemas/type_messages_MessageLabels'
        timestamp:
          $ref: '#/components/schemas/type_messages_MessageTimestamp'
        from:
          $ref: '#/components/schemas/type_messages_MessageFrom'
        to:
          $ref: '#/components/schemas/type_messages_MessageTo'
        cc:
          $ref: '#/components/schemas/type_messages_MessageCc'
        bcc:
          $ref: '#/components/schemas/type_messages_MessageBcc'
        subject:
          $ref: '#/components/schemas/type_messages_MessageSubject'
        preview:
          $ref: '#/components/schemas/type_messages_MessagePreview'
        attachments:
          $ref: '#/components/schemas/type_messages_MessageAttachments'
        in_reply_to:
          $ref: '#/components/schemas/type_messages_MessageInReplyTo'
        references:
          $ref: '#/components/schemas/type_messages_MessageReferences'
        headers:
          $ref: '#/components/schemas/type_messages_MessageHeaders'
        size:
          $ref: '#/components/schemas/type_messages_MessageSize'
        updated_at:
          $ref: '#/components/schemas/type_messages_MessageUpdatedAt'
        created_at:
          $ref: '#/components/schemas/type_messages_MessageCreatedAt'
        highlights:
          $ref: '#/components/schemas/type_messages_SearchMessageHighlights'
          description: 每个字段中匹配的片段。仅当查询匹配索引字段时存在。
      required:
        - inbox_id
        - thread_id
        - message_id
        - labels
        - timestamp
        - from
        - to
        - size
        - updated_at
        - created_at
      title: SearchMessageItem
    type__ErrorName:
      type: string
      description: 错误名称。
      title: ErrorName
    type__ErrorMessage:
      type: string
      description: 错误消息。
      title: ErrorMessage
    type_threads_ThreadId:
      type: string
      description: 会话 ID。
      title: ThreadId
    type_messages_MessageId:
      type: string
      description: 消息 ID。
      title: MessageId
    type_messages_MessageLabels:
      type: array
      items:
        type: string
      description: 消息标签。
      title: MessageLabels
    type_messages_MessageTimestamp:
      type: string
      format: date-time
      description: 消息的发送或起草时间。
      title: MessageTimestamp
    type_messages_MessageFrom:
      type: string
      description: 发件人地址。格式为 `username@domain.com` 或 `Display Name <username@domain.com>`。
      title: MessageFrom
    type_messages_MessageTo:
      type: array
      items:
        type: string
      description: 收件人地址。格式为 `username@domain.com` 或 `Display Name <username@domain.com>`。
      title: MessageTo
    type_messages_MessageCc:
      type: array
      items:
        type: string
      description: >-
        抄送收件人的地址。格式为 `username@domain.com` 或 `Display Name
        <username@domain.com>`。
      title: MessageCc
    type_messages_MessageBcc:
      type: array
      items:
        type: string
      description: >-
        BCC 收件人的地址。格式为 `username@domain.com` 或 `Display Name
        <username@domain.com>`。
      title: MessageBcc
    type_messages_MessageSubject:
      type: string
      description: 消息主题。
      title: MessageSubject
    type_messages_MessagePreview:
      type: string
      description: 消息文本预览。
      title: MessagePreview
    type_messages_MessageAttachments:
      type: array
      items:
        $ref: '#/components/schemas/type_attachments_Attachment'
      description: 消息中的附件。
      title: MessageAttachments
    type_messages_MessageInReplyTo:
      type: string
      description: 被回复消息的 ID。
      title: MessageInReplyTo
    type_messages_MessageReferences:
      type: array
      items:
        type: string
      description: 会话串中先前消息的 ID。
      title: MessageReferences
    type_messages_MessageHeaders:
      type: object
      additionalProperties:
        type: string
      description: 消息中的标头。
      title: MessageHeaders
    type_messages_MessageSize:
      type: integer
      description: 消息大小（以字节为单位）。
      title: MessageSize
    type_messages_MessageUpdatedAt:
      type: string
      format: date-time
      description: 消息最后更新的时间。
      title: MessageUpdatedAt
    type_messages_MessageCreatedAt:
      type: string
      format: date-time
      description: 消息的创建时间。
      title: MessageCreatedAt
    type_messages_SearchMessageHighlights:
      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: SearchMessageHighlights
    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

````