Webhooks
When a job ends, we send a POST to your webhook endpoints with the job as GET /v1/jobs/{id} shows it. You don’t poll; your server hears once, when there’s something to do.
Add an endpoint
Section titled “Add an endpoint”In the dashboard, open Webhooks and add the endpoint’s URL, or make one with the API (a key with the webhooks scope):
curl https://api.formatjet.com/v1/webhooks \ -H "Authorization: Bearer $FORMATJET_API_KEY" \ -H "Content-Type: application/json" \ -d '{"url": "https://example.com/formatjet/events", "events": ["job.completed", "job.failed"]}'The answer includes the endpoint’s secret (whsec_…). It’s shown now only: store it with your other secrets. The URL must use HTTPS on a public host name, on port 443 or one from 1024 up. Each mode has its own endpoints, up to 10: jobs made with test keys are sent to test endpoints, live jobs to live ones.
To have one job’s events sent somewhere else as well, give the job a webhook URL. Those deliveries are signed with your organization’s job-webhook secret, which the dashboard’s Webhooks page shows, as does GET /v1/webhooks/job-secret with a live key that has the webhooks scope. That one secret signs test jobs’ deliveries as well as live ones’, and anyone with a test key can give a test job any webhook URL: a receiver for live jobs must check the body’s mode too, and ignore test events.
An endpoint gets every job of its mode unless you narrow it: conversions (up to 50 slugs) sends only jobs with a step that runs one of them, and metadata (up to 5 values) only jobs whose metadata has every one of those values. Change or clear them with PATCH /v1/webhooks/{id}; null sends every job again.
What we send
Section titled “What we send”Events are job.completed, job.failed and job.canceled; an endpoint gets the ones it asked for (every one by default). The body is JSON:
{ "id": "evt_01JBXA4C7E9G1H3J5K7M9N1P3Q", "type": "job.completed", "created_at": "2026-10-24T10:00:06.000Z", "mode": "live", "data": { "job": { "id": "job_01JBXA3Q6M2T8V4W9Y5Z7B1C3D", "status": "completed", "conversion": "word-to-pdf", "credits": 2, "outputs": [ { "id": "file_01JBXA3R2N5P7Q9S1T3V5W7X9Z", "filename": "report.pdf", "url": "https://…", "expires_at": "2026-10-25T10:00:06.000Z" } ], "metadata": { "invoice": "INV-1042" }, "…": "…" } }}With these headers:
| Header | Value |
|---|---|
FormatJet-Signature |
t=<unix seconds>,v1=<hex>: see below |
FormatJet-Event |
The event’s type |
FormatJet-Event-Id |
The event’s id, the same on every attempt |
FormatJet-Delivery-Attempt |
1 for the first attempt, then 2, 3, … |
Answer with any 2xx within 10 seconds; anything else, a redirect included, counts as a failure. Do the work after answering, from a queue if it’s slow. The same event can arrive more than once, and events can arrive out of order: use id to skip ones you’ve handled, and the job’s status rather than the order of events.
Check the signature
Section titled “Check the signature”Every delivery is signed with the endpoint’s secret: v1 is an HMAC-SHA256 of the timestamp, a dot and the raw body. Check it before you trust the body, with the body exactly as it arrived: parse the JSON afterwards, since re-serialised JSON won’t match.
import { createHmac, timingSafeEqual } from 'node:crypto';
/** * Checks a FormatJet webhook delivery. `body` is the raw request body exactly as it arrived * (read it before parsing the JSON), `header` the FormatJet-Signature header and `secret` * the endpoint's secret. */export function verifyFormatJetSignature( body: string, header: string | null, secret: string, toleranceSeconds = 300, now = Date.now() / 1000,): boolean { if (!header) return false; const parts = header.split(',').map((part) => part.trim().split('=')); const timestamp = Number(parts.find(([name]) => name === 't')?.[1]); // A delivery signed too long ago may be a replay of a captured one. if (!Number.isInteger(timestamp) || Math.abs(now - timestamp) > toleranceSeconds) return false; const expected = createHmac('sha256', secret).update(`${timestamp}.${body}`).digest(); // While a rotated secret is still valid, the header carries a v1 for each secret. return parts.some( ([name, value]) => name === 'v1' && /^[0-9a-f]{64}$/.test(value ?? '') && timingSafeEqual(Buffer.from(value!, 'hex'), expected), );}import hashlibimport hmacimport time
def verify_formatjet_signature(body, header, secret, tolerance_seconds=300, now=None): """Checks a FormatJet webhook delivery.
body is the raw request body as bytes, exactly as it arrived (read it before parsing the JSON), header the FormatJet-Signature header and secret the endpoint's secret. """ if not header: return False timestamp, signatures = None, [] for part in header.split(","): name, _, value = part.strip().partition("=") if name == "t" and value.isdigit(): timestamp = int(value) elif name == "v1": signatures.append(value) # A delivery signed too long ago may be a replay of a captured one. now = time.time() if now is None else now if timestamp is None or abs(now - timestamp) > tolerance_seconds: return False message = f"{timestamp}.".encode() + body expected = hmac.new(secret.encode(), message, hashlib.sha256).hexdigest() # While a rotated secret is still valid, the header carries a v1 for each secret. return any(hmac.compare_digest(signature, expected) for signature in signatures)Refuse deliveries whose timestamp is more than 5 minutes from your clock, so a captured request can’t be replayed later. When you rotate a secret (in the dashboard, or POST /v1/webhooks/{id}/rotate-secret), deliveries carry a v1 for the new secret and one for the old for 24 hours: a receiver that accepts any matching v1 switches without missing one.
Retries
Section titled “Retries”A failed delivery is tried 8 times in all, timed from the event: at once, 1 minute, 6 minutes, 36 minutes, 2.6 hours, 7.6 hours, 17.6 hours, 24 hours. An endpoint that has failed for 24 hours is turned off, and the account’s owners are emailed. Turn it back on in the dashboard (or with PATCH /v1/webhooks/{id} and "enabled": true); events that ended while it was off aren’t sent by themselves.
Every attempt is kept for 7 days with its outcome, never its body. The dashboard lists them, and POST /v1/webhooks/{id}/replay sends an event again, now: handy after an outage, or to test a receiver.