curl --request PUT \
--url http://localhost:3000/devices/{device_id}/chatwoot/config \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"chatwoot_url": "https://chatwoot.example.com",
"account_id": 1,
"inbox_id": 5,
"api_token": "<string>",
"webhook_secret": "<string>",
"enabled": true
}
'import requests
url = "http://localhost:3000/devices/{device_id}/chatwoot/config"
payload = {
"chatwoot_url": "https://chatwoot.example.com",
"account_id": 1,
"inbox_id": 5,
"api_token": "<string>",
"webhook_secret": "<string>",
"enabled": True
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
chatwoot_url: 'https://chatwoot.example.com',
account_id: 1,
inbox_id: 5,
api_token: '<string>',
webhook_secret: '<string>',
enabled: true
})
};
fetch('http://localhost:3000/devices/{device_id}/chatwoot/config', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "3000",
CURLOPT_URL => "http://localhost:3000/devices/{device_id}/chatwoot/config",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'chatwoot_url' => 'https://chatwoot.example.com',
'account_id' => 1,
'inbox_id' => 5,
'api_token' => '<string>',
'webhook_secret' => '<string>',
'enabled' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:3000/devices/{device_id}/chatwoot/config"
payload := strings.NewReader("{\n \"chatwoot_url\": \"https://chatwoot.example.com\",\n \"account_id\": 1,\n \"inbox_id\": 5,\n \"api_token\": \"<string>\",\n \"webhook_secret\": \"<string>\",\n \"enabled\": true\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("http://localhost:3000/devices/{device_id}/chatwoot/config")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"chatwoot_url\": \"https://chatwoot.example.com\",\n \"account_id\": 1,\n \"inbox_id\": 5,\n \"api_token\": \"<string>\",\n \"webhook_secret\": \"<string>\",\n \"enabled\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:3000/devices/{device_id}/chatwoot/config")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"chatwoot_url\": \"https://chatwoot.example.com\",\n \"account_id\": 1,\n \"inbox_id\": 5,\n \"api_token\": \"<string>\",\n \"webhook_secret\": \"<string>\",\n \"enabled\": true\n}"
response = http.request(request)
puts response.read_body{
"code": "SUCCESS",
"message": "Chatwoot device config saved",
"results": {
"device_id": "my-device-id",
"device_jid": "628123456789@s.whatsapp.net",
"chatwoot_url": "https://chatwoot.example.com",
"account_id": 1,
"inbox_id": 5,
"api_token": "****1234",
"enabled": true,
"webhook_url": "https://gowa.example.com/chatwoot/webhook/my-device-id",
"webhook_secret_set": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
}{
"code": 400,
"message": "field cannot be blank",
"results": null
}{
"code": 400,
"message": "field cannot be blank",
"results": null
}{
"code": 400,
"message": "field cannot be blank",
"results": null
}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.
curl --request PUT \
--url http://localhost:3000/devices/{device_id}/chatwoot/config \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"chatwoot_url": "https://chatwoot.example.com",
"account_id": 1,
"inbox_id": 5,
"api_token": "<string>",
"webhook_secret": "<string>",
"enabled": true
}
'import requests
url = "http://localhost:3000/devices/{device_id}/chatwoot/config"
payload = {
"chatwoot_url": "https://chatwoot.example.com",
"account_id": 1,
"inbox_id": 5,
"api_token": "<string>",
"webhook_secret": "<string>",
"enabled": True
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
chatwoot_url: 'https://chatwoot.example.com',
account_id: 1,
inbox_id: 5,
api_token: '<string>',
webhook_secret: '<string>',
enabled: true
})
};
fetch('http://localhost:3000/devices/{device_id}/chatwoot/config', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "3000",
CURLOPT_URL => "http://localhost:3000/devices/{device_id}/chatwoot/config",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'chatwoot_url' => 'https://chatwoot.example.com',
'account_id' => 1,
'inbox_id' => 5,
'api_token' => '<string>',
'webhook_secret' => '<string>',
'enabled' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:3000/devices/{device_id}/chatwoot/config"
payload := strings.NewReader("{\n \"chatwoot_url\": \"https://chatwoot.example.com\",\n \"account_id\": 1,\n \"inbox_id\": 5,\n \"api_token\": \"<string>\",\n \"webhook_secret\": \"<string>\",\n \"enabled\": true\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("http://localhost:3000/devices/{device_id}/chatwoot/config")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"chatwoot_url\": \"https://chatwoot.example.com\",\n \"account_id\": 1,\n \"inbox_id\": 5,\n \"api_token\": \"<string>\",\n \"webhook_secret\": \"<string>\",\n \"enabled\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:3000/devices/{device_id}/chatwoot/config")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"chatwoot_url\": \"https://chatwoot.example.com\",\n \"account_id\": 1,\n \"inbox_id\": 5,\n \"api_token\": \"<string>\",\n \"webhook_secret\": \"<string>\",\n \"enabled\": true\n}"
response = http.request(request)
puts response.read_body{
"code": "SUCCESS",
"message": "Chatwoot device config saved",
"results": {
"device_id": "my-device-id",
"device_jid": "628123456789@s.whatsapp.net",
"chatwoot_url": "https://chatwoot.example.com",
"account_id": 1,
"inbox_id": 5,
"api_token": "****1234",
"enabled": true,
"webhook_url": "https://gowa.example.com/chatwoot/webhook/my-device-id",
"webhook_secret_set": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
}{
"code": 400,
"message": "field cannot be blank",
"results": null
}{
"code": 400,
"message": "field cannot be blank",
"results": null
}{
"code": 400,
"message": "field cannot be blank",
"results": null
}Authorizations
Basic authentication header of the form Basic <encoded-value>, where <encoded-value> is the base64-encoded string username:password.
Path Parameters
Device ID (or WhatsApp JID) whose Chatwoot config is addressed
"my-device-id"
Body
"https://chatwoot.example.com"
1
5
Chatwoot agent/bot API token. Required on create; empty (or the masked value) keeps the stored token on update.
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.
