Add Rule
curl --request POST \
--url https://{appId}.api-{region}.cometchat.io/v3/moderation/rules \
--header 'Content-Type: application/json'import requests
url = "https://{appId}.api-{region}.cometchat.io/v3/moderation/rules"
headers = {"Content-Type": "application/json"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'Content-Type': 'application/json'}};
fetch('https://{appId}.api-{region}.cometchat.io/v3/moderation/rules', 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",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
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"
req, _ := http.NewRequest("POST", 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.post("https://{appId}.api-{region}.cometchat.io/v3/moderation/rules")
.header("Content-Type", "application/json")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.api-{region}.cometchat.io/v3/moderation/rules")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.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
Add Rule
Create a CometChat moderation rule with REST API to define content checks, actions, and rule conditions.
POST
/
moderation
/
rules
Add Rule
curl --request POST \
--url https://{appId}.api-{region}.cometchat.io/v3/moderation/rules \
--header 'Content-Type: application/json'import requests
url = "https://{appId}.api-{region}.cometchat.io/v3/moderation/rules"
headers = {"Content-Type": "application/json"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'Content-Type': 'application/json'}};
fetch('https://{appId}.api-{region}.cometchat.io/v3/moderation/rules', 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",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
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"
req, _ := http.NewRequest("POST", 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.post("https://{appId}.api-{region}.cometchat.io/v3/moderation/rules")
.header("Content-Type", "application/json")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.api-{region}.cometchat.io/v3/moderation/rules")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.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
Created Rule
Show child attributes
Show child attributes
Was this page helpful?