Webhooks
Cadastre um endpoint https em Settings > API access, escolha os eventos que quer e um evento JSON assinado é enviado assim que algo muda.
project.readyproject.failedclip.renderedexport.failed
Verifique a assinatura
import { createHmac, timingSafeEqual } from "node:crypto";
const TOLERANCE_SECONDS = 5 * 60;
export function verifyCastKit(rawBody, header, secret) {
const parts = Object.fromEntries(
(header ?? "").split(",").map((part) => part.trim().split("=", 2)),
);
const t = Number(parts.t);
if (!Number.isInteger(t) || !parts.v1) return false;
if (Math.abs(Date.now() / 1000 - t) > TOLERANCE_SECONDS) return false;
const expected = createHmac("sha256", secret)
.update(`${parts.t}.${rawBody}`)
.digest();
const given = Buffer.from(parts.v1, "hex");
return given.length === expected.length && timingSafeEqual(given, expected);
}Verifique o corpo bruto e depois faça o parse
app.post(
"/webhooks/castkit",
express.raw({ type: "application/json" }),
(req, res) => {
const rawBody = req.body.toString("utf8");
const header = req.get("CastKit-Signature");
if (!verifyCastKit(rawBody, header, process.env.CASTKIT_WEBHOOK_SECRET)) {
return res.status(400).end();
}
const event = JSON.parse(rawBody);
res.status(200).end();
handle(event);
},
);Entrega
POST /webhooks/castkit
CastKit-Signature: t=1791187200,v1=5f2b9c...
CastKit-Event-Id: evt_3f1c...
CastKit-Event-Type: clip.rendered
{
"id": "evt_3f1c...",
"type": "clip.rendered",
"createdAt": "2026-10-05T08:00:00.000Z",
"data": {
"export": { "id": "...", "status": "done", "download": { "url": "...", "expiresAt": "..." } },
"clip": { "id": "...", "title": "...", "projectId": "..." }
}
}Seu primeiro clipe pelo código está a uma chave de distância.
Crie uma chave, cole o início rápido em um terminal e veja a primeira exportação chegar. O primeiro episódio é grátis.