NightmailDocs
Docs

Preview campaign audience

get/v1/campaigns/{id}/audience

Counts the saved audience right now: matched contacts and how many are eligible, suppressed or unsubscribed. With readiness=true it also reviews the send (CampaignReadiness): whether it is ready to go out as it is, why, and the daily batches it recommends; send it with pacing.plan "recommended" to follow them. Read-only and never frozen; send or schedule takes its own snapshot and consent is rechecked at dispatch.

Needs Audience & content: read on the whole workspace.

Example

import { createClient } from '@nightmail/sdk/client';
import { previewCampaignAudience } from '@nightmail/sdk';

const client = createClient({
  baseUrl: 'https://nightmail.dev',
  auth: scheme => scheme.scheme === 'bearer'
    ? process.env.NIGHTMAIL_API_KEY
    : undefined,
});

const result = await previewCampaignAudience({
  client,
  path: {
    "id": "resource_123"
  },
  throwOnError: true,
});

console.log(result.data);
curl --request GET \
  --url 'https://nightmail.dev/v1/campaigns/resource_123/audience' \
  --header "Authorization: Bearer $NIGHTMAIL_API_KEY"

Parameters

idrequiredpath · string
readinessquery · string

Also review the send (readiness).

Responses

200Success
CampaignAudienceCounts

Live counts for the saved audience: matched contacts, those eligible for marketing, and the suppressed, unsubscribed or risky remainder. For a required notice everyone not suppressed or risky is eligible and unsubscribed is 0. Read-only; sending freezes its own snapshot and rechecks consent at dispatch.

matchedrequiredinteger
eligiblerequiredinteger
suppressedrequiredinteger
unsubscribedrequiredinteger
riskyrequiredinteger

Contacts who could receive it but are flagged as risky (a disposable inbox, a mistyped provider, a role address, an address known to be undeliverable): the send skips them. Not in eligible.

riskyByReasonrequiredobject
riskyByReason.invalidrequiredinteger
riskyByReason.disposablerequiredinteger
riskyByReason.typo_domainrequiredinteger
riskyByReason.rolerequiredinteger
riskyByReason.deadrequiredinteger
riskyByReason.no_mail_domainrequiredinteger
topicExcludedinteger

With a topic: the subscribed contacts it leaves out (who opted out of it, or for a topic only people who opt in get, who didn’t). Counted in unsubscribed, not in eligible.

approximateboolean

The topic’s effect on this list couldn’t be counted in time: eligible and topicExcluded are estimated from the workspace’s choices about the topic. Sending counts it exactly.

readinessobject or null

With readiness=true: the send review of a marketing campaign with a sender; null for a required notice or a draft without a sender.

readiness.verdictrequiredstring

ready: 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 null

Why, 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.unavailablestring

Present 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.domainrequiredobject
readiness.historyrequiredobject
readiness.listrequiredobject
readiness.sizeJumprequirednumber or null

This send ÷ the largest campaign its domain sent in the last 90 days; null without one.

readiness.usualJumpnumber or null

This send ÷ the workspace's usual day (history.workspace.usualDay); null without one.

readiness.planrequiredobject or null

The recommended daily batches; null when one day covers everyone.

readiness.requiredrequiredobject or null
400, 401, 403, 404, 409, 413, 422, 429, 500, 503Request failed; use error.code and requestId to diagnose.
ApiError
errorrequiredobject
error.coderequiredstring
error.messagerequiredstring
error.requestIdrequiredstring
error.fieldstring
error.retryablerequiredboolean
error.resetAtstring

Next 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.requiredobject

On a 403 permission refusal: what the request needs that this credential lacks. The Nightmail-Required-Permission header says the same.