Skip to main content
POST
Create a campaign

Authorizations

Authorization
string
header
required

Your project's secret key (pk_…, without the pub segment). Server-side only — never ship it to a browser. Get it from Settings → Projects in the dashboard.

Body

application/json

Exactly one of message or variants is required.

name
string
required

Internal campaign name shown in the dashboard.

Maximum string length: 80
Example:

"Launch: CSV export"

message
object
required

Single-variant shorthand: creates one variant named "A". Mutually exclusive with variants.

channel
enum<string>
default:web_inapp

Delivery channel. Email content uses subject, previewText, Markdown body, and an optional CTA.

Available options:
web_inapp,
email,
push
variants
object[]

Weighted variants for an A/B test (at most one control, at least one positive weight). Mutually exclusive with message.

Required array length: 1 - 10 elements
audience
object

Canonical audience union. null or { "kind": "all" } targets everyone. { "kind": "expression", "expression": { … }, "reason": "…" } authors an inline audience stored as an immutable audience version. { "kind": "segment", "segment": "id-or-key", "version": n? } pins a saved segment version (omitted version = current, resolved atomically; archived segments are refused). Check expressions first with POST /api/v1/audiences/check. Mutually exclusive with the deprecated targeting field.

targeting
object | null
deprecated

Deprecated shorthand for the same audience semantics (strict trait equality + events seen/not_seen, ANDed). Still accepted; normalized into an immutable audience version. Prefer audience.

pages
string[]

Web in-app only. Path patterns limiting where the message may render. Email campaigns reject this field.

Maximum array length: 20
Maximum string length: 256
goalId
string | null

Link the campaign to a goal in this project (400 if the goal doesn't exist here). Tracked events matching the linked goal's targetEvent automatically resolve the campaign's deliveries to converted once shown. Omit or pass null for no goal — direct communications never need one.

Minimum string length: 1
launch
boolean
default:false

Start the campaign instead of creating a draft. Email returns 409 until the project's sending domain is verified and its from address matches.

deliverFrom

Requested delivery-window start: epoch milliseconds or ISO-8601 with an explicit timezone offset (e.g. 2026-08-01T09:00:00Z). Nothing is delivered before this instant; combine with launch: true to schedule a future start. Must be earlier than deliverUntil.

deliverUntil

Requested delivery-window end: epoch milliseconds or ISO-8601 with an explicit timezone offset. Must be in the future; delivery stops automatically at exactly this instant.

push
object
sourceChanges
object

Optional prepared source declaration, committed atomically with campaign content. No expectedRevision on create. Empty changes cannot qualify for automatic activation.

Response

The created campaign, including its variant.

campaign
object
required