Receive webhooks
When you publish an entry or upload media, Hako CMS sends a webhook (an HTTP POST) to the URL you set. This page explains how to receive webhooks on your own server, verify that they really came from Hako CMS, and avoid processing the same notification twice when it is resent.
If you only want to trigger a Vercel or Netlify build, you do not need a receiving server. In the webhook’s [種類](Type), select [Vercel(Deploy Hook)](Vercel (Deploy Hook)) or [Netlify(Build Hook)](Netlify (Build Hook)), and enter the build hook URL.
Before you begin
Section titled “Before you begin”- You have created a webhook in the admin. Set [種類](Type) to [カスタム](Custom)
- You have set the webhook’s [署名のシークレット](Signing secret) (8–256 characters). Put the secret on the receiving server too
- The receiving URL is reachable from the internet.
https://is recommended. Webhooks cannot be sent to private addresses, such as an internal company network
The request you receive
Section titled “The request you receive”A webhook arrives in this form.
POST /your/endpoint HTTP/1.1Content-Type: application/jsonUser-Agent: Hako-Webhook/0.1.0X-HAKOCMS-Event: entry.publishedX-HAKOCMS-Delivery: d1e2f3a4b5c6X-HAKOCMS-Signature: 9f2c4e1b7a0d3c5e8f6a1b2c3d4e5f60718293a4b5c6d7e8f9a0b1c2d3e4f5a6The body is JSON. Its shape is described below, in “Body: entry events” and the following sections.
| Header | Contents |
|---|---|
X-HAKOCMS-Event |
The event name |
X-HAKOCMS-Delivery |
The delivery ID. It does not change when resent |
X-HAKOCMS-Signature |
The signature. Added only when you set [署名のシークレット](Signing secret) |
| [カスタムヘッダー](Custom headers) | Headers you added to the webhook |
Receive webhooks
Section titled “Receive webhooks”To receive webhooks, do the following:
- Before you parse the body as JSON, keep it as the raw bytes you received.
- Compute HMAC-SHA256 from the body bytes and the secret, and compare it with
X-HAKOCMS-Signature. If they do not match, return401and stop. - Return
2xxwithin 10 seconds. Do heavy work after you return. - Look at
deliveryId, and do nothing if you have already processed it.
Here is an example server in Node.js (22 or later) that does these four things. It uses no external packages. Save it as server.mjs.
import { createServer } from "node:http";import { createHmac, timingSafeEqual } from "node:crypto";
const secret = process.env.HAKO_WEBHOOK_SECRET;// Processed deliveryIds. In production, keep them in a DB or similarconst handled = new Set();
function verify(rawBody, signature) { if (typeof signature !== "string") return false; const expected = createHmac("sha256", secret) .update(rawBody) .digest("hex"); return ( expected.length === signature.length && timingSafeEqual(Buffer.from(expected), Buffer.from(signature)) );}
function handle(payload) { // Rebuild the site, purge caches, and so on here console.log(payload.event, payload.contentType ?? "", payload.id ?? "");}
createServer((req, res) => { const chunks = []; req.on("data", (chunk) => chunks.push(chunk)); req.on("end", () => { const rawBody = Buffer.concat(chunks); if (!verify(rawBody, req.headers["x-hakocms-signature"])) { res.writeHead(401).end(); return; } const payload = JSON.parse(rawBody.toString("utf8")); // Return 2xx first, and do heavy work later res.writeHead(204).end(); // If the same delivery arrives again as a resend, do nothing if (handled.has(payload.deliveryId)) return; handled.add(payload.deliveryId); handle(payload); });}).listen(3000);Replace <secret> with the webhook’s [署名のシークレット](Signing secret), and start the server.
HAKO_WEBHOOK_SECRET='<secret>' node server.mjsCompute the signature over the raw bytes you received. If you parse the JSON and turn it back into a string, the spaces and key order change, and the signature does not match. In frameworks such as Express, make sure you can get the body before JSON parsing (in Express, express.raw({ type: "application/json" })).
To compare, use timingSafeEqual, not ===. This prevents the signature from being guessed from how long the comparison takes.
Try it locally
Section titled “Try it locally”With the server running, send a signed request from another terminal. Replace <secret> with the same value you used to start the server.
body='{"event":"ping","space":"blog","deliveryId":"d1"}'sig=$(printf '%s' "$body" \ | openssl dgst -sha256 -hmac '<secret>' | sed 's/^.* //')curl -i -X POST http://localhost:3000 \ -H "Content-Type: application/json" \ -H "X-HAKOCMS-Signature: $sig" \ -d "$body"If you get HTTP/1.1 204 No Content and the server’s terminal shows ping, signature verification works. If you change X-HAKOCMS-Signature and send again, you get 401.
Check the result
Section titled “Check the result”Put the server somewhere reachable from the internet, enter its URL in the webhook’s [送信先の URL](Destination URL), and then send from Hako CMS.
- In the left menu of the admin, click [Webhook](Webhooks).
- Click the webhook for your receiving server.
- Click [テストの送信](Send test).
A ping event is sent right away, and the result is shown. If [送信履歴](Delivery history) shows [成功](Succeeded), you are receiving webhooks. If it shows [失敗](Failed), [応答](Response) shows the status and the start of the body that your server returned. If the connection failed, the reason is shown (timed out, connection refused, private network address is not allowed, and so on).
Resends
Section titled “Resends”If a webhook is not delivered successfully, Hako CMS sends it again.
- It fails if anything other than
2xxis returned, if the connection fails, or if there is no response within 10 seconds. Redirects (3xx) also count as failures and are not followed - After a failure, it is resent up to 5 times, at intervals of 30 seconds, 2 minutes, 10 minutes, 1 hour, and 6 hours
- Resends have exactly the same body (including
deliveryId). You can tell the same notification apart bydeliveryIdorX-HAKOCMS-Delivery - The order of arrival is not fixed. If you need order, compare
occurredAt - If an operation succeeds, the notification is always sent. If an operation fails, it is not sent. It usually takes 1–2 seconds from the operation to sending
Even after the resends are used up, you can send the same body again by clicking [もう一度送る](Send again) in [送信履歴](Delivery history) in the admin. Delivery history is kept for 30 days.
Events
Section titled “Events”| Event | Name on screen | When |
|---|---|---|
entry.published |
[エントリーの公開・公開中の更新](Entry published or published entry updated) | Published. A published entry was published again |
entry.draft_saved |
[下書きの保存](Draft saved) | A draft was saved (including creation) |
entry.unpublished |
[公開終了](Unpublished) | Unpublished |
entry.deleted |
[エントリーの削除](Entry deleted) | Deleted |
entry.schedule_failed |
[予約公開の失敗](Scheduled publishing failed) | Scheduled publishing could not be done (a required field is empty, and so on) |
media.uploaded |
[メディアの追加](Media added) | Media was uploaded |
media.deleted |
[メディアの削除](Media deleted) | Media was deleted |
ping |
[テスト](Test) | [テストの送信](Send test) was clicked |
- Webhooks are sent both for operations in the admin and for writes with an API key. They are not sent when a draft is discarded
- When scheduled publishing or unpublishing runs,
entry.publishedandentry.unpublishedare sent withactorset to{ "type": "system" } - Media events are not sent to a webhook whose [対象のコンテンツタイプ](Target content types) is narrowed to one
Body: entry events
Section titled “Body: entry events”{ "event": "entry.published", "deliveryId": "d1e2f3a4b5c6", "occurredAt": "2026-10-09T03:00:00.000Z", "space": "blog", "contentType": "articles", "id": "hello", "actor": { "type": "user", "id": "u1" }, "entry": { "status": "published", "published": { "sys": { "id": "hello", "contentType": "articles" }, "title": "こんにちは(改)" }, "draft": null }, "previous": { "status": "published_with_draft", "published": { "sys": { "id": "hello", "contentType": "articles" }, "title": "こんにちは" }, "draft": { "sys": { "id": "hello", "contentType": "articles" }, "title": "こんにちは(改)" } }}Part of sys is omitted in the example. In practice, it contains the same sys keys as a Content API entry.
| Key | Contents |
|---|---|
event |
The event name |
deliveryId |
The delivery ID. The same as X-HAKOCMS-Delivery |
occurredAt |
When the operation happened |
space |
The space slug |
contentType |
The content type ID |
id |
The entry ID |
actor |
Who performed the operation. { "type": "user", "id" } (a person), { "type": "apiKey", "id" } (an API key), { "type": "system" } (scheduled) |
entry |
The state after the operation. null for a deletion |
previous |
The state before the operation. null on creation |
schedule |
Only for entry.schedule_failed. { "action": "publish", "scheduledAt", "error" } |
truncated |
true only when the body exceeds 1 MB. published and draft become null, so read the entry again with the Content API |
The contents of entry and previous:
| Key | Contents |
|---|---|
status |
draft (never published), published, published_with_draft (published, with a draft), closed (unpublished) |
published |
The published revision. The same shape as a Content API entry, with references not expanded and rich text as JSON. null if there is none |
draft |
The draft. The same shape as published. null if there is none |
Body: media events
Section titled “Body: media events”{ "event": "media.uploaded", "deliveryId": "e5f6a7b8c9d0", "occurredAt": "2026-10-09T03:00:00.000Z", "space": "blog", "id": "k2m9x0a1b2c3", "actor": { "type": "user", "id": "u1" }, "media": { "sys": { "id": "k2m9x0a1b2c3" }, "url": "https://<media host>/media/k2m9x0a1b2c3/hero.jpg", "fileName": "hero.jpg", "mimeType": "image/jpeg", "size": 482113, "kind": "image", "width": 1920, "height": 1080 }}media is part of the shape returned by the media API. It does not include alt, tags, or dates.
Body: test (ping)
Section titled “Body: test (ping)”{ "event": "ping", "space": "blog", "deliveryId": "d1e2f3a4b5c6", "occurredAt": "2026-10-09T03:00:00.000Z", "webhook": { "id": "w1", "name": "本番サイト" }}Other types
Section titled “Other types”| [種類](Type) | Body you receive |
|---|---|
| [カスタム](Custom) | The bodies on this page |
| [Vercel(Deploy Hook)] | {}. Notifications not yet sent are combined into one |
| [Netlify(Build Hook)] | {}. Notifications not yet sent are combined into one |
| [Slack(Incoming Webhook)] | { "text": "..." }. A message such as “記事「こんにちは」を公開しました” (Published the article “こんにちは”) and a link to the admin |
For every type, a signature is added if you set [署名のシークレット](Signing secret).