Generated from Postwind commit a19b2e4 OpenAPI 0.1.0 synced

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

Needs scope: readIdempotency-KeyMCP tool: preview_template operationId preview_template

Preview a message template

Renders the template’s latest version, with the latest versions of the partials it includes, as a subscriber would get it: the subscriber subscriber_id’s email, attributes and list name, or sample_attributes, or, with neither, sample values. The unsubscribe and confirmation links are samples (https://postwind.invalid/...); campaign.name is Sample campaign. The text is the text body, or the HTML made into text; when the project’s auto_footer is true, the footer with the unsubscribe link is added to each that does not show {{ unsubscribe_url }}. Nothing is written. Needs scope read.

Parameters

NameInTypeDescription
project_idrequired path string · uuid The project’s id
template_idrequired path string · uuid The message template’s id
Idempotency-Key header string

1–128 characters · pattern ^[!-~]{1,128}$

A key of the client’s choosing, one per request it means to send once (a UUID will do). A repeat with the same key and the same body within 24 h creates nothing again and gets the first answer, marked Idempotent-Replayed: true. The key belongs to the API key that sent it. Only a 2xx answer is kept: after any other answer the key is free again.

Request body

application/json · required

  • PreviewTemplateRequest object
  • sample_attributesobject | null

    Attributes to render with, as a subscriber’s: string, number or boolean values, up to 64 keys, up to 4 KB of JSON; any other attribute the template names is undefined. Not with subscriber_id; null or left out: none.

  • subscriber_idstring · uuid | null

    A subscriber of the project: its email, attributes and list name. Not with sample_attributes; null or left out: none.

Responses

200

The rendered message

HeaderTypeDescription
Idempotent-Replayedstring · enumtrue when the answer is a replay of an earlier request with the same Idempotency-Key; absent otherwise.
  • TemplatePreview 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 PreviewWarning
    3 fields
    • PreviewWarning object · all fields required
    • codestring

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

      example auto_footer_added

    • messagestring
    • partPreviewPart | null

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

      • subject
      • html
      • text

403

A project key without scope read (forbidden)

Problem (application/problem+json)

404

No such project, template or subscriber in it, or another project’s (not_found)

Problem (application/problem+json)

409

A request with the same Idempotency-Key has not answered yet (idempotency_key_in_progress)

Problem (application/problem+json)

422

Invalid fields, every one in errors (validation_failed): both subscriber_id and sample_attributes, invalid attributes, a partial (template_id), or the template does not render with this data, with the codes of saving; or the Idempotency-Key was used in the last 24 h for another request (idempotency_key_reused), or is not 1 to 128 visible ASCII characters (validation_failed, field Idempotency-Key)

Problem (application/problem+json)

429

The key is over its rate limit, api.rate_limit_per_minute requests a minute on this node (rate_limited)

HeaderTypeDescription
Retry-AfterintegerSeconds until the key’s next request passes; rounded up.

Problem (application/problem+json)

504

Postwind’s storage did not answer within its time limit (storage_timeout). A change the request makes may still take effect: check before repeating it. A repeat with the same Idempotency-Key never runs it twice: it is 409 idempotency_key_in_progress until the key’s 24 h end

Problem (application/problem+json)