The Render API
The Render API enables you to build emails on demand, using components from your Email Design System. It’s particularly useful if you have many transactional email templates. When you make a change to your Email Design System components, it can be risky and time consuming to update each template.
Example
Section titled “Example”In this example we’ll be using Node.js to make a request to the render API.
import axios from 'axios';
const apiKey = process.env.EMAILSHEPHERD_API_KEY;
const headers = { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json',}
const payload = { email_design_system_id: 123, locale: 'en-US', email_content: { subject: { branch_content: { null_branch: { 'en-US': 'Hello, world!', } } }, preheader: { branch_content: { null_branch: { 'en-US': 'This is a preheader', } } }, container_component_instance: { id: '00000000-0000-0000-0000-000000000001', component_name: 'container_component', field_values: { null_branch: { 'en-US': { email_background_color: { value: '#000000' }, email_text_color: { value: '#ffffff' }, } } } }, component_instances: [ { id: '00000000-0000-0000-0000-000000000002', // any unique string component_name: 'header', field_values: { null_branch: { 'en-US': { header_text: { value: 'Hello, world!' }, header_link_url: { value: 'https://emailshepherd.com' }, } } } }, { id: '00000000-0000-0000-0000-000000000003', component_name: 'body', field_values: { null_branch: { 'en-US': { body: { value: 'Hello, world!' }, } } } } ] }}
const response = await axios.post( `https://api.emailshepherd.com/v1/renders`, payload, { headers });
const { html, subject } = response.data;
// And here you would pass the rendered HTML to your ESP for sending, e.g:await axios.post( `https://api.your-esp.com/v1/send`, { to: 'test@example.com', subject, html, });