This page will help you get started with the Template resource
In this guide, you will learn the basics of working with templates in Cakemail.
Create a template
Let's create your first template to get started. To do this, you can call the Create a template endpoint. Review the full API reference for a list of all the parameters you can pass.
Code
You now have an html template you can use as a starting point for your next campaigns or for sending your transactional emails.
Update a template
Once you have a template, you can update it from time to time by using the Update a template endpoint.
Code
Next, let's try to use our template in a campaign.
Using a template in a campaign
Now that you have a template, you can use it when creating a new campaign.
Code
You just created a new campaign using your template.
Using a template with transactional emails
You can also use templates to send transactional emails. Since a template can contain personalization tags, it is possible to also specify custom attributes to be used with the template.
Transactional emails are sent with the Email API, using the Submit an email endpoint:
Code
A few things to note about the request body:
sender,emailandcontentare required. The sender must be a confirmed sender on your account.- Inside
content, use either atemplateor inlinehtml/textcontent — not both. custom_attributessits next totemplate, not inside it. Each entry fills one personalization tag in the template.
For the full transactional sending flow, including how to obtain a sender ID, see Sending emails via REST API.
The older /emails endpoint is deprecated and is not enabled on accounts. Calling it returns Transactional emails are disabled on this account — use /v2/emails shown above instead.
You can explore the full API reference for more advanced features in the Asset API.