Update Message
curl --request PUT \
--url https://{appId}.api-{region}.cometchat.io/v3/messages/{id} \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"data": {
"text": "<string>",
"metadata": {}
},
"tags": [
"tag1"
]
}
'import requests
url = "https://{appId}.api-{region}.cometchat.io/v3/messages/{id}"
payload = {
"data": {
"text": "<string>",
"metadata": {}
},
"tags": ["tag1"]
}
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: '<string>', metadata: {}}, tags: ['tag1']})
};
fetch('https://{appId}.api-{region}.cometchat.io/v3/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/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' => '<string>',
'metadata' => [
]
],
'tags' => [
'tag1'
]
]),
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/messages/{id}"
payload := strings.NewReader("{\n \"data\": {\n \"text\": \"<string>\",\n \"metadata\": {}\n },\n \"tags\": [\n \"tag1\"\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/messages/{id}")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"text\": \"<string>\",\n \"metadata\": {}\n },\n \"tags\": [\n \"tag1\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.api-{region}.cometchat.io/v3/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\": \"<string>\",\n \"metadata\": {}\n },\n \"tags\": [\n \"tag1\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "402",
"conversationId": "cometchat-uid-1_user_cometchat-uid-2",
"sender": "cometchat-uid-1",
"receiverType": "user",
"receiver": "cometchat-uid-2",
"category": "action",
"type": "message",
"data": {
"action": "edited",
"entities": {
"by": {
"entity": {
"uid": "cometchat-uid-1",
"name": "Updated Name",
"status": "offline",
"role": "default",
"createdAt": 1639448370,
"updatedAt": 1640599553
},
"entityType": "user"
},
"for": {
"entity": {
"uid": "cometchat-uid-2",
"name": "George Alan",
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp",
"status": "offline",
"role": "default",
"createdAt": 1639448370
},
"entityType": "user"
},
"on": {
"entity": {
"id": "69",
"conversationId": "cometchat-uid-1_user_cometchat-uid-2",
"sender": "cometchat-uid-1",
"receiverType": "user",
"receiver": "cometchat-uid-2",
"category": "message",
"type": "text",
"data": {
"text": "hello spider",
"entities": {
"sender": {
"entity": {
"uid": "cometchat-uid-1",
"name": "Andrew Joseph",
"role": "default",
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp",
"status": "offline",
"createdAt": 1639448370
},
"entityType": "user"
},
"receiver": {
"entity": {
"uid": "cometchat-uid-2",
"name": "George Alan",
"role": "default",
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp",
"status": "offline",
"createdAt": 1639448370,
"conversationId": "cometchat-uid-1_user_cometchat-uid-2"
},
"entityType": "user"
}
}
},
"sentAt": 1640171302,
"editedAt": 1641477338,
"editedBy": "app_system",
"updatedAt": 1641477338,
"tags": [
"t6"
]
},
"entityType": "message"
}
}
},
"sentAt": 1641477338,
"updatedAt": 1641477338
}
}Messages
Update Message
Update a CometChat message by message ID with REST API to edit message content on behalf of a user.
PUT
/
messages
/
{id}
Update Message
curl --request PUT \
--url https://{appId}.api-{region}.cometchat.io/v3/messages/{id} \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"data": {
"text": "<string>",
"metadata": {}
},
"tags": [
"tag1"
]
}
'import requests
url = "https://{appId}.api-{region}.cometchat.io/v3/messages/{id}"
payload = {
"data": {
"text": "<string>",
"metadata": {}
},
"tags": ["tag1"]
}
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: '<string>', metadata: {}}, tags: ['tag1']})
};
fetch('https://{appId}.api-{region}.cometchat.io/v3/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/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' => '<string>',
'metadata' => [
]
],
'tags' => [
'tag1'
]
]),
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/messages/{id}"
payload := strings.NewReader("{\n \"data\": {\n \"text\": \"<string>\",\n \"metadata\": {}\n },\n \"tags\": [\n \"tag1\"\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/messages/{id}")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"text\": \"<string>\",\n \"metadata\": {}\n },\n \"tags\": [\n \"tag1\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.api-{region}.cometchat.io/v3/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\": \"<string>\",\n \"metadata\": {}\n },\n \"tags\": [\n \"tag1\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "402",
"conversationId": "cometchat-uid-1_user_cometchat-uid-2",
"sender": "cometchat-uid-1",
"receiverType": "user",
"receiver": "cometchat-uid-2",
"category": "action",
"type": "message",
"data": {
"action": "edited",
"entities": {
"by": {
"entity": {
"uid": "cometchat-uid-1",
"name": "Updated Name",
"status": "offline",
"role": "default",
"createdAt": 1639448370,
"updatedAt": 1640599553
},
"entityType": "user"
},
"for": {
"entity": {
"uid": "cometchat-uid-2",
"name": "George Alan",
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp",
"status": "offline",
"role": "default",
"createdAt": 1639448370
},
"entityType": "user"
},
"on": {
"entity": {
"id": "69",
"conversationId": "cometchat-uid-1_user_cometchat-uid-2",
"sender": "cometchat-uid-1",
"receiverType": "user",
"receiver": "cometchat-uid-2",
"category": "message",
"type": "text",
"data": {
"text": "hello spider",
"entities": {
"sender": {
"entity": {
"uid": "cometchat-uid-1",
"name": "Andrew Joseph",
"role": "default",
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp",
"status": "offline",
"createdAt": 1639448370
},
"entityType": "user"
},
"receiver": {
"entity": {
"uid": "cometchat-uid-2",
"name": "George Alan",
"role": "default",
"avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp",
"status": "offline",
"createdAt": 1639448370,
"conversationId": "cometchat-uid-1_user_cometchat-uid-2"
},
"entityType": "user"
}
}
},
"sentAt": 1640171302,
"editedAt": 1641477338,
"editedBy": "app_system",
"updatedAt": 1641477338,
"tags": [
"t6"
]
},
"entityType": "message"
}
}
},
"sentAt": 1641477338,
"updatedAt": 1641477338
}
}For the complete error reference, see Error Guide.
Authorizations
API Key with fullAccess scope(i.e. Rest API Key from the Dashboard).
Headers
UID of the user on whose behalf the action is performed.
Path Parameters
Id of the message whose details are to be fetched.
Body
application/json
Response
200 - application/json
Updated Message
Was this page helpful?
⌘I