> ## 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.

# 获取聊天列表

> 获取包含基本信息的聊天对话列表



## OpenAPI

````yaml /zh/openapi.yml get /chats
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:
  /chats:
    get:
      tags:
        - chat
      summary: 获取聊天列表
      description: 获取包含基本信息的聊天对话列表
      operationId: listChats
      parameters:
        - $ref: '#/components/parameters/DeviceIdHeader'
        - name: limit
          in: query
          schema:
            type: integer
            default: 25
            maximum: 100
          description: 要返回的最大聊天数
        - name: offset
          in: query
          schema:
            type: integer
            default: 0
          description: 要跳过的聊天数 (用于分页)
        - name: search
          in: query
          schema:
            type: string
          description: 按名称搜索聊天
        - name: has_media
          in: query
          schema:
            type: boolean
            default: false
          description: 过滤包含媒体消息的聊天
        - name: archived
          in: query
          schema:
            type: boolean
          description: 按存档状态过滤。 true = 仅存档, false = 非存档。 不要退回所有聊天。
      responses:
        '200':
          description: 好的
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatListResponse'
        '400':
          description: 错误请求
          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:
    ChatListResponse:
      type: object
      properties:
        code:
          type: string
          example: SUCCESS
        message:
          type: string
          example: Success get chat list
        results:
          type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/Chat'
            pagination:
              type: object
              properties:
                limit:
                  type: integer
                  example: 25
                offset:
                  type: integer
                  example: 0
                total:
                  type: integer
                  example: 150
    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: 附加数据
    Chat:
      type: object
      properties:
        jid:
          type: string
          example: 6289685028129@s.whatsapp.net
          description: 聊天JID 标识符
        name:
          type: string
          example: John Doe
          description: 聊天显示名称
        last_message_time:
          type: string
          format: date-time
          example: '2024-01-15T10:30:00Z'
          description: 最后消息的时间戳
        ephemeral_expiration:
          type: integer
          example: 0
          description: 短信过期时间（以秒计） (0=禁用)
        created_at:
          type: string
          format: date-time
          example: '2024-01-10T08:00:00Z'
          description: 聊天创建时间戳
        updated_at:
          type: string
          format: date-time
          example: '2024-01-15T10:30:00Z'
          description: 聊天最后更新时间戳
        archived:
          type: boolean
          example: false
          description: 聊天是否已存档
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic

````

## Related topics

- [获取聊天窗口同步进度](https://gowa-docs.mintlify.site/zh/api-reference/chatwoot/获取聊天窗口同步进度.md)
- [固定或取消置顶聊天](https://gowa-docs.mintlify.site/zh/api-reference/chat/固定或取消置顶聊天.md)
- [归档或取消归档聊天](https://gowa-docs.mintlify.site/zh/api-reference/chat/归档或取消归档聊天.md)
- [获取用户联系人列表](https://gowa-docs.mintlify.site/zh/api-reference/user/获取用户联系人列表.md)
- [从指定的聊天室获取消息](https://gowa-docs.mintlify.site/zh/api-reference/chat/从指定的聊天室获取消息.md)


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