Create a campaign

Create a campaign

POST/api/v1/email/campaigns

POST /email/campaigns
curl -X POST 'https://www.unitpost.com/api/v1/email/campaigns' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "June newsletter",
    "subject": "What's new",
    "from": "you@yourdomain.com",
    "template_id": "tmpl_123",
    "segment_id": "seg_123"
  }'
Response · 201
{
  "object": "campaign",
  "id": "id_123",
  "name": "Example",
  "template_id": "template_123",
  "segment_id": "segment_123",
  "topic_id": "topic_123",
  "from": "you@yourdomain.com",
  "subject": "Welcome to Acme",
  "preview_text": "string",
  "open_tracking": false,
  "click_tracking": false,
  "status": "draft",
  "scheduled_at": "2026-01-01T00:00:00.000Z",
  "variable_fallbacks": {},
  "excluded_contact_ids": [
    "string"
  ],
  "total_recipients": 1,
  "sent_count": 1,
  "failed_count": 1,
  "created_at": "2026-01-01T00:00:00.000Z",
  "updated_at": "2026-01-01T00:00:00.000Z"
}

Create a campaign in draft. Target either a saved segment (segment_id, see Create a segment) or an inline recipients list, and optionally scope it to a subscription topic (topic_id) so contacts who opted out of that topic are skipped automatically. Content comes from a published template_id (campaigns have no inline html/text). Nothing is sent yet — edit the draft with Update a campaign, check it with Validate a campaign, then launch it with Send a campaign. Requires the campaigns:write capability.

Request body13 fields
FieldTypeDescription
namerequiredstring—
template_idrequiredstring—
segment_idstring—
recipientsstring[]—
topic_idstring—
fromrequiredstring—
subjectstring—
preview_textstring—
scheduled_atstring—
open_trackingobject—
click_trackingobject—
variable_fallbacksobject—
excluded_contact_idsstring[]—
Response · 201 fields20 fields
FieldTypeDescription
objectrequiredstring—
idrequiredstring—
namerequiredstring—
template_idrequiredstring—
segment_idrequiredstring—
topic_idrequiredobject—
fromrequiredstring—
subjectrequiredobject—
preview_textrequiredobject—
open_trackingrequiredobject—
click_trackingrequiredobject—
statusrequiredenumdraft | scheduled | sending | paused | sent | canceled | failed—
scheduled_atrequiredobject—
variable_fallbacksrequiredobject—
excluded_contact_idsrequiredstring[]—
total_recipientsrequirednumber—
sent_countrequirednumber—
failed_countrequirednumber—
created_atrequiredstring—
updated_atrequiredstring—
201401422

Search docs and guides

Search the docs and product guides.