Campaigns define recurring batch execution configurations. Each campaign targets a decision flow and customer segment, with schedule, volume, and file settings. Campaign runs are individual execution instances.Documentation Index
Fetch the complete documentation index at: https://docs.kaireonai.com/llms.txt
Use this file to discover all available pages before exploring further.
See the Campaigns feature page for UI guidance on creating and managing campaigns.
Base path
List campaigns
Query parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
limit | No | integer | Max results per page. Default 50, max 200. |
offset | No | integer | Records to skip. Default 0. |
Response 200
Create campaign
Request body
| Field | Required | Type | Description |
|---|---|---|---|
decisionFlowId | Yes | string | Decision flow to execute |
segmentId | Yes | string | Customer segment to target |
name | No | string | Campaign name (auto-generated if omitted) |
description | No | string | Campaign purpose and notes |
status | No | enum | draft, active, paused, archived. Default: draft |
scheduleType | No | enum | manual, daily, weekly, monthly. Default: manual |
scheduleDayOfWeek | No | integer | 0=Sun..6=Sat (for weekly) |
scheduleDayOfMonth | No | string | 1-28 or last_working_day (for monthly) |
scheduleTime | No | string | HH:mm format. Default: 09:00 |
scheduleTimezone | No | string | IANA timezone. Default: UTC |
scheduleCron | No | string | Cron expression for custom schedules (e.g., 0 9 * * 1). Used when scheduleType does not cover the desired frequency. |
volumeConstraints | No | object | { maxTotalPerRun?, maxPerOffer?, maxPerChannel? } |
fileConfig | No | object | { format, columns[], includePersonalization, destination, s3Path? } |
channelIds | No | string[] | Batch channel IDs to target (empty = all batch channels) |
Example request
Response 201
Returns the created campaign object.
Update campaign
name, description, status, scheduleType, scheduleDayOfWeek, scheduleDayOfMonth, scheduleTime, scheduleTimezone, scheduleCron, volumeConstraints, fileConfig, channelIds, decisionFlowId, segmentId.
Unlike most update endpoints, PUT allows changing
decisionFlowId and segmentId to retarget a campaign to a different decision flow or customer segment.Delete campaign
admin role.
Get campaign detail
Trigger a campaign run
Response 201
List campaign runs
Execute a run inline (background)
Run execution in the background and return immediately. The route at src/app/api/v1/runs/execute-inline/route.ts:10-22 calls executeBatchRun(runId, decisionFlowId, segmentViewName, tenantId) from src/lib/batch-executor.ts:58 without awaiting — the response is sent before the batch starts producing output, and any per-run failure is logged via getLogger("runs-execute-inline") rather than returned to the caller.
This endpoint is for inline triggers from a single-tenant dev environment or a backup path when the BullMQ worker tier is degraded. Production triggering should use POST /api/v1/runs/:id/campaign-runs so the run gets a CampaignRun row, retry semantics, and DLQ visibility.
Request Body
Identifier of the
Run row that the executor will update with status, startedAt, and completedAt.Decision flow to execute against.
Customer-segment view name. The executor reads from this Postgres view to enumerate target customers.
Response
Returned atroute.ts:21. Status 200.
GET /api/v1/runs/:id.
Status codes
| Code | When |
|---|---|
| 200 | Executor dispatched (returned immediately, before completion) |
| 400 | Missing runId, decisionFlowId, or segmentViewName |
| 401 / 403 | Caller is not authenticated, or not admin / editor |
Roles
admin, editor.Errors raised by
executeBatchRun after the response is sent are logged but never surfaced to the caller. The Run row’s status and error columns are the source of truth for outcome — poll GET /api/v1/runs/:id to see the final state.Campaign statuses
| Status | Description |
|---|---|
draft | Created but not yet active |
active | Live — scheduled runs execute automatically |
paused | Temporarily disabled |
archived | Retired, preserved for history |
Run statuses
| Status | Description |
|---|---|
pending | Waiting for worker to pick up |
running | Processing customers |
completed | All customers processed |
completed_with_errors | Finished but some deliveries failed |
failed | Unrecoverable error |
Role requirements
| Method | Minimum role |
|---|---|
| GET (list/detail) | viewer |
| POST (create/trigger) | editor |
| PUT (update) | editor |
| DELETE | admin |