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.
settings:writeGrant 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 omitcontext(string) — required when template_id is null (e.g. sales_order)event(string|null)store_id(int|null) — whose layout and sender to usesubject(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 datalayout_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
- 200
- 401
- 403
- 422
- 429
OK
Response Headers
Unauthenticated — the bearer token is missing, revoked, expired, or malformed. Never retry automatically; fix the credential. See the Errors guide.
Forbidden — the token lacks a required scope, the endpoint is not available to API tokens, or the user behind the token lacks the permission. A human must adjust the token scopes or user permissions; do not retry.
Unprocessable Content
Response Headers
Rate limited — platform limit is 1,000 requests/min; individual tokens may carry lower limits. Honor the Retry-After header before retrying. See the Rate Limits guide.