Skip to main content

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

FieldTypeRequiredDescription
subjectstringyesSubject line. Supports substitution data.
senderNamestringyesDisplay name in the recipient inbox.
senderEmailstringyesAddress on a verified sending domain.
bodystringyesHTML body. Plain-text auto-derived if not supplied.
bodyTextstringnoPlain-text body. Recommended.
recipientsobjectyesList, label, or segment scope. See Recipients.
scheduledAtdatetimenoFuture send time. If absent, send is immediate when triggered.
categoryIdstringnoOptional grouping for reporting roll-ups.
trackingobjectnoOpen and click tracking flags. Defaults: both on.
templateIdstringnoReference a server-side template instead of inlining the body.

Status lifecycle

draft -> scheduled -> sending -> sent -> reported
|
+-> cancelled (via cancel-schedule before send)
StatusMeaningEditableCancelable
draftCreated, not sent.YesN/A
scheduledSend time in the future.Yes (until send)Yes
sendingPlatform delivering now.NoNo
sentDelivery to platform complete. Recipient deliveries flow async.NoNo
reportedEngagement aggregates available.NoNo
cancelledScheduled send cancelled before launch.NoN/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:

  1. Pick the campaign type (regular, A/B test, automation entry).
  2. Compose the email in the visual editor or paste raw HTML.
  3. Pick recipients. See Recipients.
  4. Choose Send Now or Schedule. See Scheduling.
  5. 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

SymptomLikely cause
422 with Domain not verifiedsenderEmail domain has not completed DNS verification. See Sending Domains.
Recipient count zeroRecipients filter resolves to empty. Check labels and segments.
Subject renders with {{first_name}} literallyContact missing the field, no fallback set, or template tag mistyped. See Personalization.
Send fires but no opens or clicks recordedTracking flags off, or tracking domain CNAME not verified. See Sending Domains.
Cannot edit a sending campaignEdit window closes when send starts. Cancel and clone instead, if pre-scheduled.