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

# 从手机请求较早的聊天记录

> 在需要时询问电话是否有新的聊天信息 (WhatsApp Web 在滚动/"加载旧消息"时做了什么)。 请求基于当前本地存储的最旧的消息，所以聊天必须已经有至少一个存储的消息。 手机异常回答一个历史同步事件，该事件将持续到聊天存储。 此端点仅确认请求已发送，它不会直接返回旧消息。



## OpenAPI

````yaml /zh/openapi.yml post /chat/{chat_jid}/history
openapi: 3.0.0
info:
  title: WhatsApp API 多设备
  version: 9.7.0
  description: |
    此 API 用于通过 API 发送什么应用。

    Web 仪表板是一个单独的项目(gowa-ui)； 服务器下载它的
    最新版本资产并在 `/` 处服务(或在
    APP_UI_ENABLED=false时返回一个 JSON 横幅)。

    设备范围：
    - 在所有设备范围的REST 调用上发送 `X-Device-Id` 。
    - WebSocket: 连接到"/w?device_id=<id>`.
    - WebSocket 身份验证（启用基本身份验证时）：浏览器无法为
      WebSocket 连接设置 Authorization 请求头，因此还需在
      查询字符串中传入 `&authorization=<base64(user:pass)>`。 在
      生产中使用TLS ，因为凭据在 URL 中可见。
servers:
  - url: http://localhost:3000
security:
  - basicAuth: []
tags:
  - name: app
    description: 初始连接到 Whatsapp 服务器
  - name: device
    description: 多设备支持的设备管理
  - name: user
    description: 获取信息
  - name: send
    description: 发送消息 (Text/Image/File/Video)。
  - name: message
    description: 消息操作 (撤销/react/update)。
  - name: call
    description: 通话管理 (拒绝来电)
  - name: chat
    description: 聊天对话和消息
  - name: group
    description: 组设置
  - name: newsletter
    description: 通讯设置
  - name: chatwoot
    description: 客户支持的聊天窗口集成
paths:
  /chat/{chat_jid}/history:
    post:
      tags:
        - chat
      summary: 从手机请求较早的聊天记录
      description: >-
        在需要时询问电话是否有新的聊天信息 (WhatsApp Web 在滚动/"加载旧消息"时做了什么)。
        请求基于当前本地存储的最旧的消息，所以聊天必须已经有至少一个存储的消息。 手机异常回答一个历史同步事件，该事件将持续到聊天存储。
        此端点仅确认请求已发送，它不会直接返回旧消息。
      operationId: requestChatHistory
      parameters:
        - $ref: '#/components/parameters/DeviceIdHeader'
        - in: path
          name: chat_jid
          schema:
            type: string
          required: true
          description: >-
            聊天 JID (e.g. phone@s.whatsapp.net for individ或groupid@g.us for
            group). 接受百分比编码值(如组%40g.us)。
          example: 6289685028129@s.whatsapp.net
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                count:
                  type: integer
                  default: 50
                  minimum: 0
                  maximum: 500
                  example: 50
                  description: 从手机请求的较旧消息数量。 省略它，或发送 0，使用默认的50。
      responses:
        '200':
          description: 好的
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RequestChatHistoryResponse'
        '400':
          description: 错误的请求(例如缺少聊天_jid，计数超出范围，或者聊天没有存储的消息可以定位)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBadRequest'
        '401':
          description: 未授权
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorUnauthorized'
        '500':
          description: 服务器内部错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorInternalServer'
components:
  parameters:
    DeviceIdHeader:
      name: X-Device-Id
      in: header
      required: false
      description: |
        多设备支持的设备标识符。 当多个设备被注册时需要.
        如果只有一个设备被注册，它将被用作默认。
        也可以以 `device_id` 查询参数提供。
      schema:
        type: string
        example: my-device-id
  schemas:
    RequestChatHistoryResponse:
      type: object
      properties:
        status:
          type: integer
          example: 200
        code:
          type: string
          example: SUCCESS
        message:
          type: string
          example: History sync requested successfully
        results:
          type: object
          properties:
            status:
              type: string
              example: requested
            chat_jid:
              type: string
              example: 6289685028129@s.whatsapp.net
            requested_count:
              type: integer
              example: 50
            anchor_message_id:
              type: string
              example: 3EB0C767D82B0A0D1234
            anchor_timestamp:
              type: string
              format: date-time
              example: '2026-05-16T08:00:00Z'
    ErrorBadRequest:
      type: object
      properties:
        code:
          type: string
          example: 400
          description: HTTP 状态代码
        message:
          type: string
          example: field cannot be blank
          description: 详细错误消息
        results:
          type: object
          example: null
          description: 附加数据
    ErrorUnauthorized:
      type: object
      properties:
        code:
          type: string
          example: 401
          description: HTTP 状态代码
        message:
          type: string
          example: Unauthorized access
          description: 详细错误消息
        results:
          type: object
          example: null
          description: 附加数据
    ErrorInternalServer:
      type: object
      properties:
        code:
          type: string
          example: INTERNAL_SERVER_ERROR
          description: SYSTEM_CODE_ERROR
        message:
          type: string
          example: you are not loggin
          description: 详细错误消息
        results:
          type: object
          example: null
          description: 附加数据
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic

````

## Related topics

- [正在接收消息](https://gowa-docs.mintlify.site/zh/examples/receiving-messages.md)
- [聊天woot 集成](https://gowa-docs.mintlify.site/zh/integrations/chatwoot.md)
- [获取待定密码配对状态](https://gowa-docs.mintlify.site/zh/api-reference/app/获取待定密码配对状态.md)
- [从指定的聊天室获取消息](https://gowa-docs.mintlify.site/zh/api-reference/chat/从指定的聊天室获取消息.md)
- [每台设备聊天woot webhook 端点](https://gowa-docs.mintlify.site/zh/api-reference/chatwoot/每台设备聊天woot-webhook-端点.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.