0

I've been searching through the Fuelsdk docs and I can't work out how templates can be created/updated. It feels like I'm missing something obvious here, but how can I create a new template and insert html using the API?

1

The Template object is not currently exposed via the SDK, it is accessible by using the SOAP API directly.

Details on the Template object: https://help.marketingcloud.com/en-US/technical_library/web_service_guide/objects/template/

Example SOAP Request:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://exacttarget.com/wsdl/partnerAPI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="https://exacttarget.com/wsdl/partnerAPI">
   <SOAP-ENV:Header>
<!-- Header removed -->
   <SOAP-ENV:Body>
      <CreateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
         <Objects xsi:type="par:Template" xmlns:par="http://exacttarget.com/wsdl/partnerAPI">
            <PartnerKey xsi:nil="true"/>
            <ObjectID xsi:nil="true"/>
            <TemplateName>API Created Template5</TemplateName>
            <LayoutHTML><![CDATA[<body bgcolor="#ffffff" text="#000000"><table @@cellspacing @@cellpadding @@borderwidth @@bordercolor @@bgcolor @@width @@alignment><tr><td>@@headerContent</td></tr><tr><td>@@layoutContent</td></tr></table><custom name="opencounter" type="tracking"></body>]]></LayoutHTML>
            <BackgroundColor>ffffff</BackgroundColor>
            <BorderColor>000000</BorderColor>
            <BorderWidth>1</BorderWidth>
            <Cellpadding>0</Cellpadding>
            <Cellspacing>0</Cellspacing>
            <Width>600</Width>
            <Align>center</Align>
            <ActiveFlag>1</ActiveFlag>
            <CategoryType>template</CategoryType>
            <OwnerID>38626</OwnerID>
            <Layout>
               <ID>1</ID>
            </Layout>
         </Objects>
      </CreateRequest>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
0

Pretty sure you can't create Email Templates using the SFMC APIs. The whole re-publishing templated email scenario is a complication that I don't think they have overcome.

You can certainly update Content Areas in templated emails or update HTML Paste emails with the API.

3
  • <custom> tags to allow content blocks don't seem to work when an email is created through the API, but they do work if the same html goes in as a template then an html is created from it. That's why I'm asking about templates - should a <custom> tag work in an email that isn't based on a template? – Will Jul 7 '16 at 12:08
  • When you are creating the Email via the API with content blocks, does the request have IsHTMLPaste = false and EmailType = Normal? Those should be the default values so if they are undefined then that should work too. – Mac Jul 7 '16 at 14:58
  • I've checked and the email is being created with IsHTMLPaste = false and EmailType = Normal, also I've retrieved the campaign to check these. What I can't work out is whether an email being from a template a precondition of making the <custom> tags work? If not, what other properties might be important - what does IsActive mean - and where is it documented? – Will Jul 7 '16 at 20:23
0

@Mac's answer is correct at the most basic level. It's possible to create and update Templates, however the API doesn't have access to the ContentAreas, the "Layout" object referred to in the documentation (updated URL: https://developer.salesforce.com/docs/atlas.en-us.mc-apis.meta/mc-apis/template.htm) says that the Layout object contains ContentAreas, it does not. There is a Laravel Version of the FuelSDK, i've added "createTemplate" and "updateTemplate" methods to the ET_Client, and I am using these in production. https://packagist.org/packages/ariad/exacttarget-laravel

I very badly need to update that documentation.

The Layout Object: https://developer.salesforce.com/docs/atlas.en-us.mc-apis.meta/mc-apis/layout.htm states "reserved for Future Use" and also does not have ContentAreas.

The only thing that can implement a ContentArea, is HeaderContent which is type: ContentArea description: Contains content used in header of template.

This only provides the ID and ObjectID to a ContentArea Object which you can update if it exists, it appears to be missing the key and content which you would need to make this work in the content tag, I don't think you can create these independently as they have a CategoryID of 0 (they belong to a Template, not in My Contents).

Bottom line, The Template Object from the API perspective is VERY broken. Basic Templates can be created, but you'll need to go into the Marketing Cloud website and fix them if you are using any of their more powerful features.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.