Campaigns

API reference for creating campaign drafts, sending or scheduling them with warm-up, and reading their results.

Using an AI agent? Just ask:“Draft a campaign to my Newsletter list and show me before sending.”Connect your agent →

Create a draft#

POST/api/v1/campaigns

Creates a draft. Nothing is sent. The response says whether it's ready (ready_to_send), what's missing (problems), and how many people it would reach (recipients). When that's more than your daily campaign limit allows today, sends_over says how it continues on the following days, e.g. { "days": 3, "today": 1000, "per_day": 1000 }; otherwise it's null. The send response has it too.

Body

  • namestringrequired
    Internal name.
  • fromstringrequired
    Sender on a verified domain: Acme <[email protected]>.
  • liststring | string[]required
    A list name or id, or up to 50 of them. Someone on several lists gets it once.
  • subjectstring
    Required unless the template has one.
  • htmlstring
    The email HTML. Plain content (paragraphs, headings, lists, links) gets the Maillayer layout and opens in the visual editor; a full document with tables or <style> is sent as is. Your postal address and an unsubscribe link are added automatically.
  • templatestring
    Use a saved template's content instead of html.
  • preheaderstring
    Preview text.
  • reply_tostring
    Where replies go.
Request
curl https://maillayer.com/api/v1/campaigns \
  -H "Authorization: Bearer $MAILLAYER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "November update",
    "from": "Acme <[email protected]>",
    "list": ["Newsletter", "Customers"],
    "subject": "What we shipped in November",
    "html": "<h1>Hi {{ first_name | default: \"there\" }}</h1><p>…</p>"
  }'
Response · 201
{
  "id": "c7d2…",
  "name": "November update",
  "status": "draft",
  "subject": "What we shipped in November",
  "from": "Acme <[email protected]>",
  "lists": ["Newsletter", "Customers"],
  "scheduled_at": null,
  "sent_at": null,
  "ready_to_send": true,
  "problems": [],
  "recipients": 4812,
  "sends_over": null,
  …
}

Edit a draft#

PATCH/api/v1/campaigns/:id

Changes a draft. Send only the fields you want to change; the rest stay as they are. It takes the same fields as creating a draft, and preheader and reply_to can be removed with null. list replaces the lists. template replaces the content with that template's, and its subject and preheader too unless you give them. The response is the same as creating a draft, with ready_to_send, problems and recipients.

Request
curl -X PATCH https://maillayer.com/api/v1/campaigns/c7d2… \
  -H "Authorization: Bearer $MAILLAYER_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "subject": "What we shipped this month", "reply_to": null }'
Drafts and paused campaigns can be changed (see fix a mistake mid-send). Anything else returns 409 not_editable; unschedule a scheduled campaign in the dashboard first. Other errors: 422 nothing_to_change, invalid_from, missing_subject or missing_content; 404 list_not_found or template_not_found.

Fix a mistake mid-send#

Wrong link or a typo in a campaign that's already going out? Pause it, fix it with PATCH /campaigns/:id, then resume. The emails still queued go out with the fix; the ones already sent keep the earlier version. While paused you can change the subject, preheader, content, sender and reply-to, but not the lists (409 audience_locked): recipients were queued and paid for when sending started.

POST/api/v1/campaigns/:id/pause

Stops a sending campaign. Emails already handed over still go out. Returns the campaign with status: "paused", or 409 not_sending.

POST/api/v1/campaigns/:id/resume

Continues a paused campaign with your changes. A paced campaign keeps its spacing from now on. Errors: 409 not_paused, or cannot_resume when we paused it for review.

Request
curl -X POST https://maillayer.com/api/v1/campaigns/c7d2…/pause -H "Authorization: Bearer $MAILLAYER_KEY"

curl -X PATCH https://maillayer.com/api/v1/campaigns/c7d2… \
  -H "Authorization: Bearer $MAILLAYER_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "html": "<p>…the right link…</p>" }'

curl -X POST https://maillayer.com/api/v1/campaigns/c7d2…/resume -H "Authorization: Bearer $MAILLAYER_KEY"

After an edit, the campaign's edited field says when, and how many had gone out before it: { "at": "2026-11-19T16:40:00Z", "sent_before_edit": 1240 }. It's null for campaigns never edited mid-send.

Delete a draft#

DELETE/api/v1/campaigns/:id

Deletes a draft and returns { "id": "c7d2…", "deleted": true }. Campaigns that were sent or scheduled can't be deleted (409 not_draft).

Send or schedule#

POST/api/v1/campaigns/:id/send

An empty body sends now. The campaign must be a draft and ready.

Body

  • scheduled_atstring
    ISO 8601 time at least a minute from now, to schedule instead.
  • review_notestring
    Only when asked with review_required: a new sender's first campaign to 5,000+ people is reviewed before it goes out. Say where the contacts came from and how they agreed to get email. The campaign then shows status: "review".
  • warmuptrue | object
    Send in growing batches. true uses the defaults, or set initial_batch (50), growth_factor (2), interval_hours (24) and max_batch (10,000).
  • per_hournumber
    Spread the send evenly at this many emails per hour, 1 to 100,000. 120 sends one email every 30 seconds. Can't be combined with warmup.
Request
curl https://maillayer.com/api/v1/campaigns/c7d2…/send \
  -H "Authorization: Bearer $MAILLAYER_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "scheduled_at": "2026-11-18T09:00:00Z", "warmup": true }'
This emails real people and can't be undone. Errors: 409 not_draft, 422 not_ready, invalid_schedule or invalid_pace.

Get a campaign#

GET/api/v1/campaigns/:id

Status and results:

Response · 200
{
  "id": "c7d2…",
  "status": "sent",
  …,
  "warmup": null,
  "per_hour": null,
  "finishes_at": null,
  "stats": {
    "recipients": 4812, "sent": 4812, "delivered": 4760,
    "opened": 2015, "clicked": 402, "bounced": 52,
    "complained": 1, "unsubscribed": 9,
    "open_rate": 42.3, "click_rate": 8.4, "bounce_rate": 1.1
  },
  "dashboard_url": "https://maillayer.com/campaigns/c7d2…"
}

List campaigns#

GET/api/v1/campaigns?limit=20

Recent campaigns, newest first, in data. limit goes up to 100. See the Campaigns guide.