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"
}
}Validate a design JSON against the Unlayer design schema. Returns { valid: true } when the payload conforms, or { valid: false, errors: [...] } with the path, message, and code of every issue when it doesn't. Always responds with HTTP 200 — valid is the source of truth.
Useful in CI, in import pipelines, and before saving — catching a schema problem before it reaches the editor produces a much better error message than letting the editor crash on render.
See Data Structures → Design object for the design shape this endpoint expects.
This endpoint lives on the v3 base URL:
https://api.unlayer.com/v3. Authenticate with a Bearer token (API key with theunlayer_sk_prefix).
POST https://api.unlayer.com/v3/templates/validate
Validate a design JSON against the Unlayer design schema. Returns { valid: true } when the payload conforms, or { valid: false, errors: [...] } with the path, message, and code of every issue when it doesn't. Always responds with HTTP 200 — valid is the source of truth.
required | object The design JSON to validate. |
| schema | string Default: "full" Enum: "full" "simple" Which form of the schema to validate against. |
| displayMode | string Enum: "email" "web" "document" "popup" Display mode for the design. Some validation rules differ per mode. |
{- "design": { },
- "schema": "full",
- "displayMode": "email"
}{- "valid": true,
- "errors": [
- {
- "path": "string",
- "message": "string",
- "code": "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"
}
]
}Convert a design JSON between Unlayer's two schema forms:
Round-trip safely by passing includeConversion: true on the way out — the embedded _conversion metadata restores original values without data loss.
See Data Structures → Design object for the shape these endpoints accept and return.
These endpoints live on the v3 base URL:
https://api.unlayer.com/v3. Authenticate with a Bearer token (API key with theunlayer_sk_prefix).
POST https://api.unlayer.com/v3/convert/full-to-simple
Convert a design from the Full schema to the Simple schema. Use this when you have an in-editor design and need to send it somewhere that expects the Simple shape — your own backend storage, a webhook payload, the /templates/validate endpoint when validating against the simple form, and so on.
required | object The Full-schema design JSON. |
| displayMode | string Enum: "email" "web" "document" "popup" Display mode for the design. |
| includeDefaultValues | boolean Default: false When |
| includeConversion | boolean Default: false When |
{- "design": { },
- "displayMode": "email",
- "includeDefaultValues": false,
- "includeConversion": false
}{- "success": true,
- "data": {
- "design": { }
}
}POST https://api.unlayer.com/v3/convert/simple-to-full
Convert a design from the Simple schema to the Full schema. If the input was produced by /convert/full-to-simple with includeConversion: true, the embedded _conversion metadata is used to restore original values without data loss.
required | object The Simple-schema design JSON. May include a |
| displayMode | string Enum: "email" "web" "document" "popup" Display mode for the design. |
| includeDefaultValues | boolean Default: false When |
{- "design": { },
- "displayMode": "email",
- "includeDefaultValues": false
}{- "success": true,
- "data": {
- "design": { }
}
}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"
}
}