Block templates


Renders: [application/json, text/html, application/xml]

Parses: [application/json, application/x-www-form-urlencoded, multipart/form-data]


Required fields

  • subject

Optional fields

  • blockdocument

Readonly fields

  • id
  • url
  • updated
  • preview_url
  • layout_slug
  • responsive

GET /mails/templates/block/

Returns a list of block templates, like usual we provide next, prev, count and the results.

Possible url parameters are:

  • page: <int>

Example:

GET /mails/templates/block/

{
    "count": 16,
    "next": "http://api.getanewsletter.com/v3/mails/templates/block/?page=2",
    "previous": null,
    "results": [
        {
            "id": 12,
            "url": "http://gantest.com:8000/v3/mails/templates/block/12/",
            "subject": "No header and no columns",
            "updated": "2012-12-21T07:51:02Z",
            "preview_url": "http://gantest.com:8000/v3/mails/templates/block/12/preview/",
            "layout_slug": "",
            "responsive": false
        }
    ]
}

GET /mails/templates/block/<id>/

The details view includes the information about the block document, its properties, areas and block data.

{
    "id": 7678,
    "url": "http://gantest.com:8000/v3/mails/templates/block/7678/",
    "subject": "No header and no columns",
    "blockdocument": {
        "body_background": "eeeeee",
        "content_background": "ffffff",
        "h_font_family": "Arial",
        "h_font_size": 30,
        "h_font_color": "333333",
        "p_font_family": "Arial",
        "p_font_size": 14,
        "p_font_color": "333333",
        "p_link_color": "2a5db0",
        "margin_topbottom": 0,
        "margin_leftright": 0,
        "separator_color": "e6e6e6",
        "separator_height": 4,
        "header_footer_font_family": "Arial",
        "header_footer_font_size": 11,
        "header_footer_font_color": "555555",
        "areas": {
            "1": {
                "width": 580
            },
            "2": {
                "width": 580
            }
        },
        "blockdata_set": [
            {
                "area": 1,
                "sort_order": 1,
                "block": {
                    "id": 48,
                    "url": null,
                    "category": 0,
                    "type": 0,
                    "belongs_to": 0,
                    "slug": "responsive-text",
                    "name": "Responsive-Text",
                    "thumb_url": "http://gantest.com:8000/ganeditor/media/images/blocks/1-txt.gif",
                    "components": [
                        {
                            "type": "text",
                            "name": "txt1"
                        }
                    ],
                    "layout": {
                        "id": 46,
                        "content": "<div  style=\"padding:0 15px\">###txt1###</div>"
                    },
                    "editable": true
                },
                "data": {
                    "txt1-text": "<p align=\"center\">Nyhetsbrev med senaste nytt. Problem att visa det?&nbsp;<a href=\"##view_online##\">Se det i webbl&auml;saren</a>.</p>"
                }
            },
            {
                "area": 2,
                "sort_order": 1,
                "block": {
                    "id": 48,
                    "url": null,
                    "category": 0,
                    "type": 0,
                    "belongs_to": 0,
                    "slug": "responsive-text",
                    "name": "Responsive-Text",
                    "thumb_url": "http://gantest.com:8000/ganeditor/media/images/blocks/1-txt.gif",
                    "components": [
                        {
                            "type": "text",
                            "name": "txt1"
                        }
                    ],
                    "layout": {
                        "id": 46,
                        "content": "<div  style=\"padding:0 15px\">###txt1###</div>"
                    },
                    "editable": true
                },
                "data": {
                    "txt1-text": "<p align=\"center\">Du f&aring;r detta nyhetsbrev eftersom du &auml;r en kund till oss eller f&ouml;r att du har skrivit upp dig p&aring; v&aring;rt nyhetsbrev.<br /><a href=\"##unsubscribe##\">Skulle du vilja avsluta din prenumeration, klicka h&auml;r</a>.</p>"
                }
            }
        ],
        "layout": {
            "id": 90,
            "content": "<table id=\"document\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"600\">\n    <tr>\n        <td align=\"center\">\n            <div id=\"document_header\">\n                <table width=\"560\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n                    <tbody>\n                        <tr>\n                            <td>\n                                <table style=\"border-spacing:0;\" id=\"area_1\" class=\"area\" width='100%'>\n                                    <tbody>###area1###</tbody>\n                                </table>\n                            </td>\n                        </tr>\n                    </tbody>\n                </table>\n            </div>\n            <table id=\"margins\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"####content_background###\" style=\"border: ###borderWidth### ###borderStyle### ###borderColor###;\">\n                <tr>\n                    <td align=\"center\" id=\"margins_td\">\n                        <table id=\"main_content\" width=\"580\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"resp-measure\">\n                            <tbody>\n\n                                <!-- main-content, one column\n                                ================================================== -->\n                                <tr>\n                                    <td width=\"15\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/ AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" width=\"15\" height=\"1\" /></td>\n                                    <td width=\"550\" class=\"column\"> <!-- one column -->\n                                        <table width=\"100%\" style=\"border-spacing: 0;\" id=\"area_4\" class=\"area content_background\">\n                                            <tbody>###area4###</tbody>\n                                        </table>\n                                    </td>\n                                    <td width=\"15\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/ AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" width=\"15\" height=\"1\" /></td>\n                                </tr>\n\n                                <!-- Footer\n                                ================================================== -->\n                                <tr>\n                                    <td width=\"15\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/ AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" width=\"15\" height=\"1\" /></td>\n                                    <td width=\"550\" class=\"column\"> <!-- one column -->\n                                        <table width=\"100%\" style=\"border-spacing: 0;\" id=\"area_5\" class=\"area footer_background\">\n                                            <tbody>###area5###</tbody>\n                                        </table>\n                                    </td>\n                                    <td width=\"15\"><img src=\"data:image/gif;base64,R0lGODlhAQABAID/ AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" width=\"15\" height=\"1\" /></td>\n                                </tr> <!-- /main-content -->\n                            </tbody>\n                        </table>\n                    </td>\n                </tr>\n            </table>\n            <div id=\"document_footer\">\n                <table width=\"560\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n                    <tbody id=\"sortable-tbody\">\n                        <tr>\n                            <td>\n                                <table style=\"border-spacing:0;\" id=\"area_2\" class=\"area\" width=\"100%\">\n                                    <tbody>###area2###</tbody>\n                                </table>\n                            </td>\n                        </tr>\n                    </tbody>\n                </table>\n            </div>\n        </td>\n    </tr>\n</table><!-- End document -->"
        }
    },
    "updated": "2013-06-04T09:26:23Z",
    "preview_url": "http://gantest.com:8000/v3/mails/templates/block/7678/preview/",
    "layout_slug": ""
}

