Messaging

Modified on Fri, 28 Oct 2022 at 01:20 PM

You can use this API to programmatically send messages between users and groups. 

Send Message

POST - https://api.cometondemand.net/api/v2/sendMessage 

<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.cometondemand.net/api/v2/sendMessage",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => [
    "Accept: application/json",
    "Content-Type: application/x-www-form-urlencoded"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
PHP
Copy
curl --request POST \
  --url https://api.cometondemand.net/api/v2/sendMessage \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/x-www-form-urlencoded'
TypeScript
Copy
Header Parameters
optional
String
Your API Key

Form Parameters
optional
String
The UID of the user sending the message

optional
String
The UID or GUID of the user/group receiving the message

optional
Integer
If you are sending the message to a group, set this to 1

optional
String
The message being sent

optional
Integer
If isGroup is set to 0 (i.e. one-on-one message), then you can choose where you want to display the message: 0 -> Both sender and receiver, 1 -> Only receiver, 2 -> Only sender

Get Messages

POST - https://api.cometondemand.net/api/v2/getMessages

<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.cometondemand.net/api/v2/getMessages",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "offset=0&limit=100",
  CURLOPT_HTTPHEADER => [
    "Accept: application/json",
    "Content-Type: application/x-www-form-urlencoded"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
PHP
Copy
curl --request POST \
  --url https://api.cometondemand.net/api/v2/getMessages \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data offset=0 \
  --data limit=100
TypeScript
Copy
Header Parameters
optional
String
Your API Key

Form Parameters
optional
String
Comma separated UIDs (if you want logs for only particular users)

optional
Integer
Page offset

optional
Integer
Maximum number of results

optional
String
Comma separated UIDs (if you want logs for conversations with only particular users)

Get Group Messages

POST - https://api.cometondemand.net/api/v2/getGroupMessages

POST
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.cometondemand.net/api/v2/getGroupMessages",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "offset=0&limit=100",
  CURLOPT_HTTPHEADER => [
    "Accept: application/json",
    "Content-Type: application/x-www-form-urlencoded"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
PHP
Copy
curl --request POST \
  --url https://api.cometondemand.net/api/v2/getGroupMessages \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data offset=0 \
  --data limit=100
TypeScript
Copy
Header Parameters
optional
String
Your API Key

Form Parameters
optional
String
Comma separated GUIDs (if you want logs for only particular groups)

optional
Integer
Page offset

optional
String
Maximum number of results


Get Unread Message Count (One-on-one)

POST - xhttps://api.cometondemand.net/api/v2/getUnreadMessageCounts

POST
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.cometondemand.net/api/v2/getUnreadMessageCounts",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => [
    "Accept: application/json",
    "Content-Type: application/x-www-form-urlencoded"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
PHP
Copy
curl --request POST \
  --url https://api.cometondemand.net/api/v2/getUnreadMessageCounts \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/x-www-form-urlencoded'
TypeScript
Copy
Header Parameters
optional
String
Your API Key

Form Parameters
optional
String
UID of user whose unread messages count you require

Get Unread Message Count for Groups

POST - https://api.cometondemand.net/api/v2/getUnreadMessageCountForGroups

POS
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.cometondemand.net/api/v2/getUnreadMessageCountForGroups",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => [
    "Accept: application/json",
    "Content-Type: application/x-www-form-urlencoded"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
PHP
Copy
curl --request POST \
  --url https://api.cometondemand.net/api/v2/getUnreadMessageCountForGroups \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/x-www-form-urlencoded'
JavaScript
Copy
Header Parameters
optional
String
Your API Key

Form Parameters
optional
String
Comma separated UIDs

Get Call History

POST - https://api.cometondemand.net/api/v2/getCallHistory

POST
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.cometondemand.net/api/v2/getCallHistory",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "offset=0&limit=100",
  CURLOPT_HTTPHEADER => [
    "Accept: application/json",
    "Content-Type: application/x-www-form-urlencoded"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
PHP
Copy
curl --request POST \
  --url https://api.cometondemand.net/api/v2/getCallHistory \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data offset=0 \
  --data limit=100
TypeScript
Copy
Header Parameters
optional
String
Your API Key

Form Parameters
optional
Integer
Unique User ID

optional
Integer
Page offset

optional
String
Maximum number of results

optional
String
Values can be: avchat, audiochat, broadcast. If empty, it will return all results

Send Sticker

POST - https://api.cometondemand.net/api/v2/sendSticker

POS
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.cometondemand.net/api/v2/sendSticker",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => [
    "Accept: application/json",
    "Content-Type: application/x-www-form-urlencoded"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
PHP
Copy
curl --request POST \
  --url https://api.cometondemand.net/api/v2/sendSticker \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/x-www-form-urlencoded'
TypeScript
Copy
Header Parameters
optional
String
Your API Key

Form Parameters
optional
String
The UID of the user sending the message

optional
String
The UID or GUID of the user/group receiving the message

optional
Integer
If you are sending the message to a group, set this to 1

optional
String
Sticker Category (Refer below for sheet)

optional
String
Sticker Key (Refer below for sheet)


Send File

POST - https://api.cakes.com

POST

<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.cometondemand.net/api/v2/sendFile",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => [
    "Accept: application/json",
    "Content-Type: application/x-www-form-urlencoded"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
PHP
Copy
curl --request POST \
  --url https://api.cometondemand.net/api/v2/sendFile \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/x-www-form-urlencoded'
TypeScript
Copy
Header Parameters
optional
String
Your API Key

Form Parameters
optional
String
The UID of the user sending the message

optional
String
The UID or GUID of the user/group receiving the message

optional
Integer
If you are sending the message to a group, set this to 1

optional
Object
The file being sent

Send Broadcast Message

POST - https://api.cometondemand.net/api/v2/sendBroadcastMessage

POS
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.cometondemand.net/api/v2/sendBroadcastMessage",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => [
    "Accept: application/json",
    "Content-Type: application/x-www-form-urlencoded"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
PHP
Copy
curl --request POST \
  --url https://api.cometondemand.net/api/v2/sendBroadcastMessage \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/x-www-form-urlencoded'
TypeScript
Copy
Header Parameters
optional
String
Your API Key

Form Parameters
optional
String
The UID of the user sending the message

optional
String
Comma separated UIDs

optional
String
The message being sent

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article