# How to automate social images from a CMS or a spreadsheet

Source: https://snapsbrew.com/blog/automate-social-images-from-cms-or-spreadsheet

Pick the trigger first. For link previews, put a signed image URL in the page, and the first share renders the image. For posts that need an image at publish time, let a CMS webhook call a render API with an idempotency key. For lists, run a scheduled batch from a spreadsheet export.

By [Alejandro Medina](https://amedina.me), maintainer of Snapsbrew. Published 27 November 2026. Last updated 27 November 2026.

On this page

- [Trigger 1: the share renders the image](#trigger-1-the-share-renders-the-image)
- [Trigger 2: the CMS publishes](#trigger-2-the-cms-publishes)
- [Trigger 3: a schedule reads a spreadsheet](#trigger-3-a-schedule-reads-a-spreadsheet)
- [One message, many sizes](#one-message-many-sizes)
- [What breaks, and how to notice](#what-breaks-and-how-to-notice)
- [When a no-code tool is the better answer](#when-a-no-code-tool-is-the-better-answer)

A post goes live in the CMS. Then someone opens a design tool, duplicates last week's card, types the new title, exports three sizes, and uploads them. It takes ten minutes, it happens every week, and the week that person is out, the post ships with no image.

Every fix for this starts with the same question: what event should make the image? The answer decides the whole setup. There are three good triggers, and most teams need one or two of them.

| Trigger                        | Good for                                       | Stores the image URL?       | Runs a job?     |
| ------------------------------ | ---------------------------------------------- | --------------------------- | --------------- |
| A crawler opens a signed URL   | og:image link previews                         | No                          | No              |
| The CMS publishes a post       | Images that go into the post or to a scheduler | Yes, back in the CMS        | Yes, one render |
| A schedule reads a spreadsheet | Lists: events, products, speakers              | Yes, in a file or the sheet | Yes, a batch    |

The examples use Snapsbrew, because that is the tool I maintain. The patterns work with any template API that has a URL-based render, a sync render and a batch endpoint.

## Trigger 1: the share renders the image

If the image only has to show up in link previews, do not store it at all. Put a signed image URL in the `og:image` tag of the page. The URL holds the template ID, the text of each layer and an HMAC signature. The first crawler that opens it makes the instance render the image. Later requests get the stored file.

```html
<meta property="og:image" content="https://snapsbrew.example/signed-url/image.jpg?template_id=...&variants=...&signature=...">

```

Why this is the best default:

- **Nothing to keep in sync.** The text is in the URL. A new title makes a new URL, so a stale image is not possible.
- **No wasted renders.** A page that nobody shares never renders. On a site with thousands of pages, that is most of the pages.
- **No job, no queue, no webhook.** The signature is one HMAC call in your page code.

The framework guides have the full code: [Next.js](https://snapsbrew.com/guides/nextjs-og-images.md), [Nuxt](https://snapsbrew.com/guides/nuxt-og-images.md), and [Laravel and Rails](https://snapsbrew.com/guides/laravel-og-images.md).

The limit: the image exists only as a URL on your instance. If a social scheduler or a newsletter tool needs the file itself, use trigger 2.

## Trigger 2: the CMS publishes

Most headless CMSs can call a URL when an entry is published. Ghost, Strapi, Sanity, Contentful and Directus have webhooks, and WordPress can send them with a plugin. The handler renders the image and writes the URL back to the entry.

```js
// A serverless function that receives the "post published" webhook of the CMS.
import { Snapsbrew } from 'snapsbrew'

const sb = new Snapsbrew({ baseUrl: process.env.SNAPSBREW_URL, token: process.env.SNAPSBREW_TOKEN })

export async function handle(request) {
  // 1. Check the secret or the signature that your CMS sends. Refuse the request if it does not match.
  const post = (await request.json()).post

  // 2. Render the card. The key makes a retry of the same webhook safe.
  const snap = await sb.snaps.create({
    templateId: process.env.CARD_TEMPLATE,
    variants: [
      { layer: 'title', text: post.title },
      { layer: 'author', text: post.author.name },
      { layer: 'photo', image_url: post.feature_image },
    ],
    idempotencyKey: `post-${post.id}-${Date.parse(post.updated_at)}`,
  })

  // 3. Write snap.media_url back to the post with the API of your CMS.
  await saveSocialImage(post.id, snap.media_url)
  return new Response('ok')
}

```

The call is sync by default: it returns `201` with the finished `media_url`. Three details make it reliable:

- **Idempotency.** CMS webhooks retry, and so do serverless platforms. An `idempotency_key` built from the post ID and its update time means a retry returns the first snap and renders nothing. A real edit changes the update time, so it gets a new image.
- **Timeouts.** A sync render waits for Chrome. If your function has a short time limit, send `"async": true` with a `webhook_url`. The instance answers `202` at once and posts `snap.completed` to your URL when the image is ready. Check the `X-Snapsbrew-Signature` header of that webhook before you trust it.
- **Public images.** An `image_url` must be a public `http` or `https` address. A draft image behind a login does not render. The instance refuses private and loopback hosts.

## Trigger 3: a schedule reads a spreadsheet

Some images do not belong to a post. A conference has 40 speakers. A shop has 300 products on sale this week. Somebody keeps that list in Google Sheets or Airtable.

For a one-time list, export the sheet as CSV and upload it on the template page. Each row becomes one image. For a list that changes, a scheduled script reads the CSV, sends batches of up to 100 rows to `POST /v1/snaps/batches`, waits, and writes the image URLs back. The [spreadsheet guide](https://snapsbrew.com/guides/generate-images-from-spreadsheet.md) has the full script.

Two rules from the docs save hours here:

- The header row must match the layer keys of the template exactly. An unknown column or a missing column stops an upload, with an error that names the column.
- A `completed` batch can still have failed items. Read the status of each item, not only the status of the batch.

## One message, many sizes

A 1200x630 link card cropped to a 1080x1920 story looks wrong. Each platform needs its own shape.

The clean way is one template for each shape, with the **same layer keys**. Then the same variants render every size, and only the template ID changes:

```js
const variants = [{ layer: 'title', text: post.title }, { layer: 'photo', image_url: post.feature_image }]
const sizes = { og: process.env.TPL_OG, story: process.env.TPL_STORY, square: process.env.TPL_SQUARE }

const images = Object.fromEntries(await Promise.all(
  Object.entries(sizes).map(async ([name, templateId]) =>
    [name, (await sb.snaps.create({ templateId, variants, idempotencyKey: `post-${post.id}-${name}` })).media_url]),
))

```

Snapsbrew has 45 size presets, for example `open_graph` (1200x630) and `instagram_story` (1080x1920). If an AI agent builds the templates through the [MCP server](https://snapsbrew.com/product/mcp-server.md), the `platform-guide` tool returns the size, the crop and the safe zones of each platform.

## What breaks, and how to notice

- **Long text.** A title that fits in the CMS can overflow the card. Test the longest real title in a preview before you go live, and cut text in code if needed.
- **Missing images.** A post with no feature image sends an empty `image_url`. Leave the variant out instead, and the layer keeps the image of the template.
- **Rate limits.** The REST API allows 60 requests a minute for each user. A backfill of 2,000 old posts should use batches, not 2,000 single calls.
- **Silent failures.** Log the `X-Request-Uuid` header of each failed call. The person who runs the instance can find the request with it.

## When a no-code tool is the better answer

If nobody on the team writes code, the patterns above need a developer to set them up. Hosted template APIs have apps for Zapier, Make and Airtable that a marketer can wire alone. That is a real advantage, and the [comparison pages](https://snapsbrew.com/compare.md) say which product has which integrations. Snapsbrew is for the team that can run a server and a small script, and wants the images and the data to stay there.

## Questions

Which trigger needs the least code?

The signed URL. Your page template signs a URL with the values of the page, and that is all. Nothing is stored in the CMS, and no job runs.

How do I stop a CMS webhook from rendering the same image twice?

Send an idempotency key made from the ID and the update time of the post. A retry with the same key returns the first snap and renders nothing for 24 hours.

Can one template make images for Instagram, LinkedIn and X?

Not well. Each platform crops to its own shape. Make one template for each shape from the size presets, with the same layer keys, and send the same values to each one.

Do I need Zapier or Make for this?

No, if you can run a small script or a serverless function. Snapsbrew has no Zapier or Make app. Hosted APIs such as Bannerbear and Placid have them, which is a good reason to pick them for a no-code team.

## Related pages

- [How to generate images from a Google Sheet or an Airtable table](https://snapsbrew.com/guides/generate-images-from-spreadsheet.md)
- [How to generate dynamic OG images in Next.js](https://snapsbrew.com/guides/nextjs-og-images.md)
- [Docs: Snaps API](https://snapsbrew.com/docs/api/snaps.md)
- [The Snapsbrew MCP server](https://snapsbrew.com/product/mcp-server.md)

## Run it on your own server

Docker Compose starts the app, the queue, MySQL, Redis and the renderer together.

[Self-host it](https://snapsbrew.com/docs/getting-started/installation-docker.md) [View on GitHub](https://github.com/amedina068/snapsbrew)

```bash
git clone https://github.com/amedina068/snapsbrew.git
cd snapsbrew
cp .env.docker.example .env   # then fill in .env
docker compose up -d --build
```
