Skip to content

Refresh your site with a webhook

Page

Guide

Updated 13/11/2026

After publishing, the site should show the new version at once. There are three layers of assurance; the webhook is the fastest.

  1. Webhook (about 1 second in the CMS measurements): the CMS calls the site, the site clears the entry’s cache.
  2. 60-second TTL on every CMS call the site makes: the safety net when a webhook is missed or the endpoint is paused.
  3. CDN in front: entries carry s-maxage=300. Either purge the CDN by tag when the webhook arrives, or keep the CDN TTL at 60 seconds or less.

Before you start

  • The CMS server runs background jobs (CMS_WORKERS_ENABLED=true). Without it there are no webhooks, only the 60-second TTL.
  • The site endpoint uses https and a public address. The CMS blocks internal addresses and checks again on every delivery.
  • Permission cms.webhook.write to register.

Steps

  1. Register the endpoint: POST /admin/cms/webhooks with the site url (the sample code uses /api/cms-webhook) and the events you need: cms.entry.published, cms.entry.unpublished, cms.entry.deleted, cms.entry.undeleted.
  2. Save the whsec_… secret immediately: the CMS returns it once.
  3. In the endpoint, verify the signature per Standard Webhooks before anything else: the signed content is webhook-id.webhook-timestamp.raw-body, HMAC-SHA256, header webhook-signature. Use the raw body, not a re-serialised one. The sample neutral/revalidate-handler.mjs does this.
  4. Clear the cache tag (or path) of the entry and answer 2xx quickly. The same webhook-id can arrive more than once: handling a repeat must be harmless.
  5. Set revalidate: 60 (Next) or ttlMs: 60000 on every CMS call as the safety net.

Operating it

  • Rotate the secret with POST /admin/cms/webhooks/{id}/rotate-secret; the old secret keeps working for grace_seconds (up to 7 days) so no event is lost.
  • An endpoint that fails many times in a row is paused; read the delivery log at GET /admin/cms/webhooks/{id}/deliveries and retry with …/deliveries/retry.
  • The event only says which entry changed. The site always re-reads content from the Store API and never trusts data in the webhook body.

See also

Last updated: