Campaigns
A campaign is the unit of Email Marketing send. One campaign = one HTML or plain-text body, one subject, one sender, one recipient list, one schedule.
Data model
| Field | Type | Required | Description |
|---|---|---|---|
subject | string | yes | Subject line. Supports substitution data. |
senderName | string | yes | Display name in the recipient inbox. |
senderEmail | string | yes | Address on a verified sending domain. |
body | string | yes | HTML body. Plain-text auto-derived if not supplied. |
bodyText | string | no | Plain-text body. Recommended. |
recipients | object | yes | List, label, or segment scope. See Recipients. |
scheduledAt | datetime | no | Future send time. If absent, send is immediate when triggered. |
categoryId | string | no | Optional grouping for reporting roll-ups. |
tracking | object | no | Open and click tracking flags. Defaults: both on. |
templateId | string | no | Reference a server-side template instead of inlining the body. |
Status lifecycle
draft -> scheduled -> sending -> sent -> reported
|
+-> cancelled (via cancel-schedule before send)
| Status | Meaning | Editable | Cancelable |
|---|---|---|---|
draft | Created, not sent. | Yes | N/A |
scheduled | Send time in the future. | Yes (until send) | Yes |
sending | Platform delivering now. | No | No |
sent | Delivery to platform complete. Recipient deliveries flow async. | No | No |
reported | Engagement aggregates available. | No | No |
cancelled | Scheduled send cancelled before launch. | No | N/A |
Status is observable via GET /v2/email-marketing/status for an account-level snapshot or GET /v2/email-marketing/{id} for one campaign.
Create a campaign
API
curl https://api.mailtarget.co/v2/email-marketing \
-X POST \
-H "Authorization: Bearer $MAILTARGET_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"subject": "Welcome to our newsletter",
"senderName": "Your Brand",
"senderEmail": "hello@your-verified-domain.com",
"body": "<h1>Welcome</h1><p>Thanks for subscribing.</p>",
"bodyText": "Welcome. Thanks for subscribing.",
"recipients": { "labelIds": ["lbl_newsletter"] },
"tracking": { "opens": true, "clicks": true }
}'
Response includes the campaign ID. Status starts at draft.
Dashboard
In Email Marketing > New Campaign:
- Pick the campaign type (regular, A/B test, automation entry).
- Compose the email in the visual editor or paste raw HTML.
- Pick recipients. See Recipients.
- Choose Send Now or Schedule. See Scheduling.
- Save as draft or launch.
Both paths produce the same campaign object.
Send a campaign
Send a draft immediately
curl https://api.mailtarget.co/v2/email-marketing/{campaignId}/send \
-X POST \
-H "Authorization: Bearer $MAILTARGET_API_KEY"
Create plus send in one call
For one-shot sends without a draft step:
curl https://api.mailtarget.co/v2/email-marketing/create-send \
-X POST \
-H "Authorization: Bearer $MAILTARGET_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"subject": "Order confirmation digest",
"senderName": "Your Brand",
"senderEmail": "hello@your-verified-domain.com",
"body": "<p>Your weekly digest is ready.</p>",
"recipients": { "labelIds": ["lbl_digest_subscribers"] }
}'
This is the API equivalent of the dashboard Send Now button.
Duplicate a campaign
Copy an existing campaign as a new draft. Useful for serial newsletters.
curl https://api.mailtarget.co/v2/email-marketing/{campaignId}/duplicate \
-X POST \
-H "Authorization: Bearer $MAILTARGET_API_KEY"
The duplicate inherits subject, body, sender, and category. Edit before sending. Recipients and schedule reset (you pick new ones).
Preview a campaign
Render the HTML with substitution data applied, without sending.
curl "https://api.mailtarget.co/v2/email-marketing/{emailId}/preview?contactId={contactId}" \
-H "Authorization: Bearer $MAILTARGET_API_KEY"
Pass a real contact ID to render with that contact's substitution values. Useful for QA on personalized campaigns.
Recipient count preview
Before launching, check how many contacts will receive the send.
curl https://api.mailtarget.co/v2/email-marketing/{campaignId}/count-recipient \
-X POST \
-H "Authorization: Bearer $MAILTARGET_API_KEY"
The count reflects current Contact Book state, suppression list, and any include/exclude rules. Run this immediately before send if the list is volatile.
Common mistakes
| Symptom | Likely cause |
|---|---|
422 with Domain not verified | senderEmail domain has not completed DNS verification. See Sending Domains. |
| Recipient count zero | Recipients filter resolves to empty. Check labels and segments. |
Subject renders with {{first_name}} literally | Contact missing the field, no fallback set, or template tag mistyped. See Personalization. |
| Send fires but no opens or clicks recorded | Tracking flags off, or tracking domain CNAME not verified. See Sending Domains. |
Cannot edit a sending campaign | Edit window closes when send starts. Cancel and clone instead, if pre-scheduled. |
Related
- Recipients for targeting.
- Scheduling for send time control.
- Personalization for substitution and AI subject.
- Reports for engagement metrics.
- Compose and Send guide for the end-to-end walkthrough.