Skip to main content
Version: 1.468.0

Export ZIP

Similar to the Export HTML function, you can also export a design as a ZIP file. This generates a bundle ZIP file that also includes all the images required by your design and uploads it to your connected File Storage.

Note: Unlike HTML or plain text, ZIP file is not generated on the client. This function uses our cloud API to generate the ZIP file.

unlayer.exportZip(function (data) {
var json = data.design; // design json
var fileUrl = data.url; // zip file url

// Do something with the ZIP url
});

Callback Parameters​

The exportZip callback returns the following parameters.

NameDescription
designThis is the JSON of the design
urlThis is the URL of the generated ZIP file

Export Options​

You can also pass certain options to this function as a second parameter.

Merge Tags​

If you want the Merge Tags in your design to be replaced by different values, you can pass the mergeTags object to export options.

unlayer.exportZip(
function (data) {
var json = data.design; // design json
var fileUrl = data.url; // zip file url
},
{
mergeTags: {
first_name: 'John',
last_name: 'Doe',
},
},
);

Cloud API​

If you want to generate the ZIP file on the server-side, you can use our Cloud API.

const fetch = require('node-fetch');

let url = 'https://api.unlayer.com/v2/export/zip';

let options = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Basic BASE64-ENCODED-API-KEY',
},
body: JSON.stringify({
displayMode: 'email',
design: {}, // json of your design
mergeTags: { first_name: 'John', last_name: 'Doe' },
}),
};

fetch(url, options)
.then((res) => res.json())
.then((json) => console.log(json))
.catch((err) => console.error('error:' + err));

Learn more at Cloud API reference.

Response​

The API response will return an uploaded zip file URL.

{
"success": true,
"data": {
"url": "https://.../1593082715347-8LCcNZuuBpU4D92W.zip"
}
}