POST emails/preview

Overview

POST /v2/emails/preview retrieves a fully rendered version of an email message based on a subscribers profile. This capability is useful for designing applications that deliver emails outside of the Yesmail Marketing Platform. 

Resource URI

 https://api.yesmail.com/v2/emails/preview

Call Description

This call returns different results based on the Accept header value made with the request. Content-Type: application/json must always be included.

Accept: application/json - Returns a JSON encoded response with envelope properties, text content and HTML content.

Accept: text/html- Returns just the HTML content.

Accept: text/plain - Returns just the text content

HTTP Return Codes

Code

Description

200 OK

The request has been processed.

400 Bad Request

The request could not be understood by the server due to malformed syntax.

401 Unauthorized

The request requires user authentication.  Invalid Api-User and/or Api-Key header value.

404 Not Found

If the specific templateId or renderSubscriber Id is not found.
Request Payload: 
{
    "content": {
        "templateId": "1456917"
    },
    "renderSubscriber": {
        "id": "jsmith@example.com"    ;client defined id
    }
}
Response Payload: 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
 
<html>
<head>
    <meta content="en-us" http-equiv="content-language">
 
    <title></title>
</head>
 
<body>
    <h1>Sample Email</h1>
 
    <p>This is an example HTML payload</p>
 
    <p>Yesmail's <a href=
    "https://developer.yesmail.com?x=some-value&amp;y=some-value">API
    Guide</a></p><br>
 
    <p>-The Yesmail Team</p><br>
 
    <p>If you no longer wish to receive these emails, use this link to <a href=
    "https://api.yesmail.com/v2/subscribers/unsubscribe?s=ZXVI&amp;i=12345678">unsubscribe</a></p>
</body>
</html>
{
  "headers": {
    "campaign": "Sample Campaign",
    "from": "team@yesmail.com",
    "from-friendly": "Yesmail Team",
    "keywords": "Sample|Test",
    "name": "Sample Email",
    "reply-to": "team@yesmail.com",
    "reply-to-friendly": "Yesmail Team",
    "sender": "team@yesmail.com",
    "sender-friendly": "Yesmail Team",
    "subject": "Sample Email"
  },
  "text": {
    "content": "[Sample Email]\r\n\r\nThis is an example text payload.\r\n\r\nYesmail's API Guide <https:\/\/developer.yesmail.com?x=x-value&y=y-value>\r\n\r\n-The Yesmail Team\r\n\r\nIf you no longer wish to receive these emails, go to the following link to =\r\nunsubscribe: https:\/\/api.yesmail.com\/v2\/subscribers\/unsubscribe?s=ZXVI&i=12=\r\n345678"
  },
  "html": {
    "content": "<!DOCTYPE HTML PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/html4\/loose.dtd\"><html><head>\r\n<meta http-equiv=\"content-language\" content=\"en-us\">\r\n<title><\/title>\r\n<\/head>\r\n<body>\r\n<h1>Sample Email<\/h1>\r\n<p>This is an exmaple HTML payload<\/p>\r\n<p>Yesmail's <a href=\"https:\/\/developer.yesmail.com?x=some-value&y=some-value\">API Guide<\/a><\/p>\r\n<br\/>\r\n<p>-The Yesmail Team<\/p>\r\n<br\/>\r\n<p>If you no longer wish to receive these emails, use this link to \r\n<a href=\"https:\/\/api.yesmail.com\/v2\/subscribers\/unsubscribe?s=ZXVI&i=12345678\">unsubscribe<\/a><\/p>\r\n<\/body>\r\n<\/html>\r\n"
  }
}