Piloterr
Destinations

Webhook

Receive signed events on your own HTTPS endpoint and verify their signature with Standard Webhooks.

A webhook destination is a URL of yours that receives Dataflow's events as signed JSON POST requests. Deliveries follow the Standard Webhooks specification: each one is signed, retried when it fails, and logged. To send a short message to people instead, use alerts.

Prepare your endpoint

  1. Expose an https URL reachable from the internet, on port 443 (or 80, 8080, 8443 or 9000). localhost, .internal names, private addresses and names that resolve to one are refused when you save. Other ports are not refused then, but deliveries to them fail.
  2. If your firewall filters incoming traffic, allow the webhook's address, 116.203.84.164, which GET /v1/destinations/types also gives (exit_ips). See Where deliveries come from.
  3. Answer 2xx within 10 seconds, and do the work afterwards. Anything else, or no answer, is retried.

Add the destination

curl https://dataflow.piloterr.com/v1/destinations \
  -H "x-api-key: YOUR_API_KEY" -H "content-type: application/json" \
  -d '{"type": "webhook", "config": {"url": "https://example.com/webhooks/piloterr"}, "topics": ["run.completed", "run.failed"], "description": "Data warehouse"}'
{
  "id": "DESTINATION_ID",
  "type": "webhook",
  "target": "https://example.com/…terr",
  "config": { "url": "https://example.com/…terr" },
  "credentials": {},
  "topics": ["run.completed", "run.failed"],
  "description": "Data warehouse",
  "disabled_at": null,
  "created_at": "2026-12-01T08:00:00.000Z",
  "secret": "whsec_…"
}
FieldRequiredHolds
config.urlyesYour endpoint, https, up to 2,000 characters.

The URL is never shown again whole: answers and the dashboard show its origin and the last 4 characters of its path (https://example.com/…terr), since a webhook's path or query is often its secret. Sending that masked URL back with PATCH keeps the stored one; send the full URL to change it.

A webhook has no credentials. Its signing secret is created with it: keep it to verify signatures. GET /v1/destinations/{id} shows it again, and so does the destination in the dashboard. To change it, rotate it.

What your endpoint receives

A POST with content-type: application/json, the event payload as body, and these headers:

HeaderHolds
webhook-idThe event id, the payload's id. A resend keeps it: deduplicate on it.
webhook-timestampWhen it was sent, in Unix seconds.
webhook-signaturev1, then the base64 HMAC-SHA256 of {id}.{timestamp}.{body}, keyed with the secret.
webhook-topicThe topic, such as run.completed.

Verify the signature

Verify the signature on the raw body, before parsing it, and refuse old timestamps. A Standard Webhooks library does both:

// npm install standardwebhooks express
import express from "express"
import { Webhook } from "standardwebhooks"

const wh = new Webhook(process.env.PILOTERR_WEBHOOK_SECRET) // "whsec_…"
const app = express()

app.post("/webhooks/piloterr", express.raw({ type: "application/json" }), (req, res) => {
  let event
  try {
    // Throws when the signature is wrong or the timestamp is more than 5 minutes off.
    event = wh.verify(req.body.toString("utf8"), req.headers)
  } catch {
    return res.status(400).end()
  }
  if (event.type === "run.completed") console.log(event.run.ok, event.data.export.url)
  res.status(204).end()
})

app.listen(3000)

Without a library: decode the part of the secret after whsec_ from base64, compute the HMAC-SHA256 of {webhook-id}.{webhook-timestamp}.{raw body} with it, base64-encode the result, and compare it in constant time with each v1, value of webhook-signature (there can be several, separated by spaces). Refuse a webhook-timestamp more than 5 minutes from your clock.

Refuse replays and duplicates

The signature covers webhook-id and webhook-timestamp, so neither can be changed without breaking it. Two checks then stop a delivery captured on the way (a proxy log, a forwarded request) from being played again:

  1. The timestamp: refuse a webhook-timestamp more than 5 minutes from your clock (the Standard Webhooks libraries do it). A captured request is useless after that.
  2. The id: keep the webhook-id of what you processed for at least those 5 minutes, and answer 2xx without processing it again when it comes back. Deliveries are at least once: a retry, or a resend from the delivery log, carries the same id and a new timestamp and signature, so this also makes retries safe.
// After wh.verify(…) succeeded: process each event once.
const fresh = await redis.set(`piloterr:${req.headers["webhook-id"]}`, "1", { NX: true, EX: 86400 })
if (!fresh) return res.status(204).end()

Rotate the secret

Rotate the signing secret from the dashboard (the destination's menu, Rotate the signing secret), or with the API:

curl -X POST https://dataflow.piloterr.com/v1/destinations/DESTINATION_ID/rotate-secret \
  -H "x-api-key: YOUR_API_KEY" -H "content-type: application/json" \
  -d '{"previous_secret_expires_in_hours": 24}'
{
  "id": "DESTINATION_ID",
  "type": "webhook",
  "target": "https://example.com/webhooks/piloterr",
  "config": { "url": "https://example.com/webhooks/piloterr" },
  "credentials": {},
  "topics": ["run.completed", "run.failed"],
  "description": "Data warehouse",
  "disabled_at": null,
  "created_at": "2026-12-01T08:00:00.000Z",
  "secret": "whsec_…",
  "previous_secret_expires_at": "2026-12-02T08:00:00.000Z"
}

The answer holds the new secret. The destination keeps its URL, topics and delivery log. Until previous_secret_expires_at (24 hours by default, up to 168), each delivery is signed with both secrets: webhook-signature then holds two values, v1,<new> v1,<previous>. Move your endpoint to the new secret within that window; a library verifying with either secret accepts the delivery, so nothing is missed.

If the secret leaked, send "previous_secret_expires_in_hours": 0 (in the dashboard, Replace the secret now): the previous secret stops signing at once, and your endpoint refuses deliveries until it verifies them with the new one. Only a webhook has a signing secret (422 not_a_webhook for the other types).

Test it

Send a test event from the dashboard, or POST /v1/destinations/{id}/test (details). The delivery log's code is the HTTP status your endpoint answered.

ProblemFix
422 validation_failed on config.urlUse an https URL whose host resolves to a public address.
code is 400 or 401Your signature check failed: use the raw body and this destination's secret.
code is timeoutAnswer within 10 seconds, and move slow work to the background.
code is connection_refused or dns_errorCheck that the host is public and that your firewall allows the webhook's address.

Other errors: Errors.

On this page