Webhooks
A webhook sends your server a signed message when a job ends, so you don’t have to keep asking.
On this page
| Event | Sent when |
|---|---|
job.completed | A job ended and every task completed, apart from any that were cancelled. Its results are ready to download. |
job.partly_failed | A job ended with some tasks completed and some failed. |
job.failed | A job ended with every task failed, apart from any that were cancelled. |
job.cancelled | A job was cancelled before any task completed. |
credits.low | The Workspace’s credits fell below the alert level set on its Billing page. It’s sent with the low-credit email, so turning that email off stops it too. |
Job events are sent for jobs started with the Workspace’s API keys. Every event and its payload is in the webhook events reference.
An endpoint is an HTTPS address on the public internet that we send messages to. Add it in your Workspace’s Settings, then Webhooks, with Add endpoint, or with the API. Choose the events it receives: all of them if you leave events out.
curl -X POST https://api.filesokay.com/v1/webhooks \
-H "Authorization: Bearer $FILESOKAY_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/webhooks/filesokay",
"events": [
"job.completed",
"job.partly_failed",
"job.failed"
]
}'const res = await fetch("https://api.filesokay.com/v1/webhooks", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.FILESOKAY_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
url: "https://example.com/webhooks/filesokay",
events: [
"job.completed",
"job.partly_failed",
"job.failed"
]
}),
});
const endpoint = await res.json();import os
import requests
res = requests.post(
"https://api.filesokay.com/v1/webhooks",
headers={
"Authorization": f"Bearer {os.environ['FILESOKAY_KEY']}",
},
json={
"url": "https://example.com/webhooks/filesokay",
"events": [
"job.completed",
"job.partly_failed",
"job.failed"
]
},
)
endpoint = res.json(){
"id": "wh_5b0e3c1f9a7d42e8b6c4d2f0a8e61b37",
"url": "https://example.com/webhooks/filesokay",
"events": [
"job.completed",
"job.partly_failed",
"job.failed"
],
"enabled": true,
"disabled_at": null,
"created_at": "2026-12-03T09:25:50Z",
"secret": "whsec_…"
}The answer holds the endpoint’s signing secret, which starts with whsec_. It’s shown this once: keep it on your server. A Workspace can have up to 20 endpoints.
Each message is a POST with a JSON body and three headers:
webhook-id: msg_0f1e2d3c4b5a69788796a5b4c3d2e1f0
webhook-timestamp: 1796289832
webhook-signature: v1,agm4oAVNWfBnEdXQnRGD9O2uh2MVVu8hPeQf/mc6UB4={
"type": "job.completed",
"timestamp": "2026-12-03T09:23:52Z",
"data": {
"id": "job_a1c9531eeb00434aba0058796f1ca517",
"operation": "video.compress",
"status": "completed",
"client_reference": "lecture-0412",
"settings": {
"audio": "keep",
"codec": "same",
"method": "target_size",
"target": {
"unit": "percent",
"value": 50
},
"frame_rate": "original",
"resolution": "auto",
"output_format": "same"
},
"created_at": "2026-12-03T09:23:14Z",
"started_at": "2026-12-03T09:23:33Z",
"finished_at": "2026-12-03T09:23:50Z",
"reserved_credits": 2,
"charged_credits": 1,
"tasks": [
{
"id": "task_3f648f64472b4ea4b88568eea9d4f88c",
"status": "completed",
"progress": 100,
"reserved_credits": 2,
"charged_credits": 1,
"inputs": [
{
"file_id": "file_3cf0737aefa34b89b7b4443c9467d60c",
"name": "lecture.mp4"
}
],
"outputs": [
{
"file_id": "file_a1c8014998a14c4da72d6e6a0c74314c",
"name": "lecture-compressed.mp4",
"size": 6054914,
"download_url": "https://…",
"download_expires_at": "2026-12-06T09:23:50Z"
}
]
}
]
}
}For a job event, data is the job as GET /v1/jobs/{id} returns it, with fresh download links and your client_reference.
Check every message before you act on it. Our webhooks follow the Standard Webhooks specification, so any of its libraries can do it, or you can check it yourself:
- Join the
webhook-id, thewebhook-timestampand the raw body with dots:{id}.{timestamp}.{body}. - Sign it with HMAC-SHA256, using the secret’s bytes: the part after
whsec_, decoded from Base64. - Compare it, in Base64, with the signature after
v1,inwebhook-signature, using a constant-time comparison. - Refuse a message whose timestamp is more than 5 minutes old, which stops a replayed message.
Use the body exactly as it arrived: parsed and written again, it no longer matches its signature.
import crypto from "node:crypto";
import http from "node:http";
const SECRET = process.env.FILESOKAY_WEBHOOK_SECRET; // whsec_…
// True when the endpoint's secret signed this message in the last 5 minutes.
function verify(headers, body) {
const id = headers["webhook-id"];
const timestamp = headers["webhook-timestamp"];
if (!id || !(Math.abs(Date.now() / 1000 - Number(timestamp)) <= 300)) {
return false;
}
const key = Buffer.from(SECRET.slice("whsec_".length), "base64");
const expected = crypto
.createHmac("sha256", key)
.update(`${id}.${timestamp}.${body}`)
.digest();
return (headers["webhook-signature"] ?? "").split(" ").some((entry) => {
const [version, signature] = entry.split(",");
const given = Buffer.from(signature ?? "", "base64");
return (
version === "v1" &&
given.length === expected.length &&
crypto.timingSafeEqual(given, expected)
);
});
}
http
.createServer((req, res) => {
let body = "";
req.setEncoding("utf8");
req.on("data", (chunk) => (body += chunk));
req.on("end", () => {
if (!verify(req.headers, body)) return res.writeHead(400).end();
res.writeHead(200).end(); // Answer first, then do the work.
const message = JSON.parse(body);
console.log(message.type, message.data.id);
});
})
.listen(3000);import base64
import hashlib
import hmac
import json
import os
import time
from http.server import BaseHTTPRequestHandler, HTTPServer
SECRET = os.environ["FILESOKAY_WEBHOOK_SECRET"] # whsec_…
def verify(headers, body):
"""True when the endpoint's secret signed this message in the last 5 minutes."""
msg_id = headers.get("webhook-id")
timestamp = headers.get("webhook-timestamp", "")
if not msg_id or not timestamp.isdigit() or abs(time.time() - int(timestamp)) > 300:
return False
key = base64.b64decode(SECRET.removeprefix("whsec_"))
signed = f"{msg_id}.{timestamp}.".encode() + body
expected = base64.b64encode(hmac.new(key, signed, hashlib.sha256).digest()).decode()
entries = (entry.partition(",") for entry in headers.get("webhook-signature", "").split())
return any(v == "v1" and hmac.compare_digest(sig, expected) for v, _, sig in entries)
class Webhook(BaseHTTPRequestHandler):
def do_POST(self):
body = self.rfile.read(int(self.headers["Content-Length"]))
if not verify(self.headers, body):
self.send_response(400)
self.end_headers()
return
self.send_response(200) # Answer first, then do the work.
self.end_headers()
message = json.loads(body)
print(message["type"], message["data"].get("id"))
HTTPServer(("", 3000), Webhook).serve_forever()- Answer with any
2xxstatus within 15 seconds. Answer first, then do the work. - Any other answer, a redirect or no answer is tried again, up to 9 more times over about 3 days.
- An endpoint that keeps failing for 72 hours is switched off, and the Workspace’s Admins get an email. Switch back on in Settings starts it again.
- A message can arrive more than once.
webhook-idstays the same on every retry: process each one once.
Settings shows each endpoint’s deliveries for the last 30 days, and Resend sends one again. Send test event sends a webhook.test message, to check your server before going live.