Schedule campaign
/v1/campaigns/{id}/scheduleAccept the current revision for durable scheduled delivery. Small audiences (<=5,000 list members) freeze immediately while larger audiences freeze and validate in the background during preparing; no recipient is materialized or sent before scheduledAt. The 202 queued count is recipients expected; delivery.total on GET /v1/campaigns/{id} is authoritative once the audience is frozen. Every email’s footer shows the workspace’s postal address under the Unsubscribe link, as US law (CAN-SPAM) requires, frozen as it is now: without one the request is refused with 422 POSTAL_ADDRESS_REQUIRED (set postalAddress with updateWorkspaceSettings). Hosted campaigns screen every distinct copy during launch and prepare before any row enters the sending queue, each distinct copy only once: recipients whose personalized copies read the same share one verdict. The campaign’s own copy, placeholders unresolved, is screened first and may hold 131,072 bytes of screened text (installation default; 422 CONTENT_TOO_LARGE_TO_SCREEN with error.details[0] { screenedBytes, limitBytes } otherwise); so may each copy. A failing copy never enters the sending queue (CONTENT_REJECTED_SPAM); when refused copies pass 5% and 10 recipients the campaign pauses once for review, and a positive verdict on the campaign’s own copy fails it before anyone is sent to. Audiences on lists up to 5,000 members freeze inside this request; larger audiences freeze in the background during preparing so this request returns immediately. CampaignQueued.queued is recipients expected; delivery.total on GET /v1/campaigns/{id} is authoritative once the audience is frozen. Late capture failures (such as EMPTY_AUDIENCE or AUDIENCE_LIMIT_EXCEEDED) move the campaign to failed with delivery.error and leave the draft editable.
Needs Send email on the whole workspace. A person needs to be an owner or admin.
Example
import { createClient } from '@nightmail/sdk/client';
import { scheduleCampaign } from '@nightmail/sdk';
const client = createClient({
baseUrl: 'https://nightmail.dev',
auth: scheme => scheme.scheme === 'bearer'
? process.env.NIGHTMAIL_API_KEY
: undefined,
});
const result = await scheduleCampaign({
client,
path: {
"id": "resource_123"
},
body: {
"revision": 1,
"scheduledAt": "2026-09-18T19:00:00Z"
},
throwOnError: true,
});
console.log(result.data);curl --request POST \
--url 'https://nightmail.dev/v1/campaigns/resource_123/schedule' \
--header "Authorization: Bearer $NIGHTMAIL_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"revision": 1,
"scheduledAt": "2026-09-18T19:00:00Z"
}'Parameters
idrequiredpath · stringIdempotency-Keyheader · stringOptional. Makes retries safe. Repeating a request with the same key and the same body returns the original result without performing the write again. While the first request with a key is still running, a duplicate returns 409 IDEMPOTENCY_IN_PROGRESS with Retry-After: retry with the same key, never a new one. Reusing a key with a different body returns 409 IDEMPOTENCY_CONFLICT. Keys are scoped to the API key and request path. This route's keys do not expire: a repeat with the same key replays the original result at any later time. Without a key, every request is processed, so a retried send can deliver twice.
Request body
CampaignScheduleInputrevisionrequiredintegerpacingobjectpacing.perDayinteger or nullRelease at most this many recipients per rolling 24-hour window. Omit or null for no daily cap. Delivery always also respects the SES 24-hour quota.
pacing.autoPausebooleanPause automatically if the bounce rate exceeds 2% (after 1,000 accepted) or the complaint rate exceeds 0.08% (after 5,000 accepted). Hosted shared sending requires true; false is rejected.
pacing.rateSharenumberMaximum fraction of the SES per-second send rate this campaign may use; the rest stays free for transactional mail and other campaigns. Defaults to 0.5 for paced campaigns; campaigns sent without pacing use the full rate.
pacing.planstringSend in the daily batches previewCampaignAudience recommends (readiness.plan), worked out again at launch: the most engaged contacts first, never-mailed last. Not with perDay.
consentobjectThe sender confirms everyone on the list agreed to this mail, and where that consent comes from. Lets a send the review requires a ramp for (readiness.verdict ramp_required) go out without the plan. Stored with the campaign, with who and when, and in the workspace's Activity. An agent asks the person first.
consent.confirmedrequiredbooleanconsent.sourcerequiredstringWhere this list's consent comes from, for example "Signed up at checkout on our site since 2023".
confirmRequiredNoticebooleanRequired for a required notice (422 REQUIRED_NOTICE_UNCONFIRMED without it): the sender confirms it is a required notice with no promotion. Recorded with who and when. An agent asks the person first.
scheduledAtrequiredstringResponses
202Success
CampaignQueuedidrequiredstringstaterequiredstringqueuedrequiredintegerRecipients expected (exact for lists up to 5,000 members and unsegmented lists once list counts are enabled; may be 0 if an uncounted large list exceeds the 200 ms launch budget without a prior preview); delivery.total is authoritative once the audience is frozen.
scheduledAtrequiredstring or nullsimulatedrequiredbooleanriskyobject or nullRecipients the send skips as risky contacts, by reason: exact when queued is; null when a large audience could not be counted at launch.
risky.totalrequiredintegerrisky.byReasonrequiredobjectreadinessobject or nullThe send review as of the launch (list.neverMailed is not counted then); null for a required notice.
readiness.verdictrequiredstringready: send as you like. ramp_recommended: the plan is suggested. ramp_required: a Hosted send this large, from a new domain or far above anything its domain has sent, goes out with the plan (pacing.plan "recommended"), a daily limit no larger than its first day, or a confirmed consent source (consent); 422 RAMP_REQUIRED otherwise.
readiness.summaryrequiredstring or nullWhy, in one or two plain sentences, when a ramp is recommended or required.
readiness.reasonsrequiredobject[]The findings behind the verdict in the original codes, one per code: a newly registered domain, one new here and a new link domain read NEW_DOMAIN, a jump over the usual day SIZE_JUMP; blocklist findings appear only in findings. Prefer findings.
readiness.findingsobject[]Every finding behind the verdict, with its own code: NEW_REGISTRATION (registered recently, from public registry data), NEW_HERE (registered long ago, new to this workspace), NEW_DOMAIN (added recently, registration not known), USUAL_JUMP, NEW_LINK_DOMAIN, BLOCKLISTED_BEFORE (an earlier send drew replies naming a blocklist and none has finished without since), BLOCKLIST_UNCOUNTED (a recent send's blocklist replies aren't counted yet, so it isn't taken for clean), and the original codes.
readiness.unavailablestringPresent when part of the review couldn't be worked out just now (sizing the plan): what was left out, in a sentence. The review is then the one without that part, and its verdict is at least ramp_recommended. A launch that fails the same way is refused, 503 SEND_PLAN_UNAVAILABLE (retryable), with nothing sent.
readiness.domainrequiredobjectreadiness.historyrequiredobjectreadiness.listrequiredobjectreadiness.sizeJumprequirednumber or nullThis send ÷ the largest campaign its domain sent in the last 90 days; null without one.
readiness.usualJumpnumber or nullThis send ÷ the workspace's usual day (history.workspace.usualDay); null without one.
readiness.planrequiredobject or nullThe recommended daily batches; null when one day covers everyone.
readiness.requiredrequiredobject or null400, 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.