Messaging
  • 4 Minutes to read
  • Dark
    Light

Messaging

  • Dark
    Light

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

Send Message

POST


<?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;
}
curl --request POST \
  --url https://api.cometondemand.net/api/v2/sendMessage \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/x-www-form-urlencoded'

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


<?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;
}
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

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


<?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;
}
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

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
<?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;
}
curl --request POST \
  --url https://api.cometondemand.net/api/v2/getUnreadMessageCounts \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/x-www-form-urlencoded'

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


<?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;
}
curl --request POST \
  --url https://api.cometondemand.net/api/v2/getUnreadMessageCountForGroups \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/x-www-form-urlencoded'

Header Parameters
optional
String
Your API Key

Form Parameters
optional
String
Comma separated UIDs

Get Call History

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;
}
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

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

<?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;
}
curl --request POST \
  --url https://api.cometondemand.net/api/v2/sendSticker \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/x-www-form-urlencoded'

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

<?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;
}
curl --request POST \
  --url https://api.cometondemand.net/api/v2/sendFile \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/x-www-form-urlencoded'

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

<?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;
}
curl --request POST \
  --url https://api.cometondemand.net/api/v2/sendBroadcastMessage \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/x-www-form-urlencoded'

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?

What's Next