Contents

Build a headless site

Read published pages, entries and menus from your website's server and refresh on publish.

Set up access

  1. In Nucleo, go to CMS > your site > Settings > For developers.
  2. Copy the base URL of the site and replace {tenant} in it with your company's workspace slug (ask Nucleo support if you do not know it).
  3. Select Create token and store the cmsdt_… value as a secret on your server — it is shown once.

The token reads only that site's published content. Call the API from your server or at build time: it does not accept browser calls, so the token never reaches visitors.

Fetch a page

Resolve the URL the visitor asked for into a page:

// Next.js (App Router): app/[...slug]/page.js
import { notFound } from "next/navigation";

const BASE = "https://api-brain.nucleoplatform.com/api/delivery/v1/acme/sites/12";

async function nucleo(path) {
  const res = await fetch(`${BASE}${path}`, {
    headers: { Authorization: `Bearer ${process.env.NUCLEO_CMS_TOKEN}` },
    next: { tags: ["nucleo"] },
  });
  if (res.status === 404) return null;
  if (!res.ok) throw new Error(`Nucleo CMS: ${res.status}`);
  return res.json();
}

export default async function Page({ params }) {
  const { slug = [] } = await params;
  const page = await nucleo(`/page?path=/${slug.join("/")}&locale=en`);
  if (!page) return notFound();
  // render page.data …
}

Use /collections/{collection}/entries for blog posts and news, /menus for navigation, /redirects to apply the redirects your editors set and /sitemap to build sitemap.xml. All of it is in the Content Delivery reference.

Refresh when editors publish

Cache everything you fetch and let Nucleo tell you when to refresh: set a Revalidate URL and secret in the site settings and handle the call as shown below.

The call comes only when a page or an entry is published. Deleting a page or an entry, and changes to menus or redirects, send nothing: give those a short cache lifetime or refresh them on a schedule.

Handle the revalidate call

Set it up in Nucleo under CMS > your site > Settings: enter your Revalidate URL and a Revalidate secret. Right after every publish Nucleo sends a signed request:

POST /api/revalidate HTTP/1.1
Host: www.acme.example
Content-Type: application/json
User-Agent: Nucleo-Webhooks/1.0
Nucleo-Signature: t=1791115200,v1=5f2b6c0e9a8d4f7b1c3e2a6d9b0f8e7c6a5d4b3c2e1f0a9b8c7d6e5f4a3b2c1d
Nucleo-Webhook-Id: 3f6c1a52-8e0b-4d7a-9c2e-1b5d7f9a0c34
Nucleo-Webhook-Event: content.published
Nucleo-Webhook-Attempt: 1

{"id":"3f6c1a52-8e0b-4d7a-9c2e-1b5d7f9a0c34","event":"content.published","site":"acme-website","locale":"en","path":"/blog","published_at":"2026-10-04T12:00:00+00:00","secret":"whsec_example_123"}
  • A page published sends path: "/" (refresh the whole site); an entry published sends /<collection-slug>.
  • Only publishing sends the call. Deleting a page or an entry, and changes to menus or redirects, send nothing: refresh those on a schedule.
  • 5-second timeout, redirects not followed. Answer with any 2xx; the body is ignored.
  • Retries. Any other answer, or no answer in time, is retried after 1 minute, 5 minutes, 30 minutes, 2 hours and 6 hours — at most 6 attempts, then Nucleo gives up. Every attempt carries the same id (also in Nucleo-Webhook-Id) and its number in Nucleo-Webhook-Attempt: refreshing the cache twice is harmless, but you can skip an id you have already handled.
  • The secret field in the body is deprecated and will be removed: verify the signature instead.

Verify the signature before doing anything. Nucleo-Signature is t=<unix time>,v1=<signature>, where the signature is the lowercase hex HMAC-SHA256 of <t>.<raw body> keyed with your Revalidate secret. Compute it on the exact bytes you received (before parsing the JSON), compare in constant time, and reject a t older than 5 minutes. A request without the header means no secret is set on the site: set one.

// Next.js route handler: app/api/revalidate/route.js
import { createHmac, timingSafeEqual } from "node:crypto";
import { revalidatePath } from "next/cache";

const TOLERANCE_SECONDS = 300;

function verify(header, rawBody, secret) {
  const parts = Object.fromEntries(header.split(",").map((p) => p.split("=")));
  const t = Number(parts.t);
  if (!secret || !parts.v1 || !Number.isFinite(t)) return false;
  if (Math.abs(Date.now() / 1000 - t) > TOLERANCE_SECONDS) return false;
  const expected = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
  const a = Buffer.from(expected);
  const b = Buffer.from(parts.v1);
  return a.length === b.length && timingSafeEqual(a, b);
}

export async function POST(req) {
  const rawBody = await req.text();
  const signature = req.headers.get("nucleo-signature") ?? "";
  if (!verify(signature, rawBody, process.env.NUCLEO_REVALIDATE_SECRET ?? "")) {
    return new Response("Forbidden", { status: 403 });
  }
  const { path = "/" } = JSON.parse(rawBody);
  revalidatePath(path === "/" ? "/" : path, "layout");
  return Response.json({ revalidated: true });
}