POST content-blocks

Overview

POST content-blocks triggers the creation of new content blocks.

Resource URI

 https://api.yesmail.com/v2/content-blocks

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
201 Created Returned when the content block ID is created.
400 Bad Request Optional parameters not supported are included, required attributes are not include.
401 Unauthorized Api-Key or Api-User headers are missing or invalid.

 

Request

> POST /v2/content-blocks HTTP/1.1
> Host: api.yesmail.com
> Accept: application/json
> Content-Type: application/json
> Api-Key: my-secret-key
> Api-User: jefftronics3
{
  "name": "unique-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="
          }
        ]
      }
    ]
}

Response

Creates a new content block with "unique-block-name" as the name and "2" as the ID.

< 201 Created
< Cache-Control: no-cache
< Content-Type: application/json
< Last-Modified: Wed, 28 Sep 2015 16:08:20 GMT
< Tracking-Id: 88776655
{
  "id": "2",
  "lastUpdate": "2014-02-28T16:08:20Z",
  "name": "unique-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="
          }
        ]
      }
    ]
}