GET content-blocks/{id}

Overview

The GET /v2/content blocks/{id} method returns a single content block with the content type based on the Accept header value.

Request URI

 https://api.yesmail.com/v2/content-blocks/{id}

Request Parameters

Parameter Required Description
name Required Unique name for the content block (per Api-User).
body Required Section holding the body content of the email template. May be empty.
html Optional Text property with JSON-encoded HTML version of the email body content.
text Optional Text property with JSON-encoded text version of the email body content.
attachments Optional

Array of embedded images and attachments. Body content may refer to attached images instead or linking to external images.

  • name - Required if 'attachments' is used; unique name (per template) for the image or attachment.
  • type - Required if 'attachments' is used; media type as a string; typically "image/png", "image/jpeg" or similar.
  • base64 - Required if 'attachments' is used; actual image or attachment as base 64 encoded string.

HTTP Return Codes

Code Description
200 OK Returned when the content block ID exists, the payload will have the content blocks and embedded content, targeting and schedule.
401 Unauthorized Api-Key or Api-User headers are missing or invalid.
404 Not Found The content block ID cannot be found, may not exist for the given Api-User or is archived.

 

Request

This request returns the json version of the entity.

> GET /v2/content-blocks/12 HTTP/1.1
> Host: api.yesmail.com
> Accept: application/json
> Api-Key: my-secret-key
> Api-User: jefftronics3

Response

Response returns the content block with ID of 12.

{
  "id": "12",
  "lastUpdate": "2015-02-28T16:08:20Z",
  "name": "unique-content block-name",
  "body": [
      {
        "html": "<html><body>JSON-encoded HTML content<\/body><\/html>",
        "text": "JSON-encoded text content",
        "attachments": [
          {
            "name": "unique-name",
            "type": "media/type",
            "base64": "YmFzZSA2NCBlbmNvZGVkIGltYWdlIG9yIGZpbGU="
          }
        ]
      }
    ]
 }

Request

This request returns the HTML content only

> GET /v2/content-blocks/12 HTTP/1.1
> Host: api.yesmail.com
> Accept: text/html
> Api-Key: my-secret-key
> Api-User: jefftronics3

Response

HTML only is returned for immediate rendering in browsers

<html>
    <body>JSON-encoded HTML content</body>
</html>