Fetch raw template html


unfortunately campaign monitor doesn't support creating a campaign by selecting a template and sending through a set of information for title/body etc, so I was looking to extract the raw template code and do these replacements myself. Unfortunately the "previewURL" that is returned with the get template API call returns a rendered html page rather than the raw, cm template, code.

I can get the designer to put in specific classnames so I can target the title/body areas for replacement but it would be really good if I can get the raw template code so I can do further replacements such as the current time and other fields. The time field is especially important to change as some campaigns will be forward dated when they are sent to CM.


Stig Stig, 6 years ago


Could you elaborate a bit on how you'll be using Campaign Monitor via the API? It sounds like you might want to export the template, grab the code, and generate the entire campaign HTML on your end?


The Campaign Monitor Blog – HTML email smarts to go with your good looks.
santouras, 6 years ago

Hi Stig,

the ultimate goal would be to use the API to say, "create a campaign using this template with these replacement variables (for title/content/date/etc) and send to this list". Unfortunately CM doesn't support creating a campaign via the API using a template. Because I want to be able to let our users select a template we have created for them and is loaded into their CM area, we need to be able to fetch the template HTML that has been loaded into the CM website. However, I cannot see a way to fetch the raw code of the template. The one with the tags of <$title .... %> etc. This makes doing replacements really tricky.

What I'm essentially wanting to do is in our CMS to have after a piece of content the ability to send that content using a particular template to a particular list, but I'm having trouble getting the template data in a way that I can build a meaningful page for CM to read.

I hope that makes sense... :)

Stig Stig, 6 years ago

Hi santouras,

Thanks for clarifying. I'm afraid the templates in Campaign Monitor are only meant for use with the built in editor, not with the API, so the raw template HTML is not available I'm afraid.

If you'll be allow users to build campaigns via your CMS, you would need to manage the templates on your end, and then generate the final campaign HTML for import to Campaign Monitor via the API. The templates in Campaign Monitor will be available to the users if they log in and create campaigns in the app itself.


The Campaign Monitor Blog – HTML email smarts to go with your good looks.
santouras, 6 years ago

Thanks Stig, I was afraid that was going to be the answer.

As someone looking to use the API from a CMS, it is quite limited at the moment. I know there are historical reasons and the like for the feature set exposed by the API, but there's a couple of things I would love to see implemented.

1 - Create campaigns by sending through html data rather than a link to a website.
one pretty important thing we do in our CMS is lock down content so that forward dated announcements and the like aren't publicly viewable until a company authorises their release. We want to use the CM API to send out emails when these announcements go live, but the CM system wants to read in the data from a publicly viewable URL. This is obviously not ideal. It would be far more desirable to send through the data to CM directly.

2 - Create campaigns using the built in templates
If one is not able to create a campaign using the built in templates, I cannot really see too much of a use to having the templates exposed in the API. Creating/deleting/updating them is nice, but surely the no1 reason to access templates is to use them. Either getting back the raw template data or being able to send through replacement text is pretty vital. With the API the way it is, it is forcing us to create two templates, one our CMS uses and one that CM uses.

Thanks for clearing up that point Stig and here's hoping the API will see some improvements in the not too distant future!

200,000 companies around the world can't be wrong.

From Australia to Zimbabwe, and everywhere in between, companies count on 
Campaign Monitor for email campaigns that drive real business results.

Get started for free