PUT /mails/templates/block/<id>/

Updates a template. Required fields are:

  • subject
  • blockdocument

PATCH /mails/templates/block/<id>/

Patch is used for partial updates. Use it if you want to update a template but don't want to overwrite all values.

Example:

PATCH /mails/templates/block/12
{
    "subject": "Mail subject"
}

Response
{
    "url": "https://api.getanewsletter.com/v3/mails/templates/block/12/",
    "subject": "Mail subject",
    ...
}

DELETE /mails/templates/block/<id>/

Deletes the email.


Actions


Copy template

POST /mails/templates/block/<id>/copy/

Example:

POST /mails/templates/block/12/copy/
{}

Response
{
    "id": 5,
    "url": "http://api.getanewsletter.com/v3/mails/templates/block/13/",
    "subject": "Copy of Header and right column",
    "blockdocument": {
        ...
    },
    "updated": "2014-06-20T12:13:52.286Z",
    "preview_url": "http://api.getanewsletter.com/v3/mails/templates/block/5/preview/",
    "layout_slug": ""
}

Create draft email

POST /mails/templates/block/<id>/draft/

Example:

POST /mails/templates/block/12/draft/
{}

Response

{
    "id": 192,
    "url": "http://api.getanewsletter.com/v3/mails/drafts/192/",
    "subject": "No header and no columns",
    "body": null,
    "blockdocument": {
        ...
    },
    "plain_text": null,
    "css": null,
    "type": 1,
    "updated": "2014-06-20T12:24:26.060Z",
    "created": "2014-06-20T12:24:26.060Z",
    "preview_url": "http://api.getanewsletter.com/v3/mails/drafts/192/preview/",
    "send_url": "http://api.getanewsletter.com/v3/mails/drafts/192/send/"}

Preview template

GET /mails/templates/block/<id>/preview/

Returns rendered version of the template.