Pause campaign
/v1/campaigns/{id}/pauseStop releasing new recipients. Queued mail (a few seconds of the send rate) still dispatches. Resume continues from the same position; cancel still works while paused.
Needs Send email on the whole workspace. A person needs to be an owner or admin.
Example
import { createClient } from '@nightmail/sdk/client';
import { pauseCampaign } from '@nightmail/sdk';
const client = createClient({
baseUrl: 'https://nightmail.dev',
auth: scheme => scheme.scheme === 'bearer'
? process.env.NIGHTMAIL_API_KEY
: undefined,
});
const result = await pauseCampaign({
client,
path: {
"id": "resource_123"
},
body: {},
throwOnError: true,
});
console.log(result.data);curl --request POST \
--url 'https://nightmail.dev/v1/campaigns/resource_123/pause' \
--header "Authorization: Bearer $NIGHTMAIL_API_KEY" \
--header 'Content-Type: application/json' \
--data '{}'Parameters
idrequiredpath · stringRequest body
Responses
200Success
CampaignidrequiredstringurlrequiredstringDashboard URL for opening this campaign. Drafts open in the editor; launched campaigns open in review.
revisionrequiredintegerdraftrequiredobjectDrafts may omit sender, subject, content and audience until review or send, except that domain-restricted keys must supply a From address on one of their domains. Content is block HTML (see html); the same form is what the dashboard composer reads and writes, so people and agents edit one document. Simple {{name}} personalization works in text and quoted href/alt attributes; values are HTML-escaped and rendered URLs are validated. Durable campaign preparation is bounded and runs in background jobs.
draft.namerequiredstringdraft.fromstring or stringdraft.fromNamestringdraft.previewTextstringOptional preheader text. Inserted as escaped hidden text into each outgoing HTML snapshot; draft HTML is unchanged. When set, supply HTML without its own duplicate preheader.
draft.replyTostring[]draft.regionrequiredstringdraft.regionPinnedbooleanRegional MX only. False follows the From domain; the displayed region is a hint. A supplied region on create or a changed region on edit pins it. To unpin, pass false and omit region.
draft.subjectstring or stringdraft.attachmentsstring[]IDs of files uploaded first (uploadAttachment). One file is at most 8 MiB decoded when sent as base64 in JSON (POST /v1/attachments), or 25 MiB as raw bytes (POST /v1/attachments/upload, with the name URI-encoded in X-Nightmail-Filename and the type in Content-Type). One email carries at most 100 files and 25 MiB of them together, decoded. A workspace keeps at most 100 GiB of uploaded files. For anything larger, link to the file from the email.
draft.trackingbooleandraft.audienceobjectdraft.defaultsobjectdraft.unsubscribePageUrlstringYour own unsubscribe or preference page: HTTPS, no user name, password, whitespace or unsubscribe_token parameter, at most 1,000 characters. The footer's Unsubscribe link opens it with unsubscribe_token=<token> added; your page records the opt-out by POSTing that token to /unsubscribe/<token> on this API (idempotent). List-Unsubscribe keeps this API's one-click address, which records the opt-out itself and, opened in a browser, confirms it and then continues to your page. Omit to use the hosted page.
draft.topicIdstringThe topic the campaign is about (listTopics): it skips contacts who opted out of it, and its one-click unsubscribe opts out of this topic only. Not on a required notice.
draft.requiredNoticebooleanA required notice: a message every recipient must get whatever their marketing choice, such as a change to terms, prices or taxes, never a promotion. It goes to everyone in the audience who is not suppressed, people who unsubscribed from marketing included, without an Unsubscribe link or List-Unsubscribe header, and is paced, limited and paused like any campaign. Only where an operator turned required notices on for the workspace (requiredNotices in getWorkspaceSettings); 403 REQUIRED_NOTICES_OFF otherwise. Sending or scheduling one needs confirmRequiredNotice. Turned off later, a launched notice pauses before releasing anyone more (pause reason REQUIRED_NOTICES_OFF) and is resumed or rescheduled only once they are on again. Resumed after a list-probe quarantine, it goes on to everyone captured for it (never deliveredOnly).
draft.htmlstringsourceTemplateIdrequiredstring or nullsourceTemplateRevisionrequiredinteger or nullstaterequiredstringdraft: editable. preparing: the audience is being frozen (for large lists) and every message is being validated in the background. scheduled: validated and waiting for scheduledAt. sending: recipients are being released into the dispatch queue. paused: releasing stopped by the user or the health check; queued mail still dispatches. done: every recipient was released and dispatched. failed: capture, preparation or releasing failed (delivery.error); edit or launch again. canceled: terminal.
scheduledAtrequiredstring or nullarchivedAtrequiredstring or nullcreatedAtrequiredstringupdatedAtrequiredstringcountsrequiredobjectCounts of immutable campaign email records grouped by their current status, not cumulative provider events or delivery rates. Drafts with no queued emails have zero counts.
counts.totalrequiredintegercounts.byStatusrequiredobjectdeliveryrequiredobject or nullThe current launch: null until the campaign is sent or scheduled, and cleared by a new revision.
delivery.totalrequiredintegerFixed recipient count once the audience is frozen (recipients expected while a large audience is being captured).
delivery.preparedrequiredintegerRecipients whose message was validated.
delivery.expandedrequiredintegerRecipients materialized as immutable email records.
delivery.canceledrequiredintegerRecipients canceled before materialization. Materialized cancellations remain in counts.byStatus.canceled.
delivery.errorrequiredobject or nullWhy the campaign failed or was canceled by the system.
delivery.pacingrequiredobjectdelivery.consentrequiredobject or nullThe consent source confirmed at launch, if any.
delivery.pausedAtrequiredstring or nulldelivery.pauseReasonrequiredobject or nulldelivery.deliveredOnlyrequiredbooleanAfter a resumed list-probe quarantine: the rest goes only to contacts this workspace delivered to before; the others are counted in canceled. Never for a required notice.
delivery.waitingrequiredobject or nullWhy releasing recipients is currently held, and the best estimate of until when. list_probe: Hosted sent the first recipients (the list probe) and waits for their bounces and complaints before releasing the rest. feedback_lag: releasing is briefly held while priority safety feedback (bounces/complaints) catches up. ramp: a Hosted sender's first large campaigns release in growing hourly steps (sendEstimate.ramp); this hour's step is used up, or its delivery results are still coming in before the next step. link_record: the campaign has no host for its unsubscribe link right now (its workspace's sending is paused, or with own link hosts, its domain's isn't active yet); it continues by itself.
delivery.stoppedDomainsobject[]Recipient domains this campaign stopped sending to because its mail there kept bouncing for good (the rest of its recipients there are counted in canceled, are not charged and are not suppressed), oldest first, at most 50. Empty unless the guard is on.
delivery.feedbackLagrequiredobject or nullPresent while a campaign is preparing, sending, or paused when delivery feedback ingestion is at least 2 minutes behind.
sendEstimaterequiredobject or nullHow long sending takes, for a draft or a campaign that has recipients left to release. Null for a finished or canceled campaign; lists leave it out.
sendEstimate.recipientsrequiredinteger or nullRecipients still to release: for a draft, the last audience count (previewCampaignAudience; null before one); once launched, those not released yet.
sendEstimate.ratePerSecondrequirednumber or nullThe region's send rate the campaign plans at, per second, before its rate share; null until the region's quota was read.
sendEstimate.ramprequiredobject or nullWhere the campaign is on the ramp. A Hosted sender's first large campaigns release in hourly steps that grow (1,000 an hour at first), moving to the next step once an hour at this one went out and its delivery results are in and clean; more than 3% bounces or more than 0.08% complaints (at least 2) in a step pause the campaign. The first step not already proven by the workspace's largest clean marketing hour of the last 30 days is where it starts, so an established sender skips it. Null when no ramp applies (self-hosted, your own AWS account, simulated mail, an established sender, or past the last step). Transactional mail never waits for it.
sendEstimate.secondsrequiredinteger or nullHow long releasing the recipients left takes from when it starts (the campaign's last change, updatedAt, or scheduledAt): from the ramp, the daily cap (pacing.perDay), the rate share and the region's send rate. A draft is estimated without a daily cap at the full rate. An estimate: it assumes clean, prompt feedback and leaves out the list probe's wait, quota holds and other mail sharing the rate. Null when it cannot be told (no audience count or send rate yet).
sendEstimate.finishAtrequiredstring or nullA launched campaign: when its last recipient is expected to be released, as of its last change (updatedAt or scheduledAt, plus seconds). Null for a draft, while paused or failed, or when it cannot be told.
400, 401, 403, 404, 409, 413, 422, 429, 500, 503Request failed; use error.code and requestId to diagnose.
ApiErrorerrorrequiredobjecterror.coderequiredstringerror.messagerequiredstringerror.requestIdrequiredstringerror.fieldstringerror.retryablerequiredbooleanerror.resetAtstringNext capacity change for a Hosted rolling send limit.
error.detailsobject[]Every problem found, when there is more than one part, such as rule diagnostics with rule, line, column, message and hint, or a measurement, such as CONTENT_TOO_LARGE_TO_SCREEN with screenedBytes and limitBytes (and index in a batch).
error.requiredobjectOn a 403 permission refusal: what the request needs that this credential lacks. The Nightmail-Required-Permission header says the same.