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

# Create or update a device's Chatwoot config

> Routes this device's messages to its own Chatwoot destination (URL + account +
inbox + token) instead of the global CHATWOOT_* env config.
The URL is canonicalized and validated (http/https only, no embedded
credentials, hosts resolving to private/loopback/link-local/metadata addresses
are rejected unless allowlisted via CHATWOOT_ALLOWED_HOSTS).
On update, an empty `api_token` — or the masked value echoed back from a GET —
keeps the stored token. Changing the routing identity (url/account/inbox) is
rejected with 409 once the config has linked conversations; delete and
recreate the config to rebind.




## OpenAPI

````yaml /openapi.yml put /devices/{device_id}/chatwoot/config
openapi: 3.0.0
info:
  title: WhatsApp API MultiDevice
  version: 9.7.0
  description: |
    This API is used for sending whatsapp via API.

    The web dashboard is a separate project (gowa-ui); the server downloads its
    latest release asset and serves it at `/` (or returns a JSON banner when
    APP_UI_ENABLED=false).

    Device scoping:
    - Send `X-Device-Id` on all device-scoped REST calls.
    - WebSocket: connect to `/ws?device_id=<id>`.
    - WebSocket auth (when basic auth is enabled): browsers cannot set an
      Authorization header on WebSocket connections, so also pass
      `&authorization=<base64(user:pass)>` in the query string. Use TLS in
      production since the credential is visible in the URL.
servers:
  - url: http://localhost:3000
security:
  - basicAuth: []
tags:
  - name: app
    description: Initial Connection to Whatsapp server
  - name: device
    description: Device management for multi-device support
  - name: user
    description: Getting information
  - name: send
    description: Send Message (Text/Image/File/Video).
  - name: message
    description: Message manipulation (revoke/react/update).
  - name: call
    description: Call management (reject incoming calls)
  - name: chat
    description: Chat conversations and messaging
  - name: group
    description: Group setting
  - name: newsletter
    description: newsletter setting
  - name: chatwoot
    description: Chatwoot integration for customer support
paths:
  /devices/{device_id}/chatwoot/config:
    put:
      tags:
        - chatwoot
      summary: Create or update a device's Chatwoot config
      description: >
        Routes this device's messages to its own Chatwoot destination (URL +
        account +

        inbox + token) instead of the global CHATWOOT_* env config.

        The URL is canonicalized and validated (http/https only, no embedded

        credentials, hosts resolving to private/loopback/link-local/metadata
        addresses

        are rejected unless allowlisted via CHATWOOT_ALLOWED_HOSTS).

        On update, an empty `api_token` — or the masked value echoed back from a
        GET —

        keeps the stored token. Changing the routing identity
        (url/account/inbox) is

        rejected with 409 once the config has linked conversations; delete and

        recreate the config to rebind.
      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 agent/bot API token. Required on create; empty (or
                    the masked value) keeps the stored token on update.
                webhook_secret:
                  type: string
                  description: >
                    Webhook secret of this inbox's API channel. When set it
                    protects every

                    webhook routed to this device (on
                    `/chatwoot/webhook/{device_id}` and on

                    the shared `/chatwoot/webhook`) instead of

                    CHATWOOT_WEBHOOK_SECRET. Omit to keep the stored value; send
                    an empty

                    string to remove it. Never returned by the API.
                enabled:
                  type: boolean
                  default: true
      responses:
        '200':
          description: Config saved
          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 (INVALID_REQUEST) or rejected URL
            (INVALID_CHATWOOT_URL)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBadRequest'
        '404':
          description: Device not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBadRequest'
        '409':
          description: >-
            Routing identity change rejected while linked conversations exist
            (CONFIG_HAS_LINKED_CONVERSATIONS)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorBadRequest'
components:
  parameters:
    ChatwootConfigDeviceId:
      name: device_id
      in: path
      required: true
      description: Device ID (or WhatsApp JID) whose Chatwoot config is addressed
      schema:
        type: string
        example: my-device-id
  schemas:
    ChatwootDeviceConfig:
      type: object
      description: Per-device Chatwoot routing config (API token masked on every read)
      properties:
        device_id:
          type: string
          example: my-device-id
        device_jid:
          type: string
          description: >-
            WhatsApp JID of the device; stamped automatically at login (empty
            before pairing)
          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: Masked; only the last 4 characters are revealed
          example: '****1234'
        enabled:
          type: boolean
          example: true
        webhook_url:
          type: string
          description: >-
            URL to set on this device's Chatwoot inbox so agent replies route
            back to this device
          example: https://gowa.example.com/chatwoot/webhook/my-device-id
        webhook_secret_set:
          type: boolean
          description: >-
            Whether this device has its own webhook secret (the secret itself is
            never returned)
          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 Status Code
        message:
          type: string
          example: field cannot be blank
          description: Detail error message
        results:
          type: object
          example: null
          description: additional data
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic

````

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