Draft Mails

The drafts object is created mails that´s not yet sent. You can display current drafts with the GET-method, create new drafts with the POST-method or update drafts with the PUT or PATCH-method.


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

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


Required fields

  • subject
  • body

Optional fields

  • blockdocument
  • plain_text
  • css

Readonly fields

  • id
  • url
  • type
  • updated
  • created
  • preview_url
  • send_url
  • blockdocument_id

Example draft email

{
    "id": 12
    "url": "https://api.getanewsletter.com/v3/mails/drafts/12/",
    "subject": "Get a Newsletter",
    "body": "<b>This is our weekly newsletter<b>",
    "blockdocument": null,
    "plain_text": "This is our weekly newsletter.",
    "css": "",
    "type": 0,
    "updated": "2013-09-06T07:20:31Z",
    "created": "2013-09-06T07:20:31Z",
    "preview_url": "https://api.getanewsletter.com/v3/mails/drafts/12/preview/",
    "send_url": "https://api.getanewsletter.com/v3/mails/drafts/12/send/"
}

GET /mails/drafts/

Returns list of draft emails, like usual we provide next, prev, count and the results. This list contains both normal HTML emails and block emails.

Possible url parameters are:

  • page: <int>
  • type: <int: 0|1>

Mail types description:

  • 0 = Standard/HTML email
  • 1 = Block email

Example:

GET /mails/drafts/

{
    "count": 46,
    "next": "https://api.getanewsletter.com/v3/mails/drafts/?page=3,
    "previous": "https://api.getanewsletter.com/v3/mails/drafts/?page=2,
    "results": [
        {
            "url": "https://api.getanewsletter.com/v3/mails/drafts/12/",
            "id": 170,
            "subject": "Mail subject",
            "type": 0,
            "updated": "2013-09-06T07:20:31Z",
            "created": "2013-09-06T07:20:31Z",
            "preview_url": "https://api.getanewsletter.com/v3/mails/drafts/170/preview/",
            "send_url": "https://api.getanewsletter.com/v3/mails/drafts/170/send/",
            "blockdocument_id": null
        }
    ]
}

It is possible to filter by type. Example url mails/drafts/?type=0.


GET /mails/drafts/<id>/

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

Example:

{
    "count": 46,
    "next": "https://api.getanewsletter.com/v3/mails/drafts/?page=3,
    "previous": "https://api.getanewsletter.com/v3/mails/drafts/?page=2,
    "results": [
        {
            "id": 12
            "url": "https://api.getanewsletter.com/v3/mails/drafts/12/",
            "subject": "Get a Newsletter",
            "body": "<b>This is our weekly newsletter<b>",
            "blockdocument": null,
            "plain_text": "This is our weekly newsletter.",
            "css": "",
            "type": 0,
            "updated": "2013-09-06T07:20:31Z",
            "created": "2013-09-06T07:20:31Z",
            "preview_url": "https://api.getanewsletter.com/v3/mails/drafts/12/preview/",
            "send_url": "https://api.getanewsletter.com/v3/mails/drafts/12/send/"
        }
    ]
}

POST /mails/drafts/

Creates a new standard/HTML draft. Required fields are:

  • subject
  • body

Optional fields are:

  • plain_text
  • css

Example:

POST /mails/drafts/

{
    "subject": "Mail subject",
    "body": "<b>This is our weekly newsletter<b>",
    "plain_text": "This is our weekly newsletter.",
    "css": "h1 {color: red }"
}

Response

{
    "id": 12
    "url": "https://api.getanewsletter.com/v3/mails/drafts/12/",
    "subject": "Mail subject",
    "body": "<b>This is our weekly newsletter<b>",
    "blockdocument": null,
    "plain_text": "This is our weekly newsletter.",
    "css": "h1 {color: red }",
    "type": 0,
    "updated": "2013-09-06T07:20:31Z",
    "created": "2013-09-06T07:20:31Z",
    "preview_url": "https://api.getanewsletter.com/v3/mails/drafts/12/preview/",
    "send_url": "https://api.getanewsletter.com/v3/mails/drafts/12/send/"
}

To create block draft you have to make a POST request to a block template.

Example:

POST /mails/templates/block/7678/draft/

For more information check the block templates section here.


PUT /mails/drafts/<id>/

Updates a draft with new data. Required fields are:

  • subject
  • body

Optional fields are:

  • plain_text
  • css

PATCH mails/drafts/<id>/

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

Example:

PATCH /mails/drafts/12/
{
    "subject": "Mail subject"
}

Response
{
    "id": 12
    "url": "https://api.getanewsletter.com/v3/mails/drafts/12/",
    "subject": "Mail subject",
    "body": "<b>This is our weekly newsletter<b>",
    "blockdocument": null,
    "plain_text": "This is our weekly newsletter.",
    "css": "h1 {color: red }",
    "type": 0,
    "updated": "2013-09-06T07:20:31Z",
    "created": "2013-09-06T07:20:31Z",
    "preview_url": "https://api.getanewsletter.com/v3/mails/drafts/12/preview/",
    "send_url": "https://api.getanewsletter.com/v3/mails/drafts/12/send/"
}

DELETE /mails/drafts/<id>/

Deletes the email.

Example:

DELETE /mails/drafts/600/

HTTP 204 NO CONTENT

POST /mails/drafts/<id>/copy/

Creates a copy of the draft.

Example:

POST https://api.getanewsletter.com/v3/mails/drafts/598/copy/

HTTP 201 CREATED
{
    "id": 604,
    "url": "https://api.getanewsletter.com/v3/mails/drafts/604/",
    "subject": "Copy of sdvsdv",
    "body": "sdvsdvsd",
    "blockdocument": null,
    "plain_text": "",
    "css": "sdvsdvsdv",
    "type": 0,
    "updated": "2014-06-25T13:46:38.150Z",
    "created": "2014-06-25T13:46:38.150Z",
    "preview_url": "https://api.getanewsletter.com/v3/mails/drafts/604/preview/",
    "send_url": "https://api.getanewsletter.com/v3/mails/drafts/604/send/"
}