Skip to main content

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.

warning

The Render API is at this time is designed for transactional email sends, not large campaign blasts. The endpoint is rate limited. Before using The Render API you must contact EmailShepherd support and provide estimates of your volume of renders.

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,
content: {
subject: 'Hello, world!',
preheader: 'This is a preheader',
container_component_instance: {
component_id: 123,
// The field values here correspond to global_fields defined in your Container Component.
// If omitted, it will fall back to the default values.
field_values: {
email_background_color: '#000000',
email_text_color: '#ffffff',
}
},
component_instances: [
{
component_id: 124,
// The field values here correspond with fields defined in your component.
// If omitted, it will fall back to the default values.
field_values: {
header_text: 'Hello, world!',
header_link_url: 'https://emailshepherd.com',
}
},
{
component_id: 125,
field_values: {
body: 'Hello, world!',
}
}
]
}
}

const response = await axios.post(
`https://api.emailshepherd.com/v1/renders`,
payload,
{ headers }
);

const renderedHtml = response.data.html;

// 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: '[email protected]',
subject: 'Hello, world!',
html: renderedHtml,
}
);

View endpoint details