Skip to main content
POST
/
campaigns
/
{id}
/
recipients
Add recipients manually (user IDs)
curl --request POST \
  --url https://{appId}.api-{region}.cometchat.io/v3/campaigns/campaigns/{id}/recipients \
  --header 'Content-Type: application/json' \
  --header 'apikey: <api-key>' \
  --header 'appid: <appid>' \
  --data '
{
  "userIds": [
    "<string>"
  ],
  "userVariables": {
    "user_42": {
      "name": "Ajay"
    }
  }
}
'
import requests

url = "https://{appId}.api-{region}.cometchat.io/v3/campaigns/campaigns/{id}/recipients"

payload = {
"userIds": ["<string>"],
"userVariables": { "user_42": { "name": "Ajay" } }
}
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({userIds: ['<string>'], userVariables: {user_42: {name: 'Ajay'}}})
};

fetch('https://{appId}.api-{region}.cometchat.io/v3/campaigns/campaigns/{id}/recipients', 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/campaigns/{id}/recipients",
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([
'userIds' => [
'<string>'
],
'userVariables' => [
'user_42' => [
'name' => 'Ajay'
]
]
]),
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/campaigns/{id}/recipients"

payload := strings.NewReader("{\n \"userIds\": [\n \"<string>\"\n ],\n \"userVariables\": {\n \"user_42\": {\n \"name\": \"Ajay\"\n }\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/campaigns/{id}/recipients")
.header("appid", "<appid>")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"userIds\": [\n \"<string>\"\n ],\n \"userVariables\": {\n \"user_42\": {\n \"name\": \"Ajay\"\n }\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://{appId}.api-{region}.cometchat.io/v3/campaigns/campaigns/{id}/recipients")

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 \"userIds\": [\n \"<string>\"\n ],\n \"userVariables\": {\n \"user_42\": {\n \"name\": \"Ajay\"\n }\n }\n}"

response = http.request(request)
puts response.read_body

Authorizations

apikey
string
header
required

Your CometChat REST API Key.

Headers

appid
string
required

Tenant application ID

Path Parameters

id
string
required

Body

application/json
userIds
string[]
required

Array of user IDs to add as recipients

Required array length: 1 - 10000 elements
userVariables
object

Per-user variables, keyed by userId. Persisted on each CampaignRecipient.variables row at insert time. Renderer substitutes these into template content per recipient. Example: { "user_42": { "name": "Ajay" }, "user_43": { "name": "Sam" } }.

Example:
{ "user_42": { "name": "Ajay" } }

Response

Recipients added