Skip to content

Overview

The Unlayer API is based on the REST paradigm. We use standard HTTP authentication, and all responses are JSON formatted.

This API is only available in Business and Growth premium plans.

Base URL

All API URLs referenced in this document are relative to the following base URL:

https://api.unlayer.com/v1

Authentication

The Unlayer API uses HTTP Basic Authentication.

All requests require you to authenticate using a Unlayer Project API Key as the username with an empty string as the password:

curl -u YOUR-API-KEY: https://api.unlayer.com/v1/templates

All API calls must use HTTPS. Any calls made using HTTP will return an appropriate error code.


Errors

Any API request will receive a standard HTTP response code.

Response Ranges:

  • 2xx -- Successful Request
  • 4xx -- Failed Request (Client error)
  • 5xx -- Failed Request (Server error)

Versioning

Any time we make backwards-incompatible changes to our API, we will release a new version. Our current API is v1.


API End Points

Templates

Get a List of Templates

GET /templates

Sample Response

{
  "success": true,
  "data": [
    {
      "id": 1987,
      "name": "My Web Template",
      "design": {
        ...
      },
      "displayMode": "web",
      "updatedAt": "2018-03-07T05:44:08.979Z",
      "createdAt": "2018-02-23T18:04:34.448Z"
    },
    {
      "id": 1861,
      "name": "My Email Template",
      "design": {
        ...
      },
      "displayMode": "email",
      "updatedAt": "2018-02-07T23:05:52.867Z",
      "createdAt": "2018-02-07T23:05:52.867Z"
    }
  ]
}

Get Specific Template

GET /templates/(:template_id)

Sample Response

{
  "success": true,
  "data": {
    "id": 1987,
    "name": "My Web Template",
    "design": {
      ...
    },
    "displayMode": "web",
    "updatedAt": "2018-03-07T05:44:08.979Z",
    "createdAt": "2018-02-23T18:04:34.448Z"
  }
}

Get Template Screenshot

GET /templates/(:template_id)/preview

Sample Response

Template Preview Image

Render a Template HTML

POST /templates/(:template_id)/render

Sample Response

{
  "html": "<html>...</html>"
}

Rendering

Render a Design

This end-point will convert the JSON of a design to HTML.

POST /render

Request Body

The body should have the complete JSON of a design.

{
  "body": {
    ...
  }
}

Sample Response

{
  "html": "<html>...</html>"
}

Download a Design

This end-point will convert the JSON of a design to a downloadable ZIP file.

POST /download

Request Body

The body should have the complete JSON of a design.

{
  "body": {
    ...
  }
}

Sample Response

Downloadable Zip File