API Reference

Campaign Follow-ups & Controls

Engagement follow-ups, mailing-list To, and the unsubscribe policy on POST /campaigns.

POST/campaigns

Three optional controls extend a campaign beyond the base fields.

Engagement follow-ups

Up to 5 followups send automatically after the campaign finishes — each fires delay later to the recipients matching its condition, threaded as a reply to their original email (same conversation; subject defaults to Re: <campaign subject>). Bodies support the same merge tags as the campaign.

FieldDescription
conditionOne of opened, clicked, not_opened, not_clicked, replied, not_replied.
delayNatural-language duration after the send completes, e.g. "5 hours", "4 days" (max 30 days).
subjectOptional; defaults to Re: <campaign subject> to keep the thread.
htmlThe follow-up body (required).
Open/click conditions require tracking to be enabled on the sending domain.

Mailing-list To

Set list_to: true and every message shows a generated recipient-<hex>@your-domain address as the visible To header. Delivery is unchanged — each mail is still sent individually to its real recipient.

Unsubscribe policy

`unsubscribe_policy`Behavior
account (default)Any opt-out blocks the recipient — today's behavior.
domainOnly opt-outs recorded for THIS sending domain (plus account-wide ones) block. An unsubscribe from one of your other domains does not.
ignoreThe unsubscribe list is skipped. Hard-bounced and complained addresses are ALWAYS excluded regardless.
Use ignore only where you have a lawful basis to email recipients who opted out.

A/B winning metric

The ab_test.metric now accepts reply in addition to open and click — the winner is the variant with the higher reply rate (replies are matched from your inbound mail).

import { MailBlastr } from 'mailblastr';

const mb = new MailBlastr('mb_xxxxxxxxx');

const { data, error } = await mb.campaigns.create({
  "domain": "yourdomain.com", "from": "You <you@yourdomain.com>",
  "subject": "Big news", "html": "<p>Hi {{name}} …</p>",
  "list_to": true,
  "unsubscribe_policy": "domain",
  "ab_test": { "enabled": true, "subject_b": "Bigger news", "test_pct": 20, "metric": "reply" },
  "followups": [
    { "condition": "not_opened", "delay": "5 hours", "html": "<p>Bumping this…</p>" }
  ]
});
console.log({ data, error });