Campaigns and flows
Create a campaign as a draft, then schedule it. Campaigns explained.
Build a flow step by step, then activate it. Flows explained.
The campaign object
{
"id": "2c3d4e5f-6a7b-4c8d-9e0f-1a2b3c4d5e6f",
"name": "October newsletter",
"subject": "What's new in October",
"preheader": "Three features and a discount",
"fromName": "Acme",
"fromEmail": "news@acme.com",
"replyTo": null,
"contentFormat": "MARKDOWN",
"content": "Hi {{ contact.first_name | default: \"there\" }},\n\nHere is what we shipped this month…",
"text": null,
"listId": "5a8e2c1f-0b3d-4e6a-9f7c-2d1e8b4a6c3f",
"segmentId": null,
"status": "SCHEDULED",
"editable": true,
"scheduledAt": "2026-10-20T08:00:00Z",
"createdVia": "API",
"createdByUserId": null,
"approvalRequestedAt": null,
"approvalRequestedBy": null,
"approvalNote": null,
"approvedAt": null,
"approvedByUserId": null,
"startedAt": null,
"completedAt": null,
"cancelledAt": null,
"failureReason": null,
"recipientCount": null,
"suppressedCount": null,
"reviewSkippedCount": null,
"createdAt": "2026-10-17T09:30:00Z",
"updatedAt": "2026-10-17T09:35:00Z",
"stats": {
"recipients": 0, "queued": 0, "sent": 0, "delivered": 0, "bounced": 0, "complained": 0,
"opened": 0, "clicked": 0, "unsubscribed": 0, "failed": 0, "suppressed": 0, "cancelled": 0,
"deliveryRate": 0.0, "bounceRate": 0.0, "complaintRate": 0.0,
"openRate": 0.0, "clickRate": 0.0, "unsubscribeRate": 0.0
},
"audience": { "total": 4210, "eligible": 4105, "underReview": 0, "reviewHeldBack": 0 }
}
| Field | Meaning |
|---|---|
status | DRAFT, PENDING_APPROVAL (prepared by an AI assistant, waiting for a person), SCHEDULED, SENDING, SENT, CANCELLED, FAILED |
editable | true until the campaign starts sending (draft, pending approval or scheduled) |
audience | While editable: subscribed members of the list (total), those it would reach now (eligible: active, matching the segment, not suppressed), how many of them are under review (underReview), and how many of those would be held back if it left now (reviewHeldBack) |
recipientCount, suppressedCount, reviewSkippedCount | Set when the campaign leaves: emails queued, addresses skipped because suppressed, and contacts under review held back this time |
stats | Counters and rates (from 0 to 1). Opens and clicks are unique and made by people, not privacy proxies or link scanners |
List campaigns
GET /v1/campaigns
Newest first, 25 per page, with their stats.
0.{
"campaigns": [
{
"id": "2c3d4e5f-…",
"name": "October newsletter",
"subject": "What's new in October",
"status": "SENT",
"listId": "5a8e2c1f-…",
"segmentId": null,
"scheduledAt": "2026-10-20T08:00:00Z",
"startedAt": "2026-10-20T08:00:03Z",
"completedAt": "2026-10-20T08:21:40Z",
"createdVia": "API",
"createdAt": "2026-10-17T09:30:00Z",
"updatedAt": "2026-10-20T08:21:40Z",
"stats": { "recipients": 4105, "delivered": 4079, "opened": 1876, "clicked": 402, "…": "…" }
}
],
"page": 0,
"size": 25,
"total": 18,
"totalPages": 1
}
Create a campaign
POST /v1/campaigns
Creates a draft. Nothing is sent until you schedule it.
MARKDOWN or BLOCKS (wrapped in the space theme), or HTML (sent as given).BLOCKS, the document as a JSON string, 512 KB at most. Variables reference.content. Variables allowed. Empty string: derived again.curl https://api.kulamail.com/v1/campaigns \
-H "Authorization: Bearer ml_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"name": "October newsletter",
"subject": "What'\''s new in October",
"contentFormat": "HTML",
"content": "<h1>October</h1><p>Hi {{ contact.first_name | default: \"there\" }}, …</p><p><a href=\"{{ unsubscribe_url }}\">Unsubscribe</a></p>",
"listId": "5a8e2c1f-0b3d-4e6a-9f7c-2d1e8b4a6c3f"
}'
Returns 201 with the campaign object, status: "DRAFT".
{{ unsubscribe_url }}, Kula adds a small footer with one.Update a campaign
PATCH /v1/campaigns/{id}
Same fields as Create a campaign, all optional: fields left out stay as they are, a blank optional field is cleared. Works while the campaign is editable, otherwise answers 409.
Schedule a campaign
POST /v1/campaigns/{id}/schedule
Schedules the campaign at scheduledAt, or sends it right away when the body is empty. Calling it again moves the date.
curl -X POST https://api.kulamail.com/v1/campaigns/2c3d4e5f-6a7b-4c8d-9e0f-1a2b3c4d5e6f/schedule \
-H "Authorization: Bearer ml_your_api_key" \
-H "Content-Type: application/json" \
-d '{ "scheduledAt": "2026-10-20T08:00:00Z" }'
{
"campaign": { "id": "2c3d4e5f-…", "status": "SCHEDULED", "scheduledAt": "2026-10-20T08:00:00Z", "…": "…" },
"warnings": [],
"checks": { "checks": [], "checkedAt": "2026-10-19T09:12:04Z", "warnings": 0, "blocked": false, "linksNotChecked": 0 }
}
The campaign needs a subject, content, a list and a sender on a verified domain. When it leaves, the usual protections apply: warm-up of new domains, the review cap, and suppressions.
If the campaign can't leave at its time (for example, over your plan's monthly limit), it becomes FAILED, failureReason says why, and the campaign.failed webhook is sent.
checks holds the pre-send checks of the content. They are warnings: the campaign is scheduled anyway, unless a link is flagged as dangerous.
warnings flags a space whose marketing is paused: the campaign is scheduled, but its emails wait until sending resumes. Those still waiting after 24 hours of pause are cancelled, the campaign ends as SENT with them counted in stats.cancelled, and the campaign.expired webhook is sent. Reputation.
| Status | Code | When |
|---|---|---|
| 400 | bad_request, domain_not_verified | Missing subject, content or list, or a date in the past |
| 409 | conflict | The campaign already left or was cancelled |
| 409 | content_blocked | A link is flagged as dangerous by Google. The message names it |
Cancel a campaign
POST /v1/campaigns/{id}/cancel
Stops a scheduled or sending campaign: waiting emails are cancelled, those already sent stay sent. Answers 409 if the campaign is not scheduled, pending approval or sending.
Get campaign stats
GET /v1/campaigns/{id}/stats
The full report: stats, most clicked links, results per mailbox provider, and unique opens per hour over the first 48 hours.
{
"stats": {
"recipients": 4105, "queued": 0, "sent": 4105, "delivered": 4079, "bounced": 26, "complained": 1,
"opened": 1876, "clicked": 402, "unsubscribed": 9, "failed": 0, "suppressed": 0, "cancelled": 0,
"deliveryRate": 0.9937, "bounceRate": 0.0063, "complaintRate": 0.0002,
"openRate": 0.4599, "clickRate": 0.0986, "unsubscribeRate": 0.0022
},
"topLinks": [
{ "url": "https://acme.com/blog/october", "clicks": 351, "uniqueClicks": 298 }
],
"providers": [
{ "provider": "GOOGLE", "stats": { "delivered": 2310, "opened": 1012, "…": "…" } },
{ "provider": "MICROSOFT", "stats": { "delivered": 980, "opened": 455, "…": "…" } }
],
"opensOverTime": [
{ "hour": "2026-10-20T08:00:00Z", "opens": 612 },
{ "hour": "2026-10-20T09:00:00Z", "opens": 301 }
]
}
Flows
Create a flow with its trigger, add its steps, then activate it. The rules are those of the dashboard. To make a contact enter an active flow, record the event or subscribe them to the list that triggers it.
List flows
GET /v1/flows
Newest first.
[
{
"id": "4d5e6f7a-8b9c-4d0e-1f2a-3b4c5d6e7f8a",
"name": "Trial onboarding",
"description": null,
"status": "ACTIVE",
"triggerType": "EVENT",
"triggerListId": null,
"triggerEventName": "trial_started",
"entryRule": "ONCE",
"goalEventNames": ["paid"],
"sendWindow": null,
"createdVia": "DASHBOARD",
"activationRequestedAt": null,
"activatedAt": "2026-10-02T10:00:00Z",
"activeRuns": 57,
"emailsSent": 1240,
"createdAt": "2026-10-01T15:20:00Z",
"updatedAt": "2026-10-02T10:00:00Z"
}
]
| Field | Values |
|---|---|
status | DRAFT, ACTIVE, PAUSED |
triggerType | LIST_SUBSCRIBED (with triggerListId), EVENT (with triggerEventName) or FORM_JOINED (with triggerFormId) |
triggerListId | The flow's list. With EVENT, optional: only its subscribers enter, and the unsubscribe link of marketing emails leaves that list only (without it, every list) |
entryRule | ONCE: a contact goes through the flow once. EVERY_TIME: each trigger starts it again, unless a run is still in progress |
goalEventNames | Up to 5 events that end a contact's run as soon as your app sends one, even during a wait (run status GOAL_REACHED) |
sendWindow | null, or the days and hours the flow sends its emails (see below) |
Get a flow
GET /v1/flows/{id}
The flow with its steps, each email step with its stats, the run counts and problems.
{
"id": "4d5e6f7a-…",
"name": "Trial onboarding",
"status": "ACTIVE",
"triggerType": "EVENT",
"triggerEventName": "trial_started",
"entryRule": "ONCE",
"goalEventNames": ["paid"],
"…": "…",
"steps": [
{
"id": "a1b2…",
"position": 0,
"type": "EMAIL",
"waitMinutes": null,
"subject": "Welcome to your trial",
"preheader": null,
"fromName": null,
"fromEmail": null,
"replyTo": null,
"contentFormat": "MARKDOWN",
"content": "Hi {{ contact.first_name | default: \"there\" }}, …",
"text": null,
"templateId": null,
"template": null,
"condition": null,
"transactional": false,
"stats": { "sent": 620, "delivered": 617, "opened": 401, "…": "…" },
"createdAt": "2026-10-01T15:20:00Z",
"updatedAt": "2026-10-01T15:20:00Z"
},
{
"id": "c3d4…",
"position": 1,
"type": "WAIT",
"waitMode": "EVENT",
"waitMinutes": 4320,
"waitEventName": "project_created",
"waitDays": null,
"waitTime": null,
"…": "…"
},
{
"id": "e5f6…",
"position": 2,
"type": "CONDITION",
"condition": {
"match": "all",
"conditions": [{ "type": "event", "name": "project_created", "operator": "not_performed" }]
},
"…": "…"
}
],
"runs": { "active": 57, "completed": 412, "exited": 51, "goalReached": 100, "failed": 0 },
"problems": []
}
problems lists everything that would block activation, each with stepId (null for the trigger), message and an optional code: {"stepId": "e5f6…", "message": "Step 3: add a condition"}.
type | Does |
|---|---|
EMAIL | Sends an email: its own content, with the same fields as a campaign (subject, preheader, fromName, fromEmail, replyTo, contentFormat, content, text), or a linked template in templateId |
WAIT | Waits (see below) |
CONDITION | The contact continues if it matches condition, otherwise leaves the flow |
SPLIT | Sends the contact down its yes or no branch, depending on condition. Both branches meet again at the step after the split; an empty branch goes straight to it |
END | Ends the run (COMPLETED). Always the last step of its sequence; no settings |
ADD_TO_LIST | Subscribes the contact to listId, without confirmation. Never brings back someone who left the list |
REMOVE_FROM_LIST | Unsubscribes the contact from listId. On the flow's list (triggerListId), ends the run |
SET_ATTRIBUTE | attributeKey with attributeOperation: SET (attributeValue: string, number or boolean), TODAY (the date, space timezone) or REMOVE |
UNSUBSCRIBE | Unsubscribes the contact from all emails and ends the run. Placed like END |
WEBHOOK | POSTs the contact and the trigger event to webhookUrl (https), named webhookName, then continues without waiting. Payload and signature |
An EMAIL step with "transactional": true goes on the transactional stream, without unsubscribe link, even to unsubscribed contacts: a flow holding one keeps them, and they only get its transactional emails.
A WEBHOOK step also returns webhookStats (succeeded, pending, failed calls) and webhookFailing (its last 20 calls failed).
condition uses the segment definition format. Steps form a tree: a SPLIT step holds its branches in yes and no, and a step of a branch has parentStepId (the split) and branch (YES or NO). Splits nest 3 levels deep; a flow has 50 steps at most. The steps after a split are reached unless both branches end with END.
A WAIT step waits according to its waitMode, in the space timezone:
waitMode | Waits |
|---|---|
DURATION | waitMinutes |
EVENT | Until the contact performs waitEventName, at most waitMinutes |
UNTIL | The next of waitDays (MONDAY to SUNDAY) at waitTime (HH:MM) |
A linked EMAIL step sends the template's published version: publishing the template updates every flow using it. template sums it up:
"templateId": "c41d7e2a-9b8f-4a6e-b3d2-5f1e0a9c8b7d",
"template": {
"id": "c41d7e2a-9b8f-4a6e-b3d2-5f1e0a9c8b7d",
"name": "Order shipped",
"alias": "order-shipped",
"subject": "Your order is on its way",
"published": true,
"publishedAt": "2026-10-12T14:03:11Z"
}
In a flow email, {{ data.x }} reads the trigger event's properties, like {{ event.x }}. A run whose trigger event lacks a required variable of the template is FAILED, and its exitReason names the variables.
sendWindow is null, or the days and hours the flow sends its emails, in the space timezone: {"days": ["MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY"], "start": "09:00", "end": "18:00"}.
Create a flow
POST /v1/flows
Creates a DRAFT flow, with no steps.
LIST_SUBSCRIBED, EVENT or FORM_JOINED.FORM_JOINED: the form or landing page whose signups start the flow, through the event kula.form_joined. triggerListId defaults to its first list.LIST_SUBSCRIBED: the list whose new subscribers enter the flow. With EVENT, optional: only subscribers of that list enter, and the unsubscribe link of its marketing emails leaves that list only. Without it, the link unsubscribes from every list. On update, "" removes it.EVENT: the event that starts the flow. Letters, digits and _ . : -, 100 characters at most.ONCE (default) or EVERY_TIME.days, start and end (HH:MM, at least one hour apart).curl https://api.kulamail.com/v1/flows \
-H "Authorization: Bearer ml_your_api_key" \
-H "Content-Type: application/json" \
-d '{ "name": "Welcome", "triggerType": "LIST_SUBSCRIBED", "triggerListId": "5a8e2c1f-0b3d-4e6a-9f7c-2d1e8b4a6c3f" }'
Returns 201 with the flow.
Update a flow
PATCH /v1/flows/{id}
Same fields, all optional. Name, description, goal events and send window change at any time: an empty goalEventNames removes the goals, a sendWindow without days removes the window. The trigger and the entry rule change only while the flow is not active, otherwise 409.
Add a step
POST /v1/flows/{id}/steps
EMAIL, WAIT, CONDITION, SPLIT, END, ADD_TO_LIST, REMOVE_FROM_LIST, SET_ATTRIBUTE, UNSUBSCRIBE or WEBHOOK.SPLIT step: the step goes in one of its branches. Leave out for the main sequence.YES or NO, with parentStepId.0, within its sequence. Leave out to add at the end.Plus the fields of its type: the content fields or templateId (id or alias) for EMAIL, condition for CONDITION and SPLIT. For WAIT: waitMode (default DURATION), waitMinutes (1 minute to 365 days; with EVENT, the longest wait, 1 hour to 90 days), waitEventName (never the trigger event), waitDays and waitTime. For the actions: listId, attributeKey, attributeOperation and attributeValue, webhookUrl (https, public address, 2,000 characters at most) and webhookName (100 at most).
curl https://api.kulamail.com/v1/flows/4d5e6f7a-8b9c-4d0e-1f2a-3b4c5d6e7f8a/steps \
-H "Authorization: Bearer ml_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"type": "EMAIL",
"subject": "Welcome aboard",
"content": "Hi {{ contact.first_name | default: \"there\" }}, …",
"fromEmail": "hello@acme.com"
}'
Or link a template:
curl https://api.kulamail.com/v1/flows/4d5e6f7a-8b9c-4d0e-1f2a-3b4c5d6e7f8a/steps \
-H "Authorization: Bearer ml_your_api_key" \
-H "Content-Type: application/json" \
-d '{ "type": "EMAIL", "templateId": "order-shipped" }'
Returns 201 with the whole flow. An email may stay incomplete until activation.
| Status | Code | When |
|---|---|---|
| 400 | bad_request | Content fields sent to a step linked to a template |
| 400 | missing_variables | The flow is triggered by a list and the template has required variables |
| 404 | not_found | No template with this id or alias |
Update, delete, move and reorder steps
PATCH /v1/flows/{id}/steps/{stepId}: same fields, all optional; a blank optional field is cleared, the type never changes."templateId": ""detaches the template and copies its content into the step. Works on an active flow, for email content and a webhook'swebhookUrlandwebhookName: running contacts get the new version, after the pre-send checks (409 content_blockedon a dangerous link).DELETE /v1/flows/{id}/steps/{stepId}: deletes the step, and its branches for aSPLIT. Contacts waiting on it move to the step after it, which may be the step after a split.409if a condition of the flow reads this email.PUT /v1/flows/{id}/steps/{stepId}/positionwith{ "parentStepId", "branch", "position" }: moves the step anywhere, including into another branch (leave outparentStepIdandbranchfor the main sequence). ASPLITtakes its branches along. Contacts on the step follow it. Same rules as adding a step: splits 3 levels deep, nothing after anEND, and a split never moves into its own branches. Returns the flow.PUT /v1/flows/{id}/steps/orderwith{"stepIds": [...]}: every step of the main sequence, or of one branch, in the new order.
Adding, deleting, moving and reordering need a flow that is not active, otherwise 409: pause it first.
Activate and pause
POST /v1/flows/{id}/activate
Checks the trigger and every step, runs the pre-send checks of every email, then starts enrolling contacts. Returns the flow, each email step with its checks.
| Status | Code | When |
|---|---|---|
| 400 | bad_request, domain_not_verified | A step is incomplete. The message names it: Step 2 › Yes › step 1: add a subject |
| 409 | content_blocked | A link is flagged as dangerous by Google |
| 409 | template_not_published | A step links a template never published |
Before the account review, flows send within a small daily budget. While marketing is paused for the space, runs wait.
POST /v1/flows/{id}/pause stops enrolling and running contacts; activating again resumes runs where they were. 409 if the flow is not active.
Delete a flow
DELETE /v1/flows/{id}
Deletes a flow that is not active, with its steps and runs. Sent emails stay in the history. Returns 204.
List runs
GET /v1/flows/{id}/runs
One run per entry of a contact, newest first, 50 per page. Optional status (ACTIVE, COMPLETED, EXITED, GOAL_REACHED, FAILED) and page.
{
"runs": [
{
"id": "9a8b…",
"contactId": "1f2e…",
"contactEmail": "ada@example.com",
"status": "ACTIVE",
"currentStepId": "c3d4…",
"nextRunAt": "2026-10-21T09:00:00Z",
"waitingEventName": "project_created",
"exitReason": null,
"startedAt": "2026-10-18T09:00:00Z",
"finishedAt": null
}
],
"page": 0,
"size": 50,
"total": 57,
"totalPages": 2
}
Get a run
GET /v1/flows/{id}/runs/{runId}
The run, the event that started it with its properties, and the steps it went through, oldest first.
{
"run": { "id": "9a8b…", "contactEmail": "ada@example.com", "status": "COMPLETED", "…": "…" },
"triggerEvent": {
"id": "4c5d…",
"name": "checkout_started",
"occurredAt": "2026-10-18T09:00:00Z",
"properties": { "cart_url": "https://shop.example/cart/42", "total": 59.9 }
},
"steps": [
{
"stepId": "c3d4…",
"stepType": "EMAIL",
"stepLabel": "Step 1",
"outcome": "SENT",
"eventName": null,
"startedAt": "2026-10-18T10:00:00Z",
"endedAt": "2026-10-18T10:00:00Z",
"untilAt": null,
"email": {
"messageId": "7e6f…",
"subject": "You left Ceramic mug in your cart",
"status": "DELIVERED",
"sentAt": "2026-10-18T10:00:02Z",
"deliveredAt": "2026-10-18T10:00:04Z",
"openedAt": "2026-10-18T11:12:00Z",
"clickedAt": null,
"bouncedAt": null
}
},
{
"stepId": "d4e5…",
"stepType": "WAIT",
"stepLabel": "Step 2",
"outcome": "EVENT_RECEIVED",
"eventName": "order_completed",
"startedAt": "2026-10-18T10:00:00Z",
"endedAt": "2026-10-18T14:30:00Z",
"untilAt": "2026-10-19T10:00:00Z",
"email": null
}
]
}
outcome | Step | Meaning |
|---|---|---|
SENT, DEFERRED | Sent, or held until the send window opens | |
WAITING, WAITED | Wait | Waiting for a time or a day, then done |
WAITING_FOR_EVENT, EVENT_RECEIVED, TIMED_OUT | Wait | Waiting for eventName, then received, or the longest wait passed |
PASSED, NOT_MET | Filter | The contact matched, or left the flow |
YES, NO | Split | The branch taken |
ENDED | End flow | The run completed on this step |
STOPPED | Wait, email | The run ended during the wait (goal, unsubscribe) |
stepLabel is null for a step deleted since. Runs started before October 20, 2026 have no steps.