Mailings

GET /api/v1/mailings

List of existing mailings.

Query Parameters:
 
  • list – filter results by list‘s unique identifier
Response JSON Array of Objects:
 
  • id (int) – mailing’s unique identifier
  • name (string) – mailing’s unique name
  • campaign (int) – mailing’s campaign unique identifier

Request:

GET /api/v1/mailings HTTP/1.1
Host: account.emailicious.com
Accept: application/json

Response:

HTTP/1.1 200 OK
Vary: Accept
Allow: GET, POST, HEAD, OPTIONS
Content-Type: application/json

{
    "count": 3,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 1,
            "name": "First mailing",
            "campaign": null
        },
        {
            "id": 2,
            "name": "Mailing with campaign",
            "campaign": 1
        },
        {
            "id": 3,
            "name": "Third mailing",
            "campaign": null
        }
    ]
}
POST /api/v1/mailings

Create a new mailing with variants and deliveries.

Request JSON Object:
 
  • list (int) – list‘s unique identifier
  • name (string) – mailing’s unique name
  • campaign (int) – campaign’s unique identifier
  • segments (array) – segment unique identifiers
  • variants (array) – variants
  • variants.language (array) – variant’s language
  • variants.from_name (string) – variant’s from name (defaults to list default_from_name)
  • variants.from_email (string) – variant’s from email (defaults to list default_from_email)
  • variants.replyto_email (string) – variant’s reply-to email (defaults to list default_replyto_email)
  • variants.subject (string) – variant’s subject
  • variants.layout.text (string) – variant’s layout text
  • variants.layout.zip_file (string) – data URI encoded Zip variant’s layout.
  • variants.deliveries (array) – deliveries
  • variants.deliveries.scheduled_datetime (string) – scheduled datetime of the delivery

Note

In order to allow files to be submitted through a request with an application/json content type files must be data URI encoded.

The variants.layout.zip_file expects the submitted file to be a Zip archive containing the following files:

  1. An index.html file representing the content of your layout.
  2. Optional image files (.jpg, .png, .gif) located in a images directory. These images should be referenced relatively from the index.html file to be imported appropriately.

Here’s an example of how you can generate a valid layout payload using Python:

import StringIO
import zipfile

html = """<!DOCTYPE html>
<html>
    <body>
        Hello World!
        <img src="images/planet.png" />
    </body>
</html>"""

buffer = StringIO.StringIO()
with zipfile.ZipFile(buffer, mode='w') as archive:
    archive.writestr('index.html', html)
    archive.write('/path/to/planet.png', 'images/planet.png')

# URI encode the Zip file.
layout = 'data:application/zip;charset=utf-8;base64,%s' % (
    buffer.getvalue().encode('base64'),
)

Request:

POST /api/v1/mailings HTTP/1.1
Host: account.emailicious.com
Accept: application/json
Content-Type: application/json

{
    "list": 1,
    "name": "Mailing",
    "variants": [
        {
            "subject": "Hello World!",
            "layout": {
                "zip_file": "data:application/zip;charset=utf-8;base64,..."
            },
            "deliveries": [
                {
                    "scheduled_datetime": "2017-05-15T19:30:33Z"
                }
            ]
        }
    ]
}

Response:

HTTP/1.1 201 Created
Allow: GET, POST, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 1,
    "name": "Mailing",
    "list": 1,
    "campaign": null,
    "segments": [],
    "variants": [
        {
            "from_name": "List default from name",
            "from_email": "list@default.from.email",
            "replyto_email": "",
            "subject": "Hello World!",
            "deliveries": [
                {
                    "exclusions": [],
                    "limit": null,
                    "scheduled_datetime": "2017-05-15T19:30:33Z"
                }
            ],
            "language": null,
            "layout": {
                "id": 1,
                "source": "<!DOCTYPE html>\n<html>\n<body>...</body>\n</html>"
            }
        }
    ]
}