Black Friday tra 20 giorni: i Suoi clienti potranno pagare? -25 % il 1° anno e configurazione offerta, fino al 30 novembreVedi l’offerta →

Integrazione

Webhook in uscita firmati HMAC

Eventi run.failed / run.recovered, intestazioni X-Pathly-* e verifica della firma.

Ottenere la mia chiave APIContratto OpenAPI

Documento completo, senza autenticazione, da passare al Suo generatore di client.

Webhook in uscita

Eventi supportati: run.failed, run.recovered, incident.opened, incident.resolved (questi due anche in abbonamento, POST /v1/hooks, per Zapier o Make). Intestazioni: X-Pathly-Id, X-Pathly-Event, X-Pathly-Timestamp, X-Pathly-Signature (HMAC-SHA256 di `${timestamp}.${rawBody}`, prefisso sha256=). L’URL resta cifrato a riposo; la lettura espone un’impronta.

Verifichi la firma in tempo costante (timingSafeEqual). Rifiuti i timestamp troppo vecchi (replay). Risponda 2xx rapidamente, poi elabori in coda.

Creare

curl -X POST https://api.pathlyhq.com/v1/webhooks \
  -H "Authorization: Bearer $PATHLY_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://www.example.com/hooks/pathly",
    "events": ["run.failed", "run.recovered"]
  }'

Node — verificare la firma

import { createHmac, timingSafeEqual } from "node:crypto";

function verify(secret, timestamp, rawBody, signature) {
  const expected =
    "sha256=" +
    createHmac("sha256", secret)
      .update(`${timestamp}.${rawBody}`)
      .digest("hex");
  const a = Buffer.from(signature);
  const b = Buffer.from(expected);
  return a.length === b.length && timingSafeEqual(a, b);
}

Python — verificare la firma

import hashlib, hmac

def verify(secret: str, timestamp: str, raw_body: bytes, signature: str) -> bool:
    digest = hmac.new(
        secret.encode(), f"{timestamp}.".encode() + raw_body, hashlib.sha256
    ).hexdigest()
    expected = f"sha256={digest}"
    return hmac.compare_digest(expected, signature)