Create campaign template
/v1/templatesNeeds Audience & content: write on the whole workspace.
Example
import { createClient } from '@nightmail/sdk/client';
import { createCampaignTemplate } from '@nightmail/sdk';
const client = createClient({
baseUrl: 'https://nightmail.dev',
auth: scheme => scheme.scheme === 'bearer'
? process.env.NIGHTMAIL_API_KEY
: undefined,
});
const result = await createCampaignTemplate({
client,
body: {
"name": "Example",
"description": ""
},
throwOnError: true,
});
console.log(result.data);curl --request POST \
--url 'https://nightmail.dev/v1/templates' \
--header "Authorization: Bearer $NIGHTMAIL_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"name": "Example",
"description": ""
}'Request body
CreateCampaignTemplatenamerequiredstringdescriptionstringResponses
201Success
CampaignTemplateidrequiredstringurlrequiredstringrevisionrequiredintegerdraftrequiredobjectdraft.namerequiredstringdraft.descriptionstringdraft.subjectstringdraft.previewTextstringdraft.fromNamestringdraft.replyTostring[]draft.htmlstringNightmail 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.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.
publishedrequiredobject or nullpublished.namerequiredstringpublished.descriptionstringpublished.subjectstringpublished.previewTextstringpublished.fromNamestringpublished.replyTostring[]published.htmlstringNightmail 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.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.
publishedRevisionrequiredinteger or nullarchivedAtrequiredstring or nullcreatedAtrequiredstringupdatedAtrequiredstring400, 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.