# Nightmail API

Send, receive and reply to email on your own domains. 202 means queued, not delivered.

- [Interactive documentation](/docs)
- [OpenAPI 3.1 JSON](/openapi.json)
- [Agent index](/llms.txt)
- TypeScript package: `@nightmail/sdk`

[API index](/docs.md) · [Campaigns reference](/docs/tags/campaigns.md)

## Resume campaign

`POST /v1/campaigns/{id}/resume`

Continue releasing recipients from where a paused campaign stopped, or where a campaign that failed after releasing some recipients stopped (it continues on the same frozen snapshot, never a new one). After an automatic pause, the next health check runs 30 minutes later.

Operation ID: `resumeCampaign`

Permission: Needs Send email on the whole workspace. A person needs to be an owner or admin.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes |  |

### Request body

No fields.

### TypeScript SDK

```ts
import { createClient } from '@nightmail/sdk/client';
import { resumeCampaign } from '@nightmail/sdk';

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

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

console.log(result.data);
```

### cURL

```sh
curl --request POST \
  --url 'https://nightmail.dev/v1/campaigns/resource_123/resume' \
  --header "Authorization: Bearer $NIGHTMAIL_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{}'
```

### Responses

| Status | Description | Schema |
| --- | --- | --- |
| `200` | Success | object |
| `400`, `401`, `403`, `404`, `409`, `413`, `422`, `429`, `500`, `503` | Request failed; use error.code and requestId to diagnose. | object |

#### 200: Success

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes |  |
| `url` | string | yes | Dashboard URL for opening this campaign. Drafts open in the editor; launched campaigns open in review. |
| `revision` | integer | yes |  |
| `draft` | object | yes | Drafts 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.name` | string | yes |  |
| `draft.from` | string or string | no |  |
| `draft.fromName` | string | no |  |
| `draft.previewText` | string | no | Optional 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.replyTo` | string[] | no |  |
| `draft.region` | string | yes |  |
| `draft.regionPinned` | boolean | no | Regional 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.subject` | string or string | no |  |
| `draft.attachments` | string[] | no | 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.tracking` | boolean | no |  |
| `draft.audience` | object | no |  |
| `draft.defaults` | object | no |  |
| `draft.unsubscribePageUrl` | string | no | Your 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.topicId` | string | no | The 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.requiredNotice` | boolean | no | A 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.html` | string | no |  |
| `sourceTemplateId` | string or null | yes |  |
| `sourceTemplateRevision` | integer or null | yes |  |
| `state` | string | yes | draft: 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. |
| `scheduledAt` | string or null | yes |  |
| `archivedAt` | string or null | yes |  |
| `createdAt` | string | yes |  |
| `updatedAt` | string | yes |  |
| `counts` | object | yes | Counts 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.total` | integer | yes |  |
| `counts.byStatus` | object | yes |  |
| `delivery` | object or null | yes | The current launch: null until the campaign is sent or scheduled, and cleared by a new revision. |
| `delivery.total` | integer | yes | Fixed recipient count once the audience is frozen (recipients expected while a large audience is being captured). |
| `delivery.prepared` | integer | yes | Recipients whose message was validated. |
| `delivery.expanded` | integer | yes | Recipients materialized as immutable email records. |
| `delivery.canceled` | integer | yes | Recipients canceled before materialization. Materialized cancellations remain in counts.byStatus.canceled. |
| `delivery.error` | object or null | yes | Why the campaign failed or was canceled by the system. |
| `delivery.pacing` | object | yes |  |
| `delivery.consent` | object or null | yes | The consent source confirmed at launch, if any. |
| `delivery.pausedAt` | string or null | yes |  |
| `delivery.pauseReason` | object or null | yes |  |
| `delivery.deliveredOnly` | boolean | yes | After 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.waiting` | object or null | yes | Why 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.stoppedDomains` | object[] | no | 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.feedbackLag` | object or null | yes | Present while a campaign is preparing, sending, or paused when delivery feedback ingestion is at least 2 minutes behind. |
| `sendEstimate` | object or null | yes | How 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.recipients` | integer or null | yes | Recipients still to release: for a draft, the last audience count (previewCampaignAudience; null before one); once launched, those not released yet. |
| `sendEstimate.ratePerSecond` | number or null | yes | The region's send rate the campaign plans at, per second, before its rate share; null until the region's quota was read. |
| `sendEstimate.ramp` | object or null | yes | Where 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.seconds` | integer or null | yes | How 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.finishAt` | string or null | yes | A 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, 503: Request failed; use error.code and requestId to diagnose.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | object | yes |  |
| `error.code` | string | yes |  |
| `error.message` | string | yes |  |
| `error.requestId` | string | yes |  |
| `error.field` | string | no |  |
| `error.retryable` | boolean | yes |  |
| `error.resetAt` | string | no | Next capacity change for a Hosted rolling send limit. |
| `error.details` | object[] | no | 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.required` | object | no | On a 403 permission refusal: what the request needs that this credential lacks. The Nightmail-Required-Permission header says the same. |
