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

# 同步消息历史记录到Chatwoot

> 启动背景同步 WhatsApp 消息历史到Chatwoot
来自已配置天数的消息将被导入。
此端点需要配置中的 CHATWOOT_ENABLED=true。




## OpenAPI

````yaml /zh/openapi.yml post /chatwoot/sync
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:
  /chatwoot/sync:
    post:
      tags:
        - chatwoot
      summary: 同步消息历史记录到Chatwoot
      description: |
        启动背景同步 WhatsApp 消息历史到Chatwoot
        来自已配置天数的消息将被导入。
        此端点需要配置中的 CHATWOOT_ENABLED=true。
      operationId: chatwootSyncHistory
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                device_id:
                  type: string
                  description: 要同步的设备 ID (如果未指定则使用 CHATWOOT_DEVICE_ID)
                days_limit:
                  type: integer
                  default: 3
                  description: 要同步的历史天数
                include_media:
                  type: boolean
                  default: true
                  description: 同步中包含媒体附件
                include_groups:
                  type: boolean
                  default: true
                  description: 同步时包含群聊信息
      responses:
        '200':
          description: 同步已成功启动
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatwootSyncResponse'
        '400':
          description: 错误请求 (找不到设备或聊天窗口未配置)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBadRequest'
        '409':
          description: 同步正在进行中
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                    example: 409
                  code:
                    type: string
                    example: SYNC_ALREADY_RUNNING
                  message:
                    type: string
                    example: A sync is already in progress for this device
                  results:
                    type: object
                    properties:
                      progress: 48e7be16-0b71-48a1-a359-d2f316e4c84e
components:
  schemas:
    ChatwootSyncResponse:
      type: object
      properties:
        status:
          type: integer
          example: 200
        code:
          type: string
          example: SYNC_STARTED
        message:
          type: string
          example: History sync initiated in background
        results:
          type: object
          properties:
            device_id:
              type: string
              example: my-device-id
            days_limit:
              type: integer
              example: 3
            include_media:
              type: boolean
              example: true
            include_groups:
              type: boolean
              example: true
    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: 附加数据
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic

````

## Related topics

- [聊天woot 集成](https://gowa-docs.mintlify.site/zh/integrations/chatwoot.md)
- [正在接收消息](https://gowa-docs.mintlify.site/zh/examples/receiving-messages.md)
- [会话和连接生命周期](https://gowa-docs.mintlify.site/zh/concepts/sessions.md)
- [从手机请求较早的聊天记录](https://gowa-docs.mintlify.site/zh/api-reference/chat/从手机请求较早的聊天记录.md)
- [API 参考](https://gowa-docs.mintlify.site/zh/api-reference/introduction.md)


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