Ghost is a powerful platform for independent publishers and newsletters. Its built-in webhook system makes it easy to trigger external actions on publish — including generating a SwarmGen image for every post. Set it up once and every post you publish automatically gets a branded OG card, a newsletter header, or a social media banner, without touching a design tool.
How to set it up
- 1
Build your Ghost post template
Create a SwarmGen template with merge fields matching Ghost post data: {{title}}, {{excerpt}}, {{feature_image}}, {{primary_tag}}, {{published_at}}.
- 2
Add a Ghost webhook
In Ghost Admin, go to Settings > Integrations > Custom integrations > Add webhook. Select "Post published" as the event and enter your automation endpoint (Make, n8n, or a custom URL).
- 3
Extract post data and call SwarmGen
In your automation (or serverless function), receive the Ghost webhook payload, pull out the post fields, and POST them to the SwarmGen render API.
- 4
Update the post or send the image downstream
Use the Ghost Admin API to update the og_image field on the post, or send the image URL to Mailgun/Mailchimp for the newsletter header.
Code example
// Serverless function / Express route receiving Ghost webhook
export async function handler(req) {
const post = req.body.post?.current;
if (!post) return { statusCode: 400 };
const renderRes = await fetch(`https://swarmgen.io/api/templates/${process.env.SWARMGEN_TEMPLATE_ID}/render`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${process.env.SWARMGEN_API_KEY}`,
},
body: JSON.stringify({
data: {
title: post.title,
excerpt: post.custom_excerpt || post.excerpt,
feature_image: post.feature_image,
primary_tag: post.primary_tag?.name ?? '',
published_at: new Date(post.published_at).toLocaleDateString('en-GB', {
day: 'numeric', month: 'long', year: 'numeric',
}),
},
returnUrl: true,
}),
});
const { url, jobId } = await renderRes.json();
return { statusCode: 200, body: JSON.stringify({ url, jobId }) };
}Bespoke integrations are not supported by our team. The sample code here is for guidance and you will need technical knowledge or a developer to implement it. We plan to release dedicated plugins for key tools as demand grows.
Ready to connect Ghost?
Create a free account, build a template, and start generating images from your Ghost workflows in minutes.
Get started free