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?
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>
@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.