Campaigns and newsletters
Create, test, start, pause and report on campaigns and newsletters with an API key. Templates, scopes, credit cost and safety limits.
Everything the dashboard does for campaigns and newsletters is also available at
https://api.messagepipe.dev/v1/... with a workspace API key. The calls reach the same handlers
the dashboard uses, so validation, roles, the pre-flight and the consent rules are the ones a person
gets. Sends are charged from the same credit balance as transactional sends: there is no separate
API meter and no API surcharge.
The full contract, with request and response schemas, is the
Send API reference. Every operation carries its scope, role, rate class,
idempotency mode and credit cost in x-mp-* extension fields.
For a walk-through from an empty workspace to a sent newsletter, read Send your first newsletter by API.
Scopes
A key only gets the scopes someone ticks. A write scope does not imply its read scope.
| Scope | Allows |
|---|---|
campaigns:read | List and get campaigns, pre-flight, report. |
campaigns:write | Create, edit and duplicate drafts; pause and cancel. |
campaigns:send | Start, resume and test-send. These spend credits. Never pre-selected. |
content:read, content:write | Campaign templates, versions, layouts, content preview and checks. |
audience:read | Read brands, topics and consent statements (you need a brand and a topic to make a campaign). |
Campaigns
| Operation | Scope | Rate class | Idempotency-Key | Credits |
|---|---|---|---|---|
GET /v1/campaigns | campaigns:read | read | 0 | |
POST /v1/campaigns | campaigns:write | write | optional | 0 |
GET /v1/campaigns/{id} | campaigns:read | read | 0 | |
PATCH /v1/campaigns/{id} | campaigns:write | write | optional | 0 |
POST /v1/campaigns/{id}/duplicate | campaigns:write | write | optional | 0 |
GET /v1/campaigns/{id}/preflight | campaigns:read | read | 0 | |
GET /v1/campaigns/{id}/report | campaigns:read | read | 0 | |
POST /v1/campaigns/{id}/pause | campaigns:write | write | optional | 0 |
POST /v1/campaigns/{id}/cancel | campaigns:write | write | optional | 0 |
POST /v1/campaigns/{id}/test-send | campaigns:send | start | required | 1 per test recipient |
POST /v1/campaigns/{id}/start | campaigns:send | start | required | 1 per recipient message |
POST /v1/campaigns/{id}/resume | campaigns:send | start | required | 1 per message still to send |
A campaign names a brand_id, a topic_id (what the recipients subscribed to), usually a
segment_id and a template_id. kind is campaign (the default) or newsletter. Status moves
draft, scheduled, running, paused, completed, cancelled or failed. Editing a campaign
that has failed to start puts it back to draft.
What a send costs
| Step | Credits |
|---|---|
| Creating, editing and duplicating drafts, templates, segments and counts | 0 |
| Pre-flight, previews and content checks | 0 |
| Test send | 1 email credit per test recipient |
| Start / resume | 1 email credit per recipient message, taken just before the message is queued and refunded if it cannot be queued |
| A recipient who is suppressed, unsubscribed or has no valid consent | 0 (recorded, not sent) |
| Reading the report | 0 |
Credits are taken as the campaign sends, not all at once. The debit has a durable reference per campaign run and contact, so a retried worker, a Redis flush or a replayed request cannot charge the same message twice.
When the balance is zero, start is refused with 400 validation_failed and a no_credits
problem in details.problems: no run is created and nothing is reserved. When credits are
short (fewer than recipients), the start succeeds with a credits_short warning in its
preflight, and the run pauses with pause_reason: credits_exhausted when the balance reaches
zero. Add credits and call resume. GET /v1/campaigns/{id} and the report carry run.status and
run.pause_reason, so you do not need to poll the balance to see it; subscribe to the
campaign.paused and credits.low webhook events to
be told.
Starting safely
A key can start a bulk send with nobody watching, so the human steps of the dashboard are replaced by explicit limits.
- The pre-flight must pass.
startruns it again and refuses on any error-level problem (400,details.problems); a scheduled start is checked again when it fires. The200response carries thepreflightit passed. Idempotency-Keyis required onstart,resumeandtest-send(400naming the header when it is missing or over 255 characters). A repeat returns the first answer and queues nothing twice; the same key with a different request is422 idempotency_mismatch; a second call while the first is running is409 idempotency_in_progress. See Idempotency.- Daily recipient cap per key. Default 10,000 recipients per UTC day. Over it is
422 daily_recipient_cap, withcap,used,requested,remainingandresets_at. Unsent recipients are given back when a run is cancelled or fails. Only a workspace owner or admin raises the cap, in the dashboard; a key cannot change it. - Start rate limit. 10 requests per minute per key for
start,resumeandtest-send(Retry-Afteron429), 120 for writes and 600 for reads. Override per key in the dashboard. See Rate limits. - Consent is not bypassable. Suppressed addresses, topic consent, the brand's verified-domain rule and link screening apply to an API start exactly as to a dashboard start.
- Audit. Every change is audited with the key as the actor. Start, resume, cancel and test sends by a key are warnings. A running campaign that a key started carries on if the key is later revoked; it belongs to the workspace.
Content
Campaign content lives in campaign templates: POST /v1/campaign-templates takes a project_id,
a name and content with mode (markdown, html or mjml), source, subject, and optional
preheader and text. Edit with PUT /v1/campaign-templates/{id}, then publish. The content
routes (/v1/content/preview, /v1/content/preflight, /v1/content/variables, /v1/content/layouts)
render and check content without sending and cost nothing.
| Operation | Scope |
|---|---|
GET /v1/campaign-templates, GET /v1/campaign-templates/{id}, .../versions, .../versions/{v} | content:read |
POST /v1/campaign-templates, PUT /v1/campaign-templates/{id}, .../publish, .../archive | content:write |
GET /v1/content/variables, GET /v1/content/layouts, GET /v1/content/layouts/{id} | content:read |
POST /v1/content/preview, POST /v1/content/preflight, POST /v1/content/layouts/validate | content:write |
POST /v1/content/layouts, PUT /v1/content/layouts/{id}, POST /v1/content/layouts/{id}/archive | content:write |
Previews and checks can render a real contact's data, which the dashboard shows to marketers only, so they need the write scope.
Not available by API
Campaign archive (DELETE) and the standalone /content/test-send are not exposed; a campaign's own
test-send is. Provider credentials, billing, members and API-key management stay in the dashboard.