POST /api/notifications/send
Batch notifications deliver messages to multiple users in one request. Set mode to batch and provide up to 10,000 user IDs in the targets array. Each user can receive personalized content through per-user template variables.
This uses the same endpoint as realtime notifications. The difference is
mode: "batch" and multiple targets.How does batch delivery work?
- You send a single request with up to 10,000 target user IDs
- The platform validates the template and per-user variables
- The response returns immediately with a
notificationId(fire-and-forget) - Delivery happens asynchronously — messages are queued and processed in batches
- Track delivery status through the Analytics API
Headers
Your CometChat App ID.
Your CometChat API Key.
Request body
Template configuration for the notification.
The template key (slug). Provide either
key or id.The template MongoDB ObjectId. Provide either
key or id.Per-user variables keyed by user ID. Each user ID maps to an object of variable key-value pairs matching the template’s
variableSchema.Optional custom key-value pairs included in push notification payloads.
Array of user IDs to receive the notification. Minimum 1, maximum 10,000 for batch mode.
Must be
batch for batch delivery.Optional label for organizing and tracking this notification.
Optional grouping key for analytics categorization.
How do per-user variables work in batch mode?
Each target user can receive different content by providing user-specific variable values. Thetemplate.variables object is keyed by user ID:
{{name}} and {{appointment_number}} placeholders in the template content with each user’s specific values before delivery.
What variable types are supported?
| Type | Value format | Example |
|---|---|---|
string | Plain text | "name": "Bob" |
image | Object with url, width, height | "photo": { "url": "https://...", "width": 100, "height": 100 } |
action | Object with type and data | "cta": { "type": "web", "data": "https://example.com/view" } |
Example request — batch with per-user variables
Example request — batch without variables
Example response
The response returns immediately after the batch is queued. Actual delivery happens asynchronously. Use the Analytics API to track delivery, view, and click metrics.
Response fields
Unique identifier for tracking this batch notification.
The template key used.
Array of channel objects with
key and type showing which delivery channels were used.Always
batch for batch notifications.Origin info with
type (always api) and value (masked API key).ISO 8601 timestamp when the notification was created.
Error codes
| Code | HTTP | Description |
|---|---|---|
ERR_BAD_REQUEST | 400 | Missing required fields or invalid body |
ERR_TEMPLATE_NOT_APPROVED | 409 | Template must be in approved status |
ERR_INVALID_VARIABLES | 400 | Per-user variables don’t match template schema |
ERR_TARGET_LIMIT_EXCEEDED | 400 | More than 10,000 targets in batch mode |
ERR_INVALID_MODE | 400 | Mode must be realtime or batch |
ERR_NO_CHANNELS | 400 | Template has no enabled channels |
What are the limits?
| Constraint | Limit |
|---|---|
| Inline targets (batch mode) | 10,000 users |
| Inline targets (realtime mode) | 1 user |
| CSV upload targets | 100,000 users |