POST /api/campaigns/upload Upload a CSV file to add recipients to a campaign. The CSV must include a userId column and can optionally include columns that map to the template’s variable schema for per-user personalization.

Headers

appid
string
required
Your CometChat App ID.
apikey
string
required
Your CometChat API Key.

Request body (multipart/form-data)

file
file
required
The CSV file to upload. Must contain a userId column.
campaignId
string
required
The campaign ID to add recipients to.

CSV format

The CSV file must have a header row. The userId column is required. Additional columns are mapped to the template’s variable schema.
userId,customerName,orderId
user-001,Jane Doe,ORD-001
user-002,John Smith,ORD-002
user-003,Alice Johnson,ORD-003

Example request

curl -X POST https://{appId}.api-{region}.cometchat.io/v3/business-messaging/api/campaigns/upload \
  -H "appid: YOUR_APP_ID" \
  -H "apikey: YOUR_API_KEY" \
  -F "file=@recipients.csv" \
  -F "campaignId=666c3d4e5f6a7b8c9d0e1f2a"

Example response

{
  "uploaded": 3,
  "total": 1503,
  "campaignId": "666c3d4e5f6a7b8c9d0e1f2a"
}

Response fields

uploaded
integer
Number of recipients added from the CSV.
total
integer
Total number of recipients in the campaign after upload.
campaignId
string
The campaign ID that received the recipients.
Variable columns in the CSV are matched by name to the template’s variableSchema. Column names must exactly match the variable names declared in the schema.
The CSV upload supports large files. Each row becomes a recipient record with its own variable values, enabling per-user personalization at scale.