ClipSDK Webhooks & Signature Verification
Receive signed HTTPS POST notifications for job.succeeded and job.failed events with HMAC-SHA256 verification, 300-second replay protection, and 5 automatic retries.
Webhook Headers & Delivery Contract
ClipSDK POSTs job.succeeded and job.failed JSON events to your HTTPS webhook_url with Clipsdk-Signature, Clipsdk-Job-Id, Clipsdk-Attempt, and Idempotency-Key headers.
| Header | Format / Example | Purpose |
|---|---|---|
Clipsdk-Signature | t=1796566019,v1=8a3f... | Unix timestamp plus hex HMAC-SHA256 of "<t>.<rawBody>" keyed with your webhook secret |
Clipsdk-Job-Id | job_3k9x0c2m1q8w7e6r5t4y | Identifier of the finished clipping job |
Clipsdk-Attempt | 1 to 5 | 1-based delivery attempt counter |
Idempotency-Key | <job_id>:<status> | Stable deduplication key identical across retries for the same job outcome |
User-Agent | clipsdk-webhooks/1 | Fixed ClipSDK webhook sender identifier |
Your webhook_url must use https:// on the default port (443) with no embedded user:pass@ credentials. Any 2xx HTTP response marks the event delivered. HTTP 3xx redirects are treated as failures and trigger a retry.
Webhook Event Payload Schema
Every webhook request body matches { event, job }, delivering the complete finished Job object so your consumer can ingest clips without an extra GET call.
{
"event": "job.succeeded",
"job": {
"id": "job_3k9x0c2m1q8w7e6r5t4y",
"op": "clips",
"status": "succeeded",
"stage": null,
"created_at": "2026-12-06T14:01:02Z",
"finished_at": "2026-12-06T14:04:19Z",
"usage": { "source_minutes": 38.4, "clips": 5, "output_seconds": 196.2 },
"pricing": { "basis": "source_minutes", "reason": null, "quality_multiplier": 1 },
"result": {
"source": { "duration_s": 2304, "language": "en", "speakers": null },
"clips": [
{
"rank": 1,
"score": 91,
"title": "Why 90-second intros kill viewer retention",
"video": "https://api.clipsdk.com/f/clip_rank1.mp4",
"poster": "https://api.clipsdk.com/f/clip_rank1.jpg",
"srt": "https://api.clipsdk.com/f/clip_rank1.srt",
"vtt": "https://api.clipsdk.com/f/clip_rank1.vtt"
}
],
"locked": null
},
"error": null,
"poll_url": "https://api.clipsdk.com/v1/jobs/job_3k9x0c2m1q8w7e6r5t4y"
}
}When a job fails, event is "job.failed", job.status is "failed", job.result is null, job.error contains { code, message }, and billing is $0. See all 12 job error codes in Pricing & Limits.
Verify Clipsdk-Signature in Node.js
Compute HMAC-SHA256 over the exact string "<t>.<rawBody>" using your webhook secret, verify with constant-time equality, and reject timestamps older than 300 seconds.
Never parse and re-stringify JSON before verifying Clipsdk-Signature. Whitespace or key-order changes invalidate the HMAC digest.
import crypto from "node:crypto";
import http from "node:http";
const WEBHOOK_SECRET = process.env.CLIPSDK_WEBHOOK_SECRET;
if (!WEBHOOK_SECRET) throw new Error("Set CLIPSDK_WEBHOOK_SECRET");
export function verifyClipsdkSignature(rawBody, headerValue, secret, toleranceSec = 300) {
if (!headerValue) return false;
const parts = {};
for (const item of headerValue.split(",")) {
const [k, v] = item.trim().split("=");
if (k && v) parts[k] = v;
}
const timestamp = Number(parts.t);
if (!Number.isFinite(timestamp) || !parts.v1) return false;
if (Math.abs(Math.floor(Date.now() / 1000) - timestamp) > toleranceSec) return false;
const expectedHex = crypto
.createHmac("sha256", secret)
.update(`${parts.t}.${rawBody}`)
.digest("hex");
const actual = Buffer.from(parts.v1, "hex");
const expected = Buffer.from(expectedHex, "hex");
return actual.length === expected.length && crypto.timingSafeEqual(actual, expected);
}
const seenKeys = new Set();
http.createServer((req, res) => {
if (req.method !== "POST" || req.url !== "/webhooks/clipsdk") {
res.writeHead(404).end();
return;
}
const chunks = [];
req.on("data", (chunk) => chunks.push(chunk));
req.on("end", () => {
const rawBody = Buffer.concat(chunks).toString("utf8");
const sig = req.headers["clipsdk-signature"];
if (!verifyClipsdkSignature(rawBody, String(sig ?? ""), WEBHOOK_SECRET)) {
res.writeHead(401).end("Invalid signature");
return;
}
const idemKey = String(req.headers["idempotency-key"] ?? "");
if (idemKey && seenKeys.has(idemKey)) {
res.writeHead(200).end("Already processed");
return;
}
if (idemKey) seenKeys.add(idemKey);
const payload = JSON.parse(rawBody);
// Acknowledge quickly within 15s, then mirror /f/{key} files asynchronously
queueMicrotask(() => {
console.log(payload.event, payload.job.id, payload.job.result?.clips?.length ?? 0);
});
res.writeHead(200).end("ok");
});
}).listen(8787);Retry Schedule & Timeout Rules
ClipSDK retries failed or timed-out webhook deliveries up to 5 total attempts (0s, +10s, +1m, +5m, +30m) using a 15-second timeout and identical request body bytes.
| Attempt | Delay After Previous Failure | Timeout | Success Criterion |
|---|---|---|---|
| Attempt 1 | Immediate (0s) | 15 seconds | Any 2xx status code (no redirects) |
| Attempt 2 | +10 seconds | 15 seconds | Same payload body and Idempotency-Key |
| Attempt 3 | +1 minute | 15 seconds | Same payload body and Idempotency-Key |
| Attempt 4 | +5 minutes | 15 seconds | Same payload body and Idempotency-Key |
| Attempt 5 | +30 minutes | 15 seconds | Final attempt; poll GET /v1/jobs/{id} to reconcile |
Production Consumer Checklist
Return HTTP 200 inside 15 seconds, deduplicate on Idempotency-Key in durable storage, and mirror 7-day /f/{key} files into your own bucket asynchronously.
- Decouple Heavy Downloads: Never download multi-megabyte MP4 files synchronously inside the webhook HTTP handler. Store the verified event in your database or queue, reply
200, and copyclip.video,clip.poster,clip.srt, andclip.vttfrom a background worker. - Persist
Idempotency-Key: Store<job_id>:<status>with a unique constraint in Postgres or Redis so network timeouts after commit never duplicate user notifications or social posts. - Reconcile Missed Deliveries: Run a lightweight periodic sweeper calling
GET /v1/jobs/{id}on any job still marked running after 30 minutes to recover cleanly from extended endpoint outages. - Zero-Dependency Reference Scripts: Download the runnable verifier and
--self-testharness from bitgate/clipsdk-api-skills.