Skip to main content

Render Email Template Preview

POST 

/api/store-email-templates/render-preview

Renders unsaved email content exactly as it would be sent: tokens filled from a sample record (or sample data), wrapped in the store's brand layout, sanitized and CSS-inlined, with a plain-text alternative.

Required scope: settings:write

Grant this scope to your token under Settings → Developer → Personal Access Tokens.

Authentication: Requires Bearer token. Limited to 120 requests per minute.

Body fields:

  • template_id (int|string|null) — existing template; its saved subject/preheader/body are used for any field you omit
  • context (string) — required when template_id is null (e.g. sales_order)
  • event (string|null)
  • store_id (int|null) — whose layout and sender to use
  • subject (string|null, max 255), preheader (string|null, max 255), html_body (string|null, max 200000)
  • sample_record_id (int|null) — a record from List Email Template Sample Records; null uses sample data
  • layout_html (string|null) — unsaved brand layout to preview with

unresolved_tokens lists variables the context does not know (they render empty); warnings are non-blocking checks (subject length, Gmail clipping, missing sender, own page wrapper, invalid layout).

  • layout_settings (object|null) — unsaved brand quick settings (logo_url, primary_color, accent_color, footer_text, support_email, show_social) that replace the saved layout's settings for this render, so the layout editor previews them live

Scopes: API tokens need settings:write; when sample_record_id is set, also the read scope of that context's records (sales_order / bulk_sales_order / sales_credit → orders:read; purchase_order → purchase-orders:read; vendor_credit → accounting:read; bulk_purchase_order → suppliers:read; warehouse_transfer → warehouses:read), else 403 insufficient_scope. Mock-data previews need no extra scope.

Request​

Responses​

OK

Response Headers
    Content-Type