Generated from Postwind commit a19b2e4 OpenAPI 0.1.0 synced

Templates HTTP API

POST/api/v1/projects/{project_id}/templates/{template_id}/preview

preview_template

Renders a message template as a subscriber would get it, before anything is sent: the subject, the HTML and the text, with warnings.

Call it
to check the layout and the variables of a template, for one subscriber (subscriber_id: its email, attributes and list name) or with sample_attributes (not both; with neither, every attribute is the text sample). The latest version of the template and of each partial it includes is rendered; the unsubscribe links are samples (https://postwind.invalid/...) and campaign.name is Sample campaign. A template without a text body gets its text made from the HTML; when the project’s auto_footer is true, a part that does not show {{ unsubscribe_url }} gets the footer with the unsubscribe link.
Needs
an admin key with project_id, or a project key with scope read (its own project; the argument is ignored), and a message template: a partial is validation_failed on template_id; a subscriber of another project is not_found; a template that does not render with this data is validation_failed with the errors of saving. Nothing is written.
Returns
subject, html, text and warnings (code, part, message), the same as POST /api/v1/projects/{project_id}/templates/{template_id}/preview.

Arguments

  • object
  • template_idstring · uuidrequired

    The message template’s id.

  • project_idstring · uuid | null

    The template’s project. An admin key must pass it; a project key’s own project is used and this is ignored.

  • sample_attributesmap of string → string | number | boolean | null

    Attributes to render with, as a subscriber’s (string, number or boolean values). Not with subscriber_id; with neither, every attribute is the text sample.

  • subscriber_idstring · uuid | null

    A subscriber of the project to render for: its email, attributes and list name. Not with sample_attributes.

No other arguments are accepted.

Result

The result comes back as structuredContent, with the same JSON as a text block.

  • object · all fields required
  • htmlstring

    The HTML part, with the automatic footer when it was added.

  • subjectstring
  • textstring

    The text part: the text body, or the HTML made into text; with the automatic footer when it was added.

  • warningsarray of PreviewWarningOutput
    3 fields
    • PreviewWarningOutput object · all fields required
    • codestring

      subscriber_not_active, subscriber_list_deleted, empty_subject, html_too_large, auto_footer_added, text_from_html.

    • messagestring
    • The part it is about; null: the message as a whole.

      • subject
      • html
      • text

Definitions

PreviewPartOutput

The part of a message a warning is about.

string · enum

  • subject
  • html
  • text

PreviewWarningOutput

Something about the preview to look at.

  • object · all fields required
  • codestring

    subscriber_not_active, subscriber_list_deleted, empty_subject, html_too_large, auto_footer_added, text_from_html.

  • messagestring
  • The part it is about; null: the message as a whole.

    • subject
    • html
    • text

Errors

A failed call answers isError: true with a code from the same table as the HTTP API, and detail. How tools report errors

HTTP API

The same operation over HTTP: POST /api/v1/projects/{project_id}/templates/{template_id}/preview