POST /api/campaigns/upload
For audiences larger than 10,000 users, upload a CSV file containing user IDs and optional per-user template variable values. The CSV is parsed server-side, recipients are created, and delivery is triggered through the campaign system.
How does CSV batch delivery work?
- Create a campaign linked to an approved template
- Upload a CSV file with user IDs and variable columns to the campaign
- Send the campaign
CSV batch delivery uses the campaign system (unlike the one-call send API). This gives you campaign lifecycle tracking, scheduling, and recipient status monitoring.
How do I create the CSV file?
The CSV must include:- A
user_idcolumn (required) containing the target user IDs - Additional columns for template variable values (optional) — column names must match the variable keys in the template’s
variableSchema
CSV rules
| Rule | Detail |
|---|---|
| First row | Must be column headers |
user_id column | Required — contains target user IDs |
| Variable columns | Optional — names must match template variableSchema keys |
| Column names | Letters, numbers, underscores, hyphens only |
| Max rows | 100,000 |
| Encoding | UTF-8 |
| Delimiter | Comma |
Step 1: Create a campaign
id from the response.
Step 2: Upload the CSV
POST /api/campaigns/upload
Upload the CSV as a multipart form with the campaign ID.
Headers
Your CometChat App ID.
Your CometChat API Key.
Form fields
The CSV file containing
user_id and optional variable columns.The campaign ID to add recipients to.
Example request
Example response
The number of recipients successfully parsed and added from the CSV.
Step 3: Send the campaign
How do CSV variable columns work?
When your template has avariableSchema, the CSV columns beyond user_id are mapped to variable keys:
Template variableSchema:
name and discount_code values substituted into the template content.
Comparing inline targets vs CSV upload
| Feature | Inline targets | CSV upload |
|---|---|---|
| Max users | 10,000 | 100,000 |
| API calls | 1 (one-call send) | 3 (create campaign, upload CSV, send) |
| Variables | In request body | In CSV columns |
| Scheduling | Not supported | Supported via scheduledAt |
| Lifecycle tracking | No campaign entity | Full campaign lifecycle |
| Status monitoring | Analytics only | Campaign status + recipient status |
Error codes
| Code | HTTP | Description |
|---|---|---|
ERR_BAD_REQUEST | 400 | Missing user_id column or invalid CSV format |
ERR_NOT_FOUND | 404 | Campaign not found |
ERR_OPERATION_FAILED | 500 | CSV parsing or recipient creation failed |