Download OpenAPI specification:Download
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/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 |
{- "design": { },
- "displayMode": "email",
- "mergeTags": { },
- "customJS": [
- "string"
]
}{- "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 |
| fullPage | boolean Default: true Generate image of the full page. |
{- "design": { },
- "displayMode": "email",
- "mergeTags": { },
- "customJS": [
- "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" 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 |
{- "design": { },
- "displayMode": "email",
- "mergeTags": { },
- "customJS": [
- "string"
]
}{- "success": true,
- "data": {
- "url": "string"
}
}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 |
{- "design": { },
- "displayMode": "email",
- "mergeTags": { },
- "customJS": [
- "string"
]
}{- "success": true,
- "data": {
- "url": "string"
}
}