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

# 创建或更新设备的聊天窗口配置

> 将此设备的消息转到自己的聊天目的地(URL + 帐户 +
收件箱+ 令牌) ，而不是全局的 CHATWOT_* env 配置。
URL 是可扫描和验证的 (http/htps 没有嵌入的
凭据，解决到私有/循环/link-local/metadata地址
的主机被拒绝，除非允许通过 CHATWOT_ALLOWED_HOSTS。
更新时，一个空的 `api_token` - 或一个从GET 返回的遮罩值 -
保存存储的标记。 更改路由标识 (url/account/inbox) 是
拒绝的，一旦配置链接了对话；删除和
重新创建配置以重新绑定。




## OpenAPI

````yaml /zh/openapi.yml put /devices/{device_id}/chatwoot/config
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:
  /devices/{device_id}/chatwoot/config:
    put:
      tags:
        - chatwoot
      summary: 创建或更新设备的聊天窗口配置
      description: |
        将此设备的消息转到自己的聊天目的地(URL + 帐户 +
        收件箱+ 令牌) ，而不是全局的 CHATWOT_* env 配置。
        URL 是可扫描和验证的 (http/htps 没有嵌入的
        凭据，解决到私有/循环/link-local/metadata地址
        的主机被拒绝，除非允许通过 CHATWOT_ALLOWED_HOSTS。
        更新时，一个空的 `api_token` - 或一个从GET 返回的遮罩值 -
        保存存储的标记。 更改路由标识 (url/account/inbox) 是
        拒绝的，一旦配置链接了对话；删除和
        重新创建配置以重新绑定。
      operationId: chatwootUpsertDeviceConfig
      parameters:
        - $ref: '#/components/parameters/ChatwootConfigDeviceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - chatwoot_url
                - account_id
                - inbox_id
              properties:
                chatwoot_url:
                  type: string
                  example: https://chatwoot.example.com
                account_id:
                  type: integer
                  example: 1
                inbox_id:
                  type: integer
                  example: 5
                api_token:
                  type: string
                  description: Chatwoot 代理/bot API 令牌。 创建时需要填写；空(或遮罩值)将保存存储的令牌在更新。
                webhook_secret:
                  type: string
                  description: >
                    此收件箱的 API 频道的 Webhook 秘密。 设置后，它会取代
                    CHATWOOT_WEBHOOK_SECRET，保护路由到此设备的所有

                    Webhook（包括 `/chatwoot/webhook/{device_id}` 和

                    共享的 `/chatwoot/webhook`

                    路由）。 省略以保留存储的值；发送一个空的

                    字符串以删除它。 API从未返回.
                enabled:
                  type: boolean
                  default: true
      responses:
        '200':
          description: 配置已保存
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: SUCCESS
                  message:
                    type: string
                    example: Chatwoot device config saved
                  results:
                    $ref: '#/components/schemas/ChatwootDeviceConfig'
        '400':
          description: 无效的请求 (INVALID_REQUEST) 或拒绝 URL (INVALID_CHATWOT_URL)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBadRequest'
        '404':
          description: 找不到设备
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBadRequest'
        '409':
          description: 存在链接对话时路由身份变更被拒绝 (CONFIG_HAS_LINKED_CONVERSATIONS)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBadRequest'
components:
  parameters:
    ChatwootConfigDeviceId:
      name: device_id
      in: path
      required: true
      description: 已处理聊天窗口配置的设备 ID (或WhatsApp JID)
      schema:
        type: string
        example: my-device-id
  schemas:
    ChatwootDeviceConfig:
      type: object
      description: 每次读取时都遮盖了设备聊天路由配置 (API 令牌)
      properties:
        device_id:
          type: string
          example: my-device-id
        device_jid:
          type: string
          description: 设备的WhatsApp JID；登录时自动盖章(在配对之前为空)
          example: 628123456789@s.whatsapp.net
        chatwoot_url:
          type: string
          example: https://chatwoot.example.com
        account_id:
          type: integer
          example: 1
        inbox_id:
          type: integer
          example: 5
        api_token:
          type: string
          description: 遮罩；只显示最后4个字符
          example: '****1234'
        enabled:
          type: boolean
          example: true
        webhook_url:
          type: string
          description: 在此设备上设置的 Chatwoot 收件箱的 URL，代理回复路由返回此设备
          example: https://gowa.example.com/chatwoot/webhook/my-device-id
        webhook_secret_set:
          type: boolean
          description: 此设备是否有自己的 webhook 密钥 (绝不退回机密)
          example: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    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

- [获取设备的聊天窗口配置](https://gowa-docs.mintlify.site/zh/api-reference/chatwoot/获取设备的聊天窗口配置.md)
- [删除设备的聊天窗口配置](https://gowa-docs.mintlify.site/zh/api-reference/chatwoot/删除设备的聊天窗口配置.md)
- [聊天woot 集成](https://gowa-docs.mintlify.site/zh/integrations/chatwoot.md)
- [每台设备聊天woot webhook 端点](https://gowa-docs.mintlify.site/zh/api-reference/chatwoot/每台设备聊天woot-webhook-端点.md)
- [获取聊天窗口同步进度](https://gowa-docs.mintlify.site/zh/api-reference/chatwoot/获取聊天窗口同步进度.md)


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