Webhook events and payloads
This page is for whoever builds the receiver. To add an endpoint, see Webhooks. The Events section of the Webhooks page (Settings tab) shows the same list, with an example payload for each event.
What a receiver gets
Section titled “What a receiver gets”Each event is a POST with a JSON body and these headers:
| Header | Value |
|---|---|
Naratica-Signature |
t=<unix time>,v1=<signature> (see below) |
Naratica-Event |
The event type, for example post.published |
Naratica-Event-Id |
The event id, for example evt_8121 |
Naratica-Delivery |
The delivery id |
User-Agent |
Naratica-Webhooks/1.0 |
Answer with any 2xx status within 10 seconds. Do slow work after you answer.
The body is always the same envelope:
{ "id": "evt_8121", "type": "post.published", "version": 1, "outlet": "demonews", "created_at": "2026-11-26T09:14:02Z", "data": { "post": { "...": "..." } }}idis unique and never reused. The same event can arrive twice (a retry after a timeout), so ignore anidyou already handled. Order isn’t guaranteed.versionchanges only when a field is removed or changes meaning. New fields can appear in the same version.outletis your outlet’s short name.- Times are UTC, ISO 8601.
- Test events have an id starting with
evt_test_and"test": true.
Events
Section titled “Events”| Event | When | data |
|---|---|---|
post.published |
A post becomes visible to readers: published, approved, a scheduled post reaching its time, an import that publishes. | post |
post.updated |
A visible post is saved and stays visible. | post |
post.unpublished |
A visible post stops being visible: back to draft, hidden, moved later or deleted. | post (as it was) |
reader.confirmed |
A reader confirms their newsletter sign-up, or is imported as confirmed. | reader |
reader.unsubscribed |
A confirmed reader unsubscribes, bounces, complains, is removed or deletes their account. | reader with reason |
comment.added |
A comment is saved on the site, waiting for review or approved. | comment |
membership.started |
A membership plan starts for a reader (payment, free plan, admin). Once per membership. | membership |
membership.ended |
A membership is cancelled or expires. Once per membership. | membership with reason |
Saving a draft, scheduling a post, or changing only a post’s other languages while it isn’t visible are not events.
{ "id": 84, "title": "Budget 2027: the five changes you will notice first", "url": "https://demonews.ro/budget-2027", "category": { "id": 3, "name": "Local" }, "language": "en", "published_at": "2026-11-24T18:00:00Z"}Main language only. category is null for a post without one.
reader
Section titled “reader”{ "email": "ana@example.com", "language": "ro", "reason": "unsubscribed" }Only the address and the sign-up language (null when unknown). reason is only on reader.unsubscribed: unsubscribed, bounced, complained, removed (by an admin) or deleted (the reader deleted their account). On deleted, forget the address in your tools too.
comment
Section titled “comment”{ "id": 5123, "post_id": 84, "parent_id": null, "status": "pending" }status is pending or approved. No name, email or text.
membership
Section titled “membership”{ "id": 41, "user_id": 17, "plan": { "id": 2, "name": "Supporter" }, "status": "cancelled", "gateway": "stripe", "expires_at": "2026-12-24T00:00:00Z", "reason": "cancelled"}reason is only on membership.ended: cancelled or expired. plan.name is in the site language.
Check the signature
Section titled “Check the signature”The Naratica-Signature header looks like t=1764148442,v1=5f2b…. v1 is the HMAC-SHA256, in hex, of <t>.<body> with the endpoint’s signing secret. After you rotate the secret, a second v1 signed with the old secret is added for 24 hours.
To check it:
- Read the raw body, before any JSON parsing.
- Compute HMAC-SHA256 of
t + "." + bodywith your secret. - Accept the event if any
v1matches andtis within 5 minutes of now.
<?php$secret = getenv('NARATICA_WEBHOOK_SECRET'); // whsec_...$body = file_get_contents('php://input');$header = $_SERVER['HTTP_NARATICA_SIGNATURE'] ?? '';
$t = null;$signatures = [];foreach (explode(',', $header) as $part) { [$k, $v] = array_pad(explode('=', trim($part), 2), 2, ''); if ($k === 't') { $t = (int) $v; } if ($k === 'v1') { $signatures[] = $v; }}
$expected = hash_hmac('sha256', $t . '.' . $body, $secret);$valid = false;foreach ($signatures as $signature) { $valid = $valid || hash_equals($expected, $signature);}if ($t === null || abs(time() - $t) > 300 || !$valid) { http_response_code(401); exit;}
$event = json_decode($body, true);// Skip $event['id'] if you already handled it, then queue the work.http_response_code(200);Node.js (Express)
Section titled “Node.js (Express)”import crypto from 'node:crypto';import express from 'express';
const app = express();const secret = process.env.NARATICA_WEBHOOK_SECRET; // whsec_...
app.post('/naratica', express.raw({ type: 'application/json' }), (req, res) => { const body = req.body.toString('utf8'); const parts = (req.get('Naratica-Signature') || '').split(',').map((p) => p.trim().split('=')); const t = Number(parts.find(([k]) => k === 't')?.[1]); const expected = crypto.createHmac('sha256', secret).update(`${t}.${body}`).digest('hex'); const valid = parts .filter(([k]) => k === 'v1') .some(([, v]) => v.length === expected.length && crypto.timingSafeEqual(Buffer.from(v), Buffer.from(expected)));
if (!t || Math.abs(Date.now() / 1000 - t) > 300 || !valid) { return res.sendStatus(401); }
const event = JSON.parse(body); // Skip event.id if you already handled it, then queue the work. res.sendStatus(200);});
app.listen(3000);