Publishing integrations
Next.js and custom sites (webhook)
Receive published articles as JSON on your own endpoint — payload shape, signature verification and a Next.js example.
If your site is a Next.js app, a headless front end, or anything else without a content API, Clodix can POST each published article as JSON to a URL you control. This is the integration to use for custom-built sites — and it also works well as a trigger for Zapier or Make.
Connect it
- Open Settings → Publishing integrations and click Next.js / Webhook.
- Fill in:
- Webhook URL — an
https://address on your server that accepts a POST request. - Signing secret (optional) — set one and Clodix signs every request so you can verify it really came from us.
- Webhook URL — an
- Click Connect. Clodix sends a test ping immediately — your endpoint must respond with a 2xx status for the connection to succeed.
The payload
Every request is POSTed as JSON with a content-type: application/json header. The envelope always has an event field; the body shape depends on the event.
article.published — sent when an article goes live, and again whenever you edit and republish it:
{
"event": "article.published",
"article": {
"title": "Best pour over coffee makers in 2026",
"slug": "best-pour-over",
"bodyHtml": "<p>...</p>",
"metaDescription": "A guide to the best pour over coffee makers.",
"imageUrl": "https://cdn.clodix.ai/covers/best-pour-over.jpg",
"publishedAt": "2026-08-01T10:00:00.000Z"
}
}
metaDescription, imageUrl and publishedAt are only included when the article has them.
article.unpublished — sent when you unpublish an article:
{ "event": "article.unpublished", "article": { "slug": "best-pour-over" } }
clodix.ping — the connection test sent once, when you click Connect:
{ "event": "clodix.ping" }
Headers
| Header | Value |
|---|---|
content-type | application/json |
x-clodix-event | The same value as the event field in the body. |
x-clodix-signature | Only sent when you set a signing secret — see below. |
Verifying the signature
When you set a signing secret, Clodix signs the exact raw request body with HMAC-SHA256, keyed by your secret, and sends it as x-clodix-signature: sha256=<hex digest>.
// app/api/clodix/route.ts
import { createHmac, timingSafeEqual } from "crypto";
import { NextRequest, NextResponse } from "next/server";
const SECRET = process.env.CLODIX_WEBHOOK_SECRET!;
export async function POST(req: NextRequest) {
const rawBody = await req.text(); // read as text BEFORE parsing JSON
const signature = req.headers.get("x-clodix-signature") ?? "";
const expected =
"sha256=" + createHmac("sha256", SECRET).update(rawBody).digest("hex");
const ok =
signature.length === expected.length &&
timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
if (!ok) {
return NextResponse.json({ error: "invalid signature" }, { status: 401 });
}
const payload = JSON.parse(rawBody);
// payload.event is "article.published" | "article.unpublished" | "clodix.ping"
// ... upsert payload.article into your database/CMS by slug ...
return NextResponse.json({ ok: true });
}
Respond with 2xx
Your endpoint must answer with a success status (200–299) for Clodix to count the publish as successful — including the connection test. A non-2xx response (or no response at all) is treated as a failed publish: the article stays a draft in Clodix and the connect screen (or the article's Publish button) shows the status your endpoint actually returned.
Returning a live URL (optional)
If your endpoint replies with { "url": "https://yoursite.com/blog/best-pour-over" }, Clodix stores that as the article's published URL and uses it to ping search engines that the page is new. This is optional — your endpoint can simply return { "ok": true } with no URL.
FAQ
Do I need a signing secret?
It's optional but recommended for anything public-facing — it's the only way your endpoint can confirm a request really came from Clodix and not from someone who guessed your URL.
What happens if my server is down when Clodix tries to publish?
The publish fails and the article stays a draft. See Publishing problems for what Clodix does next and how to retry safely.
Can I use this with Zapier or Make instead of my own server?
Yes — paste the webhook URL Zapier or Make gives you for a "Catch Hook" / "Custom Webhook" trigger into the Webhook URL field, and build your automation from there.