Update message
curl --request PUT \
--url https://{appid}.api-{region}.cometchat.io/v3/moderation/messages/{id} \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"data": {
"text": "This message has been updated."
}
}
'import requests
url = "https://{appid}.api-{region}.cometchat.io/v3/moderation/messages/{id}"
payload = { "data": { "text": "This message has been updated." } }
headers = {
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({data: {text: 'This message has been updated.'}})
};
fetch('https://{appid}.api-{region}.cometchat.io/v3/moderation/messages/{id}', 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/messages/{id}",
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([
'data' => [
'text' => 'This message has been updated.'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apikey: <api-key>"
],
]);
$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 := "https://{appid}.api-{region}.cometchat.io/v3/moderation/messages/{id}"
payload := strings.NewReader("{\n \"data\": {\n \"text\": \"This message has been updated.\"\n }\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("apikey", "<api-key>")
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/messages/{id}")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"text\": \"This message has been updated.\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appid}.api-{region}.cometchat.io/v3/moderation/messages/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {\n \"text\": \"This message has been updated.\"\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "1",
"conversationId": "cometchat-uid-1_user_cometchat-uid-2",
"sender": "cometchat-uid-2",
"receiverType": "user",
"receiver": "cometchat-uid-1",
"category": "message",
"type": "text",
"data": {
"text": "heyaya, I'm updated",
"entities": {
"receiver": {
"entity": {
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp",
"createdAt": 1751644824,
"lastActiveAt": 1751644824,
"name": "Andrew Joseph",
"role": "default",
"status": "offline",
"uid": "cometchat-uid-1"
},
"entityType": "user"
},
"sender": {
"entity": {
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp",
"conversationId": "cometchat-uid-1_user_cometchat-uid-2",
"createdAt": 1751644824,
"lastActiveAt": 1751644824,
"name": "George Alan",
"role": "default",
"status": "offline",
"uid": "cometchat-uid-2"
},
"entityType": "user"
}
},
"moderation": {
"status": "approved"
}
},
"sentAt": 1750335220,
"editedAt": 1751645607,
"editedBy": "cometchat-uid-1",
"updatedAt": 1751644906
}
}AI Moderation
Update message
This endpoint is responsible for editing the message, The moderation status is recalculated based on the app’s configured rules for the edited message.
PUT
/
moderation
/
messages
/
{id}
Update message
curl --request PUT \
--url https://{appid}.api-{region}.cometchat.io/v3/moderation/messages/{id} \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"data": {
"text": "This message has been updated."
}
}
'import requests
url = "https://{appid}.api-{region}.cometchat.io/v3/moderation/messages/{id}"
payload = { "data": { "text": "This message has been updated." } }
headers = {
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({data: {text: 'This message has been updated.'}})
};
fetch('https://{appid}.api-{region}.cometchat.io/v3/moderation/messages/{id}', 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/messages/{id}",
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([
'data' => [
'text' => 'This message has been updated.'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apikey: <api-key>"
],
]);
$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 := "https://{appid}.api-{region}.cometchat.io/v3/moderation/messages/{id}"
payload := strings.NewReader("{\n \"data\": {\n \"text\": \"This message has been updated.\"\n }\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("apikey", "<api-key>")
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/messages/{id}")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"text\": \"This message has been updated.\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appid}.api-{region}.cometchat.io/v3/moderation/messages/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {\n \"text\": \"This message has been updated.\"\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "1",
"conversationId": "cometchat-uid-1_user_cometchat-uid-2",
"sender": "cometchat-uid-2",
"receiverType": "user",
"receiver": "cometchat-uid-1",
"category": "message",
"type": "text",
"data": {
"text": "heyaya, I'm updated",
"entities": {
"receiver": {
"entity": {
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp",
"createdAt": 1751644824,
"lastActiveAt": 1751644824,
"name": "Andrew Joseph",
"role": "default",
"status": "offline",
"uid": "cometchat-uid-1"
},
"entityType": "user"
},
"sender": {
"entity": {
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp",
"conversationId": "cometchat-uid-1_user_cometchat-uid-2",
"createdAt": 1751644824,
"lastActiveAt": 1751644824,
"name": "George Alan",
"role": "default",
"status": "offline",
"uid": "cometchat-uid-2"
},
"entityType": "user"
}
},
"moderation": {
"status": "approved"
}
},
"sentAt": 1750335220,
"editedAt": 1751645607,
"editedBy": "cometchat-uid-1",
"updatedAt": 1751644906
}
}Authorizations
API Key with fullAccess scope(i.e. Rest API Key from the Dashboard).
Path Parameters
Id of the message whose details are to be fetched.
Body
application/json
Can contain any additional properties except for the key properties.
Show child attributes
Show child attributes
Response
200 - application/json
Update Message(s)
The response is of type object.
Was this page helpful?
⌘I