HTML templates

The HTML templates gives you full control over your templates. You have the ability to set subject, body, a plain text version and css.


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

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


Required fields

  • subject
  • body

Optional fields

  • plain_text
  • css

Readonly fields

  • id
  • url
  • updated
  • created
  • preview_url

Example HTML template

{
    "id": 4,
    "url": "https://api.getanewsletter.com/v3/mails/templates/html/4/",
    "subject": "Get a Newsletter template",
    "plain_text": "This is a HTML template.",
    "css": "",
    "body": "<b>This is a HTML template<b>",
    "updated": "2013-09-06T07:20:31Z",
    "created": "2013-09-06T07:20:31Z",
    "preview_url": "https://api.getanewsletter.com/v3/mails/templates/html/4/preview/"
}

GET /mails/templates/html/

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

Possible url parameters are:

  • page: <int>

Example:

GET /mails/templates/html/

{
    "count": 46,
    "next": "https://api.getanewsletter.com/v3/mails/templates/html/?page=3,
    "previous": "https://api.getanewsletter.com/v3/mails/templates/html/?page=2,
    "results": [
        {
            "id": 4,
            "url": "https://api.getanewsletter.com/v3/mails/templates/html/4/",
            "subject": "Get a Newsletter template",
            "updated": "2013-09-06T07:20:31Z",
            "created": "2013-09-06T07:20:31Z",
            "preview_url": "https://api.getanewsletter.com/v3/mails/templates/html/4/preview/"
        },
        {
            "id": 5,
            "url": "https://api.getanewsletter.com/v3/mails/templates/html/5/",
            "subject": "Get a Newsletter template",
            "updated": "2013-09-06T07:20:31Z",
            "created": "2013-09-06T07:20:31Z",
            "preview_url": "https://api.getanewsletter.com/v3/mails/templates/html/5/preview/"
        }
    ]
}

GET /mails/templates/html/<id>/

The details view includes the following additional fields: body, plain_text and css.

{
    "id": 4,
    "url": "https://api.getanewsletter.com/v3/mails/templates/html/4/",
    "subject": "Get a Newsletter template",
    "plain_text": "This is a HTML template.",
    "css": "",
    "body": "<b>This is a HTML template<b>",
    "updated": "2013-09-06T07:20:31Z",
    "created": "2013-09-06T07:20:31Z",
    "preview_url": "https://api.getanewsletter.com/v3/mails/templates/html/4/preview/"
}

POST /mails/templates/html/

Creates a new template. Required fields are:

  • subject
  • body

Optional fields are:

  • plain_text
  • css

Example:

POST /mails/templates/html/

{
    "subject": "Mail subject",
    "body": "<b>This is a HTML template<b>",
    "plain_text": "This is a HTML template.",
    "css": "h1 {color: red; }"
}

Response

{
    "url": "https://api.getanewsletter.com/v3/mails/templates/html/12/",
    "subject": "Get a Newsletter template",
    "body": "<b>This is a HTML template<b>",
    "plain_text": "This is a HTML template.",
    "css": "h1 {color: red; }",
    "type": 0,
    "updated": "2013-09-06T07:20:31Z",
    "created": "2013-09-06T07:20:31Z",
    "preview_url": "https://admin.getanewsletter.com/t/pt/397213042079/"
}

PUT /mails/templates/html/<id>/

Updates a template. Required fields are:

  • subject
  • body

Optional fields are:

  • plain_text
  • css

PATCH /mails/templates/html/<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/html/12
{
    "subject": "Mail subject"
}

Response
{
    "url": "https://api.getanewsletter.com/v3/mails/templates/html/12/",
    "subject": "Get a Newsletter template",
    "body": "<b>This is a HTML template<b>",
    "plain_text": "This is a HTML template.",
    "css": "h1 {color: red; }",
    "type": 0,
    "updated": "2013-09-06T07:20:31Z",
    "created": "2013-09-06T07:20:31Z",
    "preview_url": "https://admin.getanewsletter.com/t/pt/397213042079/"
}

DELETE /mails/templates/html/<id>/

Deletes the email.