Developer API
Webhooks
Spotlight sends a signed POST to your server when something happens on your page. Set them up in Dashboard → API key → Webhooks (up to 3 URLs).
Events#
| follower.new | event | Someone followed you |
| tip.received | event | You got a tip |
| sale.completed | event | Someone bought a download |
| member.joined | event | Someone became a member |
| commission.request | event | A commission request came in |
| endorsement.new | event | Someone wrote you a recommendation |
| post.comment | event | A comment on your status post |
| post.like | event | Someone liked your status post |
| mention | event | Someone mentioned you with @ |
Private messages and sign-in alerts are never sent to webhooks. A test button sends a test event.
The request#
Headers
| Content-Type | application/json | Always JSON |
| User-Agent | Spotlight-Webhooks/1.0 | Identifies Spotlight |
| X-Spotlight-Event | string | The event name, e.g. follower.new |
| X-Spotlight-Signature | t=<unix>,v1=<hex> | HMAC-SHA256 signature, see below |
Body
| id | string | Unique delivery id |
| event | string | Event name |
| created | number | Unix time in seconds |
| data | object | Event details, e.g. { "user": "username" } for who did it |
follower.new
{
"id": "9f2c4a1b7e3d5c60",
"event": "follower.new",
"created": 1731110400,
"data": { "user": "froze" }
}Verify the signature#
The signature is HMAC-SHA256(secret, "<t>.<raw body>") in hex. Compare it in constant time, and reject requests older than a few minutes so old ones can't be replayed. Use the raw body exactly as received.
import crypto from "node:crypto";
export function verify(rawBody, header, secret, maxAgeSec = 300) {
const parts = Object.fromEntries(header.split(",").map((p) => p.split("=")));
const t = Number(parts.t);
if (!t || Math.abs(Date.now() / 1000 - t) > maxAgeSec) return false; // too old: maybe replayed
const expected = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
const a = Buffer.from(expected), b = Buffer.from(parts.v1 ?? "");
return a.length === b.length && crypto.timingSafeEqual(a, b);
}
// Express: app.post("/hook", express.raw({ type: "application/json" }), (req, res) => {
// if (!verify(req.body.toString(), req.get("X-Spotlight-Signature"), process.env.WHSEC)) return res.sendStatus(401);
// const event = JSON.parse(req.body); res.sendStatus(200);
// });Delivery rules#
- HTTPS only, on the standard port, without a username or password in the URL.
- Private, local and internal addresses are refused (for example
localhost,10.x,192.168.x, cloud metadata addresses). - Redirects aren't followed. Answer within 5 seconds with any 2xx status.
- Each event is sent once. The last 20 deliveries and their status codes show in the dashboard.
Your secret#
Each webhook has its own secret starting with whsec_, shown only once when you create it. Lost it? Delete the webhook and add it again.
Answer fast and do slow work afterwards (queue it). A webhook that keeps timing out still counts as delivered once, so nothing piles up.