Webhooks
Webhooks tell your server when a job changes state, so you never have to poll. Deskew signs every delivery, retries failures for about a day, and disables an endpoint that has been failing for three days.
Set up an endpoint
Section titled “Set up an endpoint”Open Webhooks in the dashboard and add an HTTPS URL. Each endpoint has:
- a secret (
whsec_…) shown once at creation and on demand under Reveal, and rotatable; - a list of events it subscribes to (default
job.completedandjob.failed); - a mode, inherited from the dashboard’s Test / Live switch; test jobs only reach test endpoints.
Use Send test to receive a sample job.completed event with "test": true in the payload. Every delivery, with request body, response code and timing, is listed under the endpoint.
Per-request URL
Section titled “Per-request URL”You can also pass webhook_url on a single POST /v1/extract. That URL receives the job’s events in addition to any configured endpoints. Deliveries to a per-request URL are signed with a project-less key you cannot verify, so use configured endpoints for anything you need to trust.
Events
Section titled “Events”| Event | When |
|---|---|
job.queued |
An async job was accepted |
job.processing |
A worker started on the job |
job.completed |
The result is stored; data.result_url is set |
job.failed |
The job failed; data.error is set |
Synchronous jobs that finish inside the request still emit job.processing and job.completed (or job.failed), so a webhook sees every job.
Payload
Section titled “Payload”{ "id": "evt_01JE4KD3N8P9Q0R1S2T3U4V5W6", "type": "job.completed", "created_at": "2026-12-02T09:16:41.027Z", "data": { "id": "job_01JE4KB0X8Y2Z3A4B5C6D7E8F9", "status": "completed", "mode": "async", "file_name": "annual-report.pdf", "pages": { "total": 48, "done": 48, "failed": 0 }, "credits": 61, "result_url": "https://api.deskew.dev/v1/jobs/job_01JE4KB0X8Y2Z3A4B5C6D7E8F9/result", "error": null }}The payload never contains the extracted content. Fetch result_url with your API key.
Request headers:
| Header | Value |
|---|---|
Content-Type |
application/json |
User-Agent |
deskew-webhooks/1.0 |
Deskew-Signature |
t=<unix seconds>,v1=<hex HMAC-SHA256> |
X-Delivery-Id |
whd_…, unique per delivery attempt chain; use it to deduplicate |
X-Event-Type |
Same as type |
Verify the signature
Section titled “Verify the signature”The signature is HMAC-SHA256 of the string "{t}.{body}" where t is the timestamp from the header and body is the raw request body bytes, keyed with the endpoint secret. Reject deliveries whose timestamp is more than 5 minutes old. Compare in constant time.
import hmac, hashlib, time
def verify_deskew_signature(secret: str, header: str, body: bytes, tolerance: int = 300) -> bool: try: parts = dict(p.split("=", 1) for p in header.split(",")) ts = int(parts["t"]) sig = parts["v1"] except (ValueError, KeyError): return False if abs(time.time() - ts) > tolerance: return False expected = hmac.new(secret.encode(), f"{ts}.".encode() + body, hashlib.sha256).hexdigest() return hmac.compare_digest(expected, sig)
# Flask examplefrom flask import Flask, request, abort
app = Flask(__name__)SECRET = os.environ["DESKEW_WEBHOOK_SECRET"]
@app.post("/webhooks/deskew")def deskew_webhook(): if not verify_deskew_signature(SECRET, request.headers.get("Deskew-Signature", ""), request.get_data()): abort(400) event = request.get_json() if event["type"] == "job.completed": enqueue_download(event["data"]["result_url"]) # your code return "", 204import { createHmac, timingSafeEqual } from "node:crypto";import express from "express";
export function verifyDeskewSignature(secret, header, body, toleranceSeconds = 300) { const parts = Object.fromEntries( header.split(",").map((p) => { const i = p.indexOf("="); return [p.slice(0, i), p.slice(i + 1)]; }) ); const ts = Number(parts.t); if (!Number.isFinite(ts) || !parts.v1) return false; if (Math.abs(Date.now() / 1000 - ts) > toleranceSeconds) return false; const expected = createHmac("sha256", secret).update(`${ts}.`).update(body).digest("hex"); const a = Buffer.from(expected, "hex"); const b = Buffer.from(parts.v1, "hex"); return a.length === b.length && timingSafeEqual(a, b);}
const app = express();
// Keep the raw body: JSON middleware would re-serialise it and break the signature.app.post("/webhooks/deskew", express.raw({ type: "application/json" }), (req, res) => { const ok = verifyDeskewSignature( process.env.DESKEW_WEBHOOK_SECRET, req.get("Deskew-Signature") ?? "", req.body ); if (!ok) return res.status(400).end(); const event = JSON.parse(req.body.toString("utf8")); if (event.type === "job.completed") { enqueueDownload(event.data.result_url); // your code } res.status(204).end();});Respond quickly
Section titled “Respond quickly”Return any 2xx within 10 seconds. Anything else, including a timeout or a redirect (redirects are not followed), counts as a failure. Do the real work after you have responded.
Retries
Section titled “Retries”A failed delivery is retried with increasing delays, up to 8 attempts spread over roughly 24 hours:
| Attempt | Wait before it |
|---|---|
| 2 | 30 s |
| 3 | 2 min |
| 4 | 10 min |
| 5 | 30 min |
| 6 | 1 h |
| 7 | 4 h |
| 8 | 6 h |
(An 8-hour step exists after that in the schedule but is never reached with the default of 8 attempts.) Every attempt carries the same X-Delivery-Id, so you can safely ignore a repeat you have already processed. Events may also arrive out of order; use data.status rather than the arrival order.
Auto-disable
Section titled “Auto-disable”Each endpoint tracks when its current failure streak started. If deliveries keep failing for more than 3 days, the endpoint is set inactive, disabled_at is recorded and it stops receiving events. A single successful delivery resets the streak. Re-enable the endpoint from the dashboard once your receiver is healthy.
Redeliver
Section titled “Redeliver”Any delivery can be sent again from the dashboard (Redeliver on the delivery row). The replay carries the original event body with a fresh signature and timestamp, gets a new X-Delivery-Id, and is attempted once without the retry schedule.
Checklist
Section titled “Checklist”- Verify
Deskew-Signatureon every request and reject anything older than 5 minutes. - Return
2xxin under 10 seconds; process asynchronously. - Deduplicate on
X-Delivery-Idorid. - Fetch
result_urlwithin 24 hours; results expire. - Keep separate endpoints for test and live.