Download OpenAPI specification:Download
This reference is retained for existing integrations. New integrations should use the primary API reference.
Welcome to the Unlayer REST API documentation. Our API enables you to programmatically access and manipulate email templates, designs, and other Unlayer resources.
The Unlayer API uses 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: -X GET https://api.unlayer.com/v2/templates
All API calls must use HTTPS. Any calls made using HTTP will return an appropriate error code.
Follow these steps to get your API key:
Authorization: Basic BASE64-ENCODED-API-KEY
If you need to, you may construct and send basic auth headers yourself. To do this you need to perform the following steps:
APIKey:Password where Password will always be empty. For example, if your API Key is XAyAztva4, you will just add a : at the end. XAyAztva4:Authorization header with content Basic followed by the encoded string. For example, the string XAyAztva4: encodes to WEF5QXp0dmE0Og== in base64. Here's how the request would look: curl -D- \
-X GET \
-H "Authorization: Basic WEF5QXp0dmE0Og==" \
"https://api.unlayer.com/v2/templates"
All API requests will receive a standard HTTP response code.
GET https://api.unlayer.com/v2/templates
Get a list of available templates
| page | integer >= 1 Default: 1 Current page |
| perPage | integer >= 1 Default: 20 Number of templates to fetch per page |
| includeDesign | integer Default: 1 Enum: 0 1 Should the result include design json or not. This is not recommended as it could result in long response. To disable, pass 0. |
{- "success": true,
- "data": [
- {
- "id": "string",
- "name": "string",
- "design": { },
- "displayMode": "string",
- "updatedAt": "string",
- "createdAt": "string"
}
]
}GET https://api.unlayer.com/v2/templates/{id}
Get a specific template by ID
| id required | string ID of the template to retrieve |
{- "success": true,
- "data": {
- "id": "string",
- "name": "string",
- "design": { },
- "displayMode": "string",
- "updatedAt": "string",
- "createdAt": "string"
}
}GET https://api.unlayer.com/v2/templates/{id}/render
Render a template HTML
| id required | string ID of the template to retrieve |
{- "success": true,
- "data": {
- "html": "string",
- "chunks": {
- "body": "string",
- "css": "string",
- "js": "string",
- "fonts": [ ],
- "tags": [ ]
}, - "amp": {
- "enabled": true,
- "format": "string",
- "validation": {
- "status": "string",
- "errors": [ ]
}
}
}
}GET https://api.unlayer.com/v2/template-folders/{id}/templates
Get a list of templates in a specific folder
| id required | string ID of the folder to retrieve templates from |
| page | integer >= 1 Default: 1 Current page |
| perPage | integer >= 1 Default: 20 Number of templates to fetch per page |
| includeDesign | integer Default: 1 Enum: 0 1 Should the result include design json or not. This is not recommended as it could result in long response. To disable, pass 0. |
{- "success": true,
- "data": [
- {
- "id": "string",
- "name": "string",
- "design": { },
- "displayMode": "string",
- "updatedAt": "string",
- "createdAt": "string"
}
]
}You can use Unlayer's Cloud API to generate HTML, Image, PDF or ZIP file of your templates or designs.
The Cloud API helps you take care these common use-cases:
POST https://api.unlayer.com/v2/export/html
Export a design to HTML format with various options
| design required | object The design JSON to export |
| displayMode required | string Enum: "email" "web" "popup" The display mode of the design |
| mergeTags | object Values to replace merge tags in the design |
| customJS | Array of strings URLs to your custom JS to support custom tools |
| editorVersion | string Optional editor version to use when exporting the design. If omitted, the API uses the X-Unlayer-Editor-Version header when present. Versions earlier than 1.438.0 use 1.438.0. |
| outlookSupport | boolean Include classic Outlook/IE conditional markup in email HTML (default true). False also removes custom HTML conditionals. Requires an editor version that supports this option. |
{- "design": { },
- "displayMode": "email",
- "mergeTags": { },
- "customJS": [
- "string"
], - "editorVersion": "string",
- "outlookSupport": true
}{- "success": true,
- "data": {
- "html": "string",
- "chunks": {
- "body": "string",
- "css": "string",
- "js": "string",
- "fonts": [
- "string"
]
}
}
}POST https://api.unlayer.com/v2/export/image
Export a design to image format (PNG)
| design required | object The design JSON to export |
| displayMode required | string Enum: "email" "web" "popup" The display mode of the design |
| mergeTags | object Values to replace merge tags in the design |
| customJS | Array of strings URLs to your custom JS to support custom tools |
| editorVersion | string Optional editor version to use when exporting the design. If omitted, the API uses the X-Unlayer-Editor-Version header when present. Versions earlier than 1.438.0 use 1.438.0. |
| fullPage | boolean Default: true Generate image of the full page. |
{- "design": { },
- "displayMode": "email",
- "mergeTags": { },
- "customJS": [
- "string"
], - "editorVersion": "string",
- "fullPage": true
}{- "success": true,
- "data": {
- "url": "string"
}
}POST https://api.unlayer.com/v2/export/pdf
Export a design to PDF format
| design required | object The design JSON to export |
| displayMode required | string Enum: "email" "web" "popup" "document" The display mode of the design. Use |
| mergeTags | object Values to replace merge tags in the design |
| customJS | Array of strings URLs to your custom JS to support custom tools |
| pageSize | string Enum: "Letter" "Legal" "Tabloid" "Ledger" "A0" "A1" "A2" "A3" "A4" "A5" "A6" Paper size for the PDF. On this v2 endpoint, existing projects with PDF export
access retain the full supported format list, including legacy plans.
Without |
| documentOrientation | string Enum: "portrait" "landscape" Page orientation. Only applies when |
| editorVersion | string Optional editor version to use when exporting the design. If omitted, the API uses the X-Unlayer-Editor-Version header when present. Versions earlier than 1.438.0 use 1.438.0. |
object Custom watermark drawn over every page of a document-mode PDF. Requires a plan
that includes Document Watermarks; other plans receive a |
{- "design": { },
- "displayMode": "email",
- "mergeTags": { },
- "customJS": [
- "string"
], - "pageSize": "Letter",
- "documentOrientation": "portrait",
- "editorVersion": "string",
- "watermark": {
- "text": "string",
- "position": "diagonal",
- "opacity": 0.05,
- "color": "string"
}
}{- "success": true,
- "data": {
- "url": "string",
- "watermark": "unlayer"
}
}POST https://api.unlayer.com/v2/export/zip
Export a design as a ZIP archive containing all assets
| design required | object The design JSON to export |
| displayMode required | string Enum: "email" "web" "popup" The display mode of the design |
| mergeTags | object Values to replace merge tags in the design |
| customJS | Array of strings URLs to your custom JS to support custom tools |
| editorVersion | string Optional editor version to use when exporting the design. If omitted, the API uses the X-Unlayer-Editor-Version header when present. Versions earlier than 1.438.0 use 1.438.0. |
{- "design": { },
- "displayMode": "email",
- "mergeTags": { },
- "customJS": [
- "string"
], - "editorVersion": "string"
}{- "success": true,
- "data": {
- "url": "string"
}
}