Update Rule
curl --request PUT \
--url https://{appId}.api-{region}.cometchat.io/v3/moderation/rules/{ruleId} \
--header 'Content-Type: application/json'import requests
url = "https://{appId}.api-{region}.cometchat.io/v3/moderation/rules/{ruleId}"
headers = {"Content-Type": "application/json"}
response = requests.put(url, headers=headers)
print(response.text)const options = {method: 'PUT', headers: {'Content-Type': 'application/json'}};
fetch('https://{appId}.api-{region}.cometchat.io/v3/moderation/rules/{ruleId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{appId}.api-{region}.cometchat.io/v3/moderation/rules/{ruleId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_HTTPHEADER => [
"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"
"net/http"
"io"
)
func main() {
url := "https://{appId}.api-{region}.cometchat.io/v3/moderation/rules/{ruleId}"
req, _ := http.NewRequest("PUT", url, nil)
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("https://{appId}.api-{region}.cometchat.io/v3/moderation/rules/{ruleId}")
.header("Content-Type", "application/json")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.api-{region}.cometchat.io/v3/moderation/rules/{ruleId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
response = http.request(request)
puts response.read_body{
"data": {
"id": "moderation-test",
"name": "Video Moderation",
"description": "AI-powered video moderation to detect unsafe content.",
"enabled": true,
"conditions": [
{
"id": 1,
"isKeywordsReferencePresent": false,
"isMediaPresent": true,
"entity": "message",
"operand": "image",
"category": "word",
"operator": "contains",
"value": [
"violence_greaterThan_30"
],
"message": [
"Image contains violence with confidence greater than 30"
]
}
],
"action": [
"blockMessage"
],
"active": true,
"createdAt": 1720003247,
"updatedAt": 1720003247,
"revisionId": "253179cf5f665257_moderation-test_1"
}
}Rules
Update Rule
Update a CometChat moderation rule by ruleId with REST API to change content checks, actions, or rule conditions.
PUT
/
moderation
/
rules
/
{ruleId}
Update Rule
curl --request PUT \
--url https://{appId}.api-{region}.cometchat.io/v3/moderation/rules/{ruleId} \
--header 'Content-Type: application/json'import requests
url = "https://{appId}.api-{region}.cometchat.io/v3/moderation/rules/{ruleId}"
headers = {"Content-Type": "application/json"}
response = requests.put(url, headers=headers)
print(response.text)const options = {method: 'PUT', headers: {'Content-Type': 'application/json'}};
fetch('https://{appId}.api-{region}.cometchat.io/v3/moderation/rules/{ruleId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{appId}.api-{region}.cometchat.io/v3/moderation/rules/{ruleId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_HTTPHEADER => [
"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"
"net/http"
"io"
)
func main() {
url := "https://{appId}.api-{region}.cometchat.io/v3/moderation/rules/{ruleId}"
req, _ := http.NewRequest("PUT", url, nil)
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("https://{appId}.api-{region}.cometchat.io/v3/moderation/rules/{ruleId}")
.header("Content-Type", "application/json")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.api-{region}.cometchat.io/v3/moderation/rules/{ruleId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
response = http.request(request)
puts response.read_body{
"data": {
"id": "moderation-test",
"name": "Video Moderation",
"description": "AI-powered video moderation to detect unsafe content.",
"enabled": true,
"conditions": [
{
"id": 1,
"isKeywordsReferencePresent": false,
"isMediaPresent": true,
"entity": "message",
"operand": "image",
"category": "word",
"operator": "contains",
"value": [
"violence_greaterThan_30"
],
"message": [
"Image contains violence with confidence greater than 30"
]
}
],
"action": [
"blockMessage"
],
"active": true,
"createdAt": 1720003247,
"updatedAt": 1720003247,
"revisionId": "253179cf5f665257_moderation-test_1"
}
}Response
200 - application/json
Update Rule
Show child attributes
Show child attributes
Was this page helpful?