NightmailDocs
Docs

Update campaign template

patch/v1/templates/{id}

Needs Audience & content: write on the whole workspace.

Example

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

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

const result = await updateCampaignTemplate({
  client,
  path: {
    "id": "resource_123"
  },
  body: {
    "revision": 1,
    "draft": {
      "name": "Example",
      "description": "",
      "subject": "",
      "replyTo": [],
      "attachments": []
    }
  },
  throwOnError: true,
});

console.log(result.data);
curl --request PATCH \
  --url 'https://nightmail.dev/v1/templates/resource_123' \
  --header "Authorization: Bearer $NIGHTMAIL_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "revision": 1,
  "draft": {
    "name": "Example",
    "description": "",
    "subject": "",
    "replyTo": [],
    "attachments": []
  }
}'

Parameters

idrequiredpath · string

Request body

UpdateCampaignTemplate
revisionrequiredinteger
draftrequiredobject
draft.namerequiredstring
draft.descriptionstring
draft.subjectstring
draft.previewTextstring
draft.fromNamestring
draft.replyTostring[]
draft.htmlstring

Nightmail block HTML shared with the visual editor and renderer. Email-safe inline styles support color, typography, spacing, borders, radius and dimensions. May use {{placeholders}}, as campaigns do: a campaign created from the template copies them and fills them from each contact and its own defaults. Call getContentGuide before writing.

draft.attachmentsstring[]
draft.unsubscribePageUrlstring

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.

Responses

200Success
CampaignTemplate
idrequiredstring
urlrequiredstring
revisionrequiredinteger
draftrequiredobject
draft.namerequiredstring
draft.descriptionstring
draft.subjectstring
draft.previewTextstring
draft.fromNamestring
draft.replyTostring[]
draft.htmlstring

Nightmail block HTML shared with the visual editor and renderer. Email-safe inline styles support color, typography, spacing, borders, radius and dimensions. May use {{placeholders}}, as campaigns do: a campaign created from the template copies them and fills them from each contact and its own defaults. Call getContentGuide before writing.

draft.attachmentsstring[]
draft.unsubscribePageUrlstring

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.

publishedrequiredobject or null
published.namerequiredstring
published.descriptionstring
published.subjectstring
published.previewTextstring
published.fromNamestring
published.replyTostring[]
published.htmlstring

Nightmail block HTML shared with the visual editor and renderer. Email-safe inline styles support color, typography, spacing, borders, radius and dimensions. May use {{placeholders}}, as campaigns do: a campaign created from the template copies them and fills them from each contact and its own defaults. Call getContentGuide before writing.

published.attachmentsstring[]
published.unsubscribePageUrlstring

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.

publishedRevisionrequiredinteger or null
archivedAtrequiredstring or null
createdAtrequiredstring
updatedAtrequiredstring
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.