Create a new channel
curl --request POST \
--url https://{appId}.api-{region}.cometchat.io/v3/campaigns/channels \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--header 'appid: <appid>' \
--data '
{
"name": "My Push Channel",
"type": "push",
"channelId": "cc-notification-channel-my-push",
"enabled": false,
"metadata": {
"apiKey": "xxx",
"senderId": "yyy"
}
}
'import requests
url = "https://{appId}.api-{region}.cometchat.io/v3/campaigns/channels"
payload = {
"name": "My Push Channel",
"type": "push",
"channelId": "cc-notification-channel-my-push",
"enabled": False,
"metadata": {
"apiKey": "xxx",
"senderId": "yyy"
}
}
headers = {
"appid": "<appid>",
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {appid: '<appid>', apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'My Push Channel',
type: 'push',
channelId: 'cc-notification-channel-my-push',
enabled: false,
metadata: {apiKey: 'xxx', senderId: 'yyy'}
})
};
fetch('https://{appId}.api-{region}.cometchat.io/v3/campaigns/channels', 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/campaigns/channels",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'My Push Channel',
'type' => 'push',
'channelId' => 'cc-notification-channel-my-push',
'enabled' => false,
'metadata' => [
'apiKey' => 'xxx',
'senderId' => 'yyy'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apikey: <api-key>",
"appid: <appid>"
],
]);
$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/campaigns/channels"
payload := strings.NewReader("{\n \"name\": \"My Push Channel\",\n \"type\": \"push\",\n \"channelId\": \"cc-notification-channel-my-push\",\n \"enabled\": false,\n \"metadata\": {\n \"apiKey\": \"xxx\",\n \"senderId\": \"yyy\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("appid", "<appid>")
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.post("https://{appId}.api-{region}.cometchat.io/v3/campaigns/channels")
.header("appid", "<appid>")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"My Push Channel\",\n \"type\": \"push\",\n \"channelId\": \"cc-notification-channel-my-push\",\n \"enabled\": false,\n \"metadata\": {\n \"apiKey\": \"xxx\",\n \"senderId\": \"yyy\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.api-{region}.cometchat.io/v3/campaigns/channels")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["appid"] = '<appid>'
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"My Push Channel\",\n \"type\": \"push\",\n \"channelId\": \"cc-notification-channel-my-push\",\n \"enabled\": false,\n \"metadata\": {\n \"apiKey\": \"xxx\",\n \"senderId\": \"yyy\"\n }\n}"
response = http.request(request)
puts response.read_bodyChannels
Create a new channel
Create a new channel.
POST
/
channels
Create a new channel
curl --request POST \
--url https://{appId}.api-{region}.cometchat.io/v3/campaigns/channels \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--header 'appid: <appid>' \
--data '
{
"name": "My Push Channel",
"type": "push",
"channelId": "cc-notification-channel-my-push",
"enabled": false,
"metadata": {
"apiKey": "xxx",
"senderId": "yyy"
}
}
'import requests
url = "https://{appId}.api-{region}.cometchat.io/v3/campaigns/channels"
payload = {
"name": "My Push Channel",
"type": "push",
"channelId": "cc-notification-channel-my-push",
"enabled": False,
"metadata": {
"apiKey": "xxx",
"senderId": "yyy"
}
}
headers = {
"appid": "<appid>",
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {appid: '<appid>', apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'My Push Channel',
type: 'push',
channelId: 'cc-notification-channel-my-push',
enabled: false,
metadata: {apiKey: 'xxx', senderId: 'yyy'}
})
};
fetch('https://{appId}.api-{region}.cometchat.io/v3/campaigns/channels', 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/campaigns/channels",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'My Push Channel',
'type' => 'push',
'channelId' => 'cc-notification-channel-my-push',
'enabled' => false,
'metadata' => [
'apiKey' => 'xxx',
'senderId' => 'yyy'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apikey: <api-key>",
"appid: <appid>"
],
]);
$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/campaigns/channels"
payload := strings.NewReader("{\n \"name\": \"My Push Channel\",\n \"type\": \"push\",\n \"channelId\": \"cc-notification-channel-my-push\",\n \"enabled\": false,\n \"metadata\": {\n \"apiKey\": \"xxx\",\n \"senderId\": \"yyy\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("appid", "<appid>")
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.post("https://{appId}.api-{region}.cometchat.io/v3/campaigns/channels")
.header("appid", "<appid>")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"My Push Channel\",\n \"type\": \"push\",\n \"channelId\": \"cc-notification-channel-my-push\",\n \"enabled\": false,\n \"metadata\": {\n \"apiKey\": \"xxx\",\n \"senderId\": \"yyy\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.api-{region}.cometchat.io/v3/campaigns/channels")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["appid"] = '<appid>'
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"My Push Channel\",\n \"type\": \"push\",\n \"channelId\": \"cc-notification-channel-my-push\",\n \"enabled\": false,\n \"metadata\": {\n \"apiKey\": \"xxx\",\n \"senderId\": \"yyy\"\n }\n}"
response = http.request(request)
puts response.read_bodyAuthorizations
Your CometChat REST API Key.
Headers
Tenant application ID
Body
application/json
Channel display name
Example:
"My Push Channel"
Channel type
Available options:
in_app, push, sms, email, whatsapp, custom Example:
"push"
Channel slug (auto-generated from name if omitted)
Example:
"cc-notification-channel-my-push"
Whether the channel is enabled
Channel-specific metadata
Example:
{ "apiKey": "xxx", "senderId": "yyy" }
Response
Channel created
Was this page helpful?
⌘I