NightmailDocs
Docs

Render campaign template preview image

get/v1/templates/{id}/preview-image

Renders a template draft or published revision as a full-page PNG. Inline template assets are embedded, so agents can verify the result without browser automation. Answers 303 See Other: Location (also url in the body) serves the result as JSON { data, mimeType } for five minutes without a credential, so HTTP clients that follow redirects receive it as before. Inline images may total about 1.5 MiB, counted once per reference (413 PREVIEW_TOO_LARGE above); while the server renders other previews it answers 429 PREVIEW_BUSY with Retry-After. HEAD is refused with 405: it would render a preview it cannot return.

Needs Send email.

Example

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

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

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

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

Parameters

idrequiredpath · string
publishedquery · string

Responses

200What the 303 link serves.
CampaignTemplatePreviewImage
datarequiredstring

Canonical base64 PNG screenshot.

mimeTyperequiredstring
revisionrequiredinteger
publishedrequiredboolean
303The preview is stored: follow Location within five minutes.
PreviewImageLink
urlrequiredstring

Serves the 200 response (the base64 PNG as JSON) without a credential until expiresAt.

expiresAtrequiredstring
mimeTyperequiredstring
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.