Webhooks
How webhooks work
Webhooks let your server receive real-time events from Juice Reel without polling for updates.
Juice Reel sends an HTTP POST request to your configured destination endpoint with the data for the event bucket you selected. Verify the signature against the raw request body before parsing or processing the event, then return a successful 2xx response after accepting it.
Webhook flow
1. ConfigureAdd a destination endpoint and choose the event bucket it should receive.
2. ReviewJuice Reel reviews the endpoint before delivery begins.
3. ReceiveAccept signed POST requests and process each event on your server.
Verify the HMAC signature
Node.js
import express from "express";
import crypto from "node:crypto";
const app = express();
function verifyJuiceReelWebhook(rawBody, signature, secret) {
const expected = "sha256=" + crypto
.createHmac("sha256", secret)
.update(rawBody)
.digest("hex");
const received = Buffer.from(signature, "utf8");
const computed = Buffer.from(expected, "utf8");
return received.length === computed.length
&& crypto.timingSafeEqual(received, computed);
}
app.post(
"/webhooks/juice-reel",
express.raw({ type: "application/json" }),
(req, res) => {
const signature = req.get("X-Juice-Reel-Signature");
const secret = process.env.JUICE_REEL_WEBHOOK_SIGNING_SECRET;
if (!signature || !secret || !verifyJuiceReelWebhook(req.body, signature, secret)) {
return res.sendStatus(401);
}
// Parse only after the HMAC has been verified.
const event = JSON.parse(req.body.toString("utf8"));
console.log("Juice Reel event:", event.type, event.data);
return res.sendStatus(204);
},
);