> ## 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 post /devices
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:
    post:
      tags:
        - device
      summary: 添加新设备
      description: 为多设备管理创建一个新的设备栏位
      operationId: addDevice
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                device_id:
                  type: string
                  description: 可选自定义设备 ID。 如果没有提供，将产生一个。
                  example: my-custom-device-id
                webhook_url:
                  type: string
                  description: 可选设备特定的 webhook URL。 如果设置，此设备的事件将会被发送到这里而不是全局Webhook。
                  example: https://device-webhook.example.com/handler
                webhook_secret:
                  type: string
                  description: 可选的秘密用于签名特定设备的 webhook payload (HMAC)。
                  example: super-secret-key
                webhook_events:
                  type: string
                  description: 可选的逗号分隔事件名称列表以转发到特定设备的 webhook。 空意味着所有事件。
                  example: message,message.ack
                webhook_insecure_skip_verify:
                  type: boolean
                  description: 可选的。 发送到特定设备的 Web 钩子时跳过 TLS 证书验证。
                  example: false
      responses:
        '200':
          description: 好的
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeviceAddResponse'
        '400':
          description: 错误请求
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBadRequest'
        '500':
          description: 服务器内部错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorInternalServer'
components:
  schemas:
    DeviceAddResponse:
      type: object
      properties:
        code:
          type: string
          example: SUCCESS
        message:
          type: string
          example: Device added
        status:
          type: integer
          example: 200
        results:
          type: object
          properties:
            id:
              type: string
              example: my-device-id
            display_name:
              type: string
              example: John Doe
            state:
              type: string
              enum:
                - disconnected
                - connecting
                - connected
                - logged_in
              example: disconnected
            jid:
              type: string
              example: 628123456789@s.whatsapp.net
            created_at:
              type: string
              format: date-time
              example: '2024-01-01T00:00:00Z'
            webhook_url:
              type: string
              description: 在创建时指定特定的 webhook URL 重复
              example: https://device-webhook.example.com/handler
            webhook_secret:
              type: string
              description: 创建时提供指定的webhook 密钥
              example: super-secret-key
            webhook_events:
              type: string
              description: 创建时提供指定特定事件白名单
              example: message,message.ack
            webhook_insecure_skip_verify:
              type: boolean
              description: 创建时响应指定的 TLS 验证设置
              example: false
    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: 附加数据
    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/api-reference/chatwoot/创建或更新设备的聊天窗口配置.md)
- [添加更多参与者到组](https://gowa-docs.mintlify.site/zh/api-reference/group/添加更多参与者到组.md)
- [创建群组并添加参与者](https://gowa-docs.mintlify.site/zh/api-reference/group/创建群组并添加参与者.md)
- [多设备与设备选择](https://gowa-docs.mintlify.site/zh/concepts/multidevice.md)
- [WebSocket 事件](https://gowa-docs.mintlify.site/zh/api-reference/websocket.md)


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