Preview an email

Overview

Render an email type with sample data, without sending.

Use this to check your edits.

You'll need the company_id, the template type, and optionally the content to preview.

Returns the rendered email. Content you send is used for this preview only and isn't saved; anything you leave out comes from the saved template. Merge fields are filled with their sample values, and [partnerTitle] with your real white-label title.

Prerequisites

  • A bearer token. See Authentication.
  • The account's id (company_id), with the email templates section turned on.
  • The email type, from List email types.

Base URL

EnvironmentURL
Productionhttps://production-api.shoutaboutus.com
Developmenthttps://development-api.shoutaboutus.com

Endpoint

POST /api/v1/account/white-label/email-templates/preview

Authentication

Partner or Account token

  • company_id must be inside your own account tree. A Partner token can use any account under the partner; an Account token only its own account.
  • An account outside your tree, or one that doesn't exist, is rejected with 422.
  • The email templates section must be turned on for the account's partner (email_templates_enabled in Get branding). When it's off, every email template call for that account returns 403 with The email template section is disabled for this account.
  • Types managed centrally by the platform return 403 (This template is managed centrally and cannot be edited here.).

Rate limit

This endpoint has no rate limit.

Request parameters

None.

Request body

Region fields are base64-encoded HTML.

Only the merge fields returned by List an email's merge fields for that type are accepted (the example decodes to <p>Hello [customerName]</p>, valid for user_welcome); any other token returns 422 Unknown variables for this template: [token].

FieldTypeRequiredDescription
company_idintegerYesThe account. Must exist and be inside your account tree.
typestringYesThe email type, from List email types.
headerstringNoThe header region. Base64-encoded HTML, up to 80,000 characters. Only merge fields from List an email's merge fields for this type are allowed. Left out: the saved version is used.
bodystringNoThe body region. Base64-encoded HTML, up to 80,000 characters. Only merge fields from List an email's merge fields for this type are allowed. Left out: the saved version is used.
footerstringNoThe footer region. Base64-encoded HTML, up to 80,000 characters. Only merge fields from List an email's merge fields for this type are allowed. Left out: the saved version is used.
signaturestringNoThe signature region. Base64-encoded HTML, up to 80,000 characters. Only merge fields from List an email's merge fields for this type are allowed. Left out: the saved version is used.
subject_overridestringNoThe subject, as plain text (not base64), up to 255 characters. Merge fields allowed. Left out: the saved subject is used.
template_modestringNoregions (header, body, footer and signature) or html (one full-HTML body in custom_html). Left out: the saved mode is used.
custom_htmlstringNoThe full-HTML body for html mode, base64-encoded, up to 400,000 characters. Left out: the saved version is used.
show_logobooleanNoShow (true) or hide (false) the logo for this preview only. Left out: the saved setting is used.

Request payload

{
  "company_id": 5994,
  "type": "user_welcome",
  "body": "PHA+SGVsbG8gW2N1c3RvbWVyTmFtZV08L3A+",
  "show_logo": true
}

Response body

The payload is inside data.

FieldTypeDescription
statusstringsuccess.
dataobjectThe rendered email.
data.htmlstringThe full email as an HTML document.
data.subjectstringThe subject, with merge fields filled in.

Response payload

{
  "data": {
    "status": "success",
    "data": {
      "html": "<!DOCTYPE html>\n<html><head><title>Acme Reviews</title></head><body><table class=\"wrapper\"><tr><td class=\"header\"><img src=\"https://d2ny6zb7otrnhl.cloudfront.net/white-label/logo/abc.png\" alt=\"Acme Reviews\"></td></tr><tr><td class=\"content-cell\"><p>Hello Jane Doe</p><p>Thank you,<br><strong>Acme Reviews</strong></p></td></tr></table></body></html>",
      "subject": "Welcome to Acme Reviews"
    }
  }
}

Examples

Success payload

See Response payload.

Error payload

403 Email templates section is off

{
  "message": "The email template section is disabled for this account.",
  "status": "error",
  "errors": []
}

403 Type managed centrally

{
  "message": "This template is managed centrally and cannot be edited here.",
  "status": "error",
  "errors": []
}

422 type isn't a known email type

{
  "message": "The selected type is invalid.",
  "errors": {
    "type": [
      "The selected type is invalid."
    ]
  }
}

422 Unknown merge field

{
  "message": "Unknown variables for this template: [recipientName]",
  "errors": {
    "body": [
      "Unknown variables for this template: [recipientName]"
    ]
  }
}

422 Account outside your tree

{
  "message": "The selected company id does not belong to your company hierarchy.",
  "errors": {
    "company_id": [
      "The selected company id does not belong to your company hierarchy."
    ]
  }
}
StatusMeaning
200The rendered email.
401The token is missing, expired or invalid.
403The email templates section is off for this account, or the type is managed centrally.
422company_id or type is missing or invalid, a region uses a merge field that isn't valid for this type, or the account is outside your tree.
500Unexpected server error.

Example request

curl --request POST \
  --url "https://production-api.shoutaboutus.com/api/v1/account/white-label/email-templates/preview" \
  --header 'Authorization: Bearer <bearer-token>' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{"company_id": 5994, "type": "user_welcome", "body": "PHA+SGVsbG8gW2N1c3RvbWVyTmFtZV08L3A+", "show_logo": true}'

Did this page help you?