DocumentationBuild

Webhooks

Have events pushed to your HTTPS endpoint as they happen, and check each request's signature.

A webhook pushes those same events to your HTTPS endpoint as they happen, so you don't have to poll. An administrator signed in to Pleaxy adds an endpoint, up to 5 per workspace side, and chooses its event types; an API key can't. The endpoint's signing secret is shown once. Each event is POSTed as JSON with the path of the call that reads its document, never the document itself.

Every request carries a Pleaxy-Signature header, t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<body>">, made with the endpoint's secret. Refuse a request whose signature doesn't match or that is more than 5 minutes old:

verify-webhook.ts
import { createHmac, timingSafeEqual } from "node:crypto";

// rawBody is the request body exactly as it arrived, before any JSON parsing.
export function isFromPleaxy(signature: string, rawBody: string, secret: string): boolean {
  const parts = Object.fromEntries(signature.split(",").map((part) => part.split("=")));
  const sentAt = Number(parts.t);
  if (!sentAt || Math.abs(Date.now() / 1000 - sentAt) > 300) return false; // more than 5 minutes old
  const expected = createHmac("sha256", secret).update(`${parts.t}.${rawBody}`).digest();
  const given = Buffer.from(parts.v1 ?? "", "hex");
  return given.length === expected.length && timingSafeEqual(given, expected);
}

Answer with a 2xx within 10 seconds. Anything else is retried after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours, 12 hours and 24 hours, then given up. An endpoint is an https:// address on a host name; deliveries never reach a private network and never follow a redirect. The endpoints and their delivery log are in the Webhooks reference.

Talk to us