Automate importing of templates for clients

Hi there,

Has anyone built any tools that you can use to bulk import templates?

I can see that this should be technically doable within the API, but I think this might be pushing my coding abilities a bit. When setting up clients, I'd like to be able to automate the import of a range of templates for clients to use while test driving the software. I can see has a tool which can do this, but it also has a lot of other features that I dont need - I only need the template imports :)

Anyone have any code or tools they'd be willing to share? (I'll buy you something nice as a thanks!)


jamesd jamesd, 5 years ago

This functionality you've described is actually available out of the box with all the API client libraries/wrappers.

First, you'll want to host the template html file, assets zip file and optionally a screenshot somewhere, as these URLs are required as input when creating templates via the API.

You or your website developer will want to choose a client library/wrapper which suits your website setup (which you didn't describe above) and make the call to add a template as many times as you need to for all your templates.

Here is an example using the PHP client library:


require_once '../../csrest_templates.php';

$wrap = new CS_REST_Templates(NULL, 'Your API Key');

$result = $wrap->create('Templates Client ID', array(
    'Name' => 'Template Name',
    'HtmlPageURL' => 'Template HTML Url',
    'ZipFileURL' => 'Template Images Zip URL',
    'ScreenshotURL' => 'Template Screenshot URL'

echo "Result of POST /api/v3/templates/{clientID}\n<br />";
if($result->was_successful()) {
    echo "Created with ID\n<br />".$result->response;
} else {
    echo 'Failed with code '.$result->http_status_code."\n<br /><pre>";
    echo '</pre>';

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free