Webhooks
Get a signed callback the moment a batch finishes — instead of polling for it.
When you submit a batch with a callback_url, the API POSTs a signed
notification to it the moment the batch reaches a terminal status. That
replaces polling: your server reacts to completion instead of asking
for it.
Store the secret when you submit
The webhook_secret needed to verify signatures is returned once,
in the submit response. If you lose it, the batch's callbacks cannot
be verified — you would have to treat the payload's summary as
advisory and re-fetch results by batch id.
Receiving a delivery
Add callback_url to the submit body — HTTPS only:
curl "https://api.dataloom.dev/mavion-seo-insights/v2/analysis" \
-X POST \
-H "Authorization: Bearer $DATALOOM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"urls": ["stripe.com", "github.com"],
"callback_url": "https://api.yourapp.com/hooks/mavion"
}'The submit response carries the batch object plus a webhook_secret:
{
"id": "batch_9f2ce1a4d7b84c0eaf3122ee5a6d9c77",
"status": "queued",
"webhook_secret": "b3f1c9a2e8d74f06a1c25e9b0d3f87aa"
}When the batch finishes (completed, partial, failed, or
cancelled), your endpoint receives a POST with these headers:
| Header | Description |
|---|---|
X-Mavion-Batch-Id | The batch id — route on this if you handle several batches. |
X-Mavion-Timestamp | Unix seconds when the delivery was signed. |
X-Mavion-Signature | sha256= followed by the hex HMAC-SHA256 signature. |
The body is the batch object plus results:
{
"id": "batch_9f2ce1a4d7b84c0eaf3122ee5a6d9c77",
"object": "batch",
"status": "completed",
"dataset": "all-insights",
"created_at": "2026-10-27T12:00:00.000000+00:00",
"completed_at": "2026-10-27T12:31:14.000000+00:00",
"expires_at": "2026-11-03T12:31:14.000000+00:00",
"summary": { "submitted": 2, "unique": 2, "duplicates": 0, "failed": 0, "pending": 0 },
"results": [
{ "url": "stripe.com", "index": 0, "duplicate_indexes": [], "attempts": 1, "status": "success", "data": {}, "error": null },
{ "url": "github.com", "index": 1, "duplicate_indexes": [], "attempts": 1, "status": "success", "data": {}, "error": null }
]
}Batches of up to 200 items carry all result rows inline in
results. Larger batches set results_omitted: true and include a
results_url pointing at the results endpoint — page through it as
usual (see batch analysis).
Respond with any 2xx status as soon as you have durably queued the
work — do heavy processing after replying.
Verifying the signature
The signature is HMAC-SHA256 over "{timestamp}.{raw_body}", keyed
with your webhook_secret. Verify it before trusting a payload:
import hmac, hashlib, time
def verify(secret: str, timestamp: str, raw_body: bytes, signature: str) -> bool:
# Reject stale deliveries: a captured payload stops working after 5 min.
if abs(time.time() - int(timestamp)) > 300:
return False
expected = hmac.new(
secret.encode(),
timestamp.encode() + b"." + raw_body,
hashlib.sha256,
).hexdigest()
return hmac.compare_digest(signature, f"sha256={expected}")import { createHmac, timingSafeEqual } from "node:crypto";
function verify(secret, timestamp, rawBody, signature) {
if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;
const expected =
"sha256=" +
createHmac("sha256", secret)
.update(`${timestamp}.${rawBody}`)
.digest("hex");
const a = Buffer.from(expected);
const b = Buffer.from(signature);
return a.length === b.length && timingSafeEqual(a, b);
}Three details matter:
- Sign the raw request body — the exact bytes received, before any JSON parse/re-serialize.
- Compare in constant time (
hmac.compare_digest/timingSafeEqual), never==. - Reject deliveries whose
X-Mavion-Timestampis older than a few minutes — that is what makes captured payloads unreplayable.
Retries
If your endpoint does not answer 2xx within 15 seconds, or the
connection fails, the delivery is retried up to 5 times with a
growing wait between attempts (about 30 s, then 60 s, 90 s, 120 s).
Failed deliveries do not block anything else — the batch's results stay retrievable either way, so your worst case is switching from webhook to polling for that batch id.
Monitoring deliveries
The status endpoint reports where the callback stands for batches that have one:
{
"id": "batch_9f2ce1a4d7b84c0eaf3122ee5a6d9c77",
"status": "completed",
"webhook": { "status": "delivered", "attempts": 1, "last_status": "200" }
}webhook.status | Meaning |
|---|---|
pending | Batch not finished yet (or finishing right now). |
delivered | Your endpoint accepted a delivery with a 2xx. |
failed | All 5 attempts exhausted — check your endpoint's availability. |
Security rules
These are enforced at submit time:
callback_urlmust be a plain HTTPS URL — no other scheme, no embedded username/password.- Hosts that resolve to private, loopback, or link-local addresses are rejected. This keeps a caller from pointing callbacks at our internal network.
- A hostname that does not resolve is accepted at submit (DNS can be
transient) — but delivery will fail its retries if it never resolves,
which the
webhook.statusabove will show.
One callback per batch
A batch delivers exactly one webhook — at its final state. Partial progress is reported only through the status/results endpoints.
Dataloom Docs