A webhook makes Trawl call your URL each time a scrap run ends, so your code gets the result without asking for it.
Creating or changing a webhook needs Growth or Pro, or a Shops client organization; otherwise the answer is 403 PLAN_REQUIRED. Listing and deleting work on every plan.
Create a webhook
In the web app, open Developers → Webhooks, click Create, enter a public HTTPS URL and pick the events. Copy the secret at once: it is shown only once, and you need it to check each call.
Over the API, webhooks are managed from your logged-in session (the TOKEN cookie of the web app), never with an API key. Owners and admins manage every webhook of the organization; a member manages the ones they created.
The answer: plainSecret is the signing secret, shown this once.
| Field | What it is | Where the value comes from |
|---|---|---|
url |
Where Trawl sends the calls. A public HTTPS address; a private or internal one is refused. | Your server, or an n8n production webhook URL |
events |
One or more of the events below | The table below |
scrapIds (optional) |
Only runs of these scraps send a call. Empty or left out: every scrap. | The id of each scrap, from GET /api/scraps |
| Event | Sent when |
|---|---|
scrap.success |
A scrap run succeeds |
scrap.failure |
A scrap run fails |
shops.check.done |
Shops clients: a check of the catalog finished (see Shops guide) |
curl -X POST https://api.trawl.me/api/developers/webhooks \
-H "Cookie: TOKEN=<YOUR_SESSION_TOKEN>" \
-H "Content-Type: application/json" \
-d '{ "url": "https://example.com/trawl-hook", "events": ["scrap.success", "scrap.failure"] }'{ "type": "success", "message": "webhook created",
"data": { "id": "6650b2c3d4e5f6a7b8c9d0e1", "url": "https://example.com/trawl-hook", "events": ["scrap.success", "scrap.failure"],
"active": true, "scrapIds": [], "plainSecret": "9f2c…" } }Scoping webhooks to specific scraps
PUT changes a webhook. Send only the fields to change: url, events, scrapIds or active (false pauses it). scrapIds replaces the list; [] makes the webhook fire for every scrap again. The webhook id is the id of the create answer, or of GET /api/developers/webhooks.
The answer:
curl -X PUT https://api.trawl.me/api/developers/webhooks/<WEBHOOK_ID> \
-H "Cookie: TOKEN=<YOUR_SESSION_TOKEN>" \
-H "Content-Type: application/json" \
-d '{ "scrapIds": ["64a1f2e3b5c6d7e8f9a0b1c2"] }'{ "type": "success", "message": "webhook updated",
"data": { "id": "6650b2c3d4e5f6a7b8c9d0e1", "url": "https://example.com/trawl-hook", "active": true, "scrapIds": ["64a1f2e3b5c6d7e8f9a0b1c2"] } }curl -X DELETE https://api.trawl.me/api/developers/webhooks/<WEBHOOK_ID> \
-H "Cookie: TOKEN=<YOUR_SESSION_TOKEN>"{ "type": "success", "message": "webhook deleted", "data": { "acknowledged": true, "deletedCount": 1 } }Payload
Each run sends a POST with this JSON body. The X-Webhook-Event header names the event (scrap.success or scrap.failure); X-Webhook-Signature signs the body.
| Field | What it is |
|---|---|
runId |
The run. Same value as historyId, its old name; both are sent. |
scrapId |
The scrap that ran |
status |
"success" or "failure", like the event name. Not the true/false status of a run row. |
statusDetail |
"success", "empty" (no rows), "error" or "regression" (fewer rows than usual), or null. Use it to skip empty runs or alert on errors only. |
timestamp |
When the call was sent (ISO 8601) |
runtime |
How long the run took, in ms, or null |
resultPreview |
The first 1024 characters of the rows as JSON text, with a trailing … when cut; null when the run returned nothing. Secrets found in it are masked. |
triggeredBy |
"user", "api" or "cron" |
To get all the rows, call GET /api/runs/<runId> with an API key (trawl:history:read): they are in JSON.parse(data.data).data. The test button of the web app sends { "event": "ping", "timestamp": "…", "webhookId": "…" }, with no runId. A shops.check.done call has its own body, described here; only webhooks with no scrapIds receive it.
{
"historyId": "64a1f2e3b5c6d7e8f9a0b1c2",
"runId": "64a1f2e3b5c6d7e8f9a0b1c2",
"scrapId": "64a1f2e3b5c6d7e8f9a0b1c3",
"status": "success",
"statusDetail": "success",
"timestamp": "2026-04-17T10:30:00.000Z",
"runtime": 2384,
"resultPreview": "[{\"title\":\"Example item\",\"price\":\"19.90€\"}]",
"triggeredBy": "cron"
}import crypto from 'crypto';
function verifySignature(rawBody, signature, secret) {
const expected = crypto.createHmac('sha256', secret).update(rawBody).digest('hex');
if (typeof signature !== 'string') return false;
const a = Buffer.from(signature);
const b = Buffer.from(expected);
// timingSafeEqual throws when the byte lengths differ: reject first
if (a.length !== b.length) return false;
return crypto.timingSafeEqual(a, b);
}
// Express: keep the raw body
app.post('/webhook', express.raw({ type: 'application/json' }), (req, res) => {
if (!verifySignature(req.body, req.headers['x-webhook-signature'], process.env.WEBHOOK_SECRET)) {
return res.status(401).send('Invalid signature');
}
res.sendStatus(200); // answer first, then work on JSON.parse(req.body)
});Verify in n8n
Hash the raw body first, parse it after: parsed and written back, the JSON may change and the signature no longer matches. The nodes, in order (tested on self-hosted n8n 2.44.5):
- Webhook: Method
POST, RespondUsing 'Respond to Webhook' Node, Options → Raw Body on. The body arrives as the binary filedata. - Extract from File:
Extract From Text File, Input Binary Fielddata, Destination Output Fieldraw, Options → Keep SourceBoth. - Crypto: Action
Hmac, Binary File on (Propertydata), TypeSHA256, Property Nameexpected, EncodingHEX. Put the webhook secret in a Crypto credential, field Hmac Secret. - If:
{{ $json.expected }}is equal to{{ $json.headers['x-webhook-signature'] }}. - Respond to Webhook:
200on true,401on false, before any slow work. - Edit Fields:
payload={{ JSON.parse($json.raw) }}. Skip a test ping with an If on{{ $json.payload.runId }}exists.
Use the workflow's production URL (/webhook/..., workflow active), not the editor's test URL. Check the gate from a terminal:
BODY='{"historyId":"demo","status":"success"}'
SIG=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "$WEBHOOK_SECRET" -hex | sed 's/^.* //')
curl -s -o /dev/null -w '%{http_code}\n' -X POST https://n8n.example.com/webhook/trawl \
-H 'Content-Type: application/json' -H "X-Webhook-Signature: $SIG" -d "$BODY" # 200
# same call with a changed body, another signature or no header → 401Retry policy
Trawl waits 10 seconds for a 2xx answer. Otherwise it tries again: three tries in all, at once, then 1 minute later, then 5 minutes after that. A paused webhook gets no more tries. Every try and its status code are in the webhook's Deliveries, opened from Developers → Webhooks.
See also: API Keys · Scrap Payload · Notifications
Next step → CLI