PATCH content-blocks/{id}

Overview

PATCH content-blocks/{id} triggers an update for existing content blocks. Since this is a PATCH method, any fields not provided will be ignored. All fields are optional, except body array which must be included. Only fields in the request payload will be updated. An empty string value will remove content for optional fields. Attachments cannot be deleted with this method.

Resource URI

PATCH 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.
subscriptions Required Array of subscriptions that the content blocks are associcated with. This controls visibility of the content blocks in the UI.

HTTP Return Codes

Code Description
200 OK  Returned when the content block is successfully updated.
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.
404 Not Found  ID is invalid or not found.

 

Request

Request to update the unique-block-name content block (ID = 2).

> PATCH /v2/content-blocks/2 HTTP/1.1
> Host: api.yesmail.com
> Content-Type: application/json
> Accept: 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="
          }
        ],
       "subscription": [
		"4 finger club"
	]
      }
    ]
}
 

Response

Successfully updates the content block with the "unique-name" attachment.

< 200 OK
< 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="
          }
        ],
       "subscription": [
		"4 finger club"
	]
      }
    ]
}