Sidelatch Docs
Docs menu

View as Markdown

Webhooks

An event is recorded for everything that happens to a connection, a sign-in or an async run, whether or not you have a webhook. List them for 30 days. Set webhook_url in settings and each one is also POSTed to you. Events carry ids and statuses only, never portal data or credentials.

The event types and their data are listed on Events.

Event body{
  "id": "evt_1f0c...",
  "type": "connection.reconnect_needed",
  "created": 1795700000,
  "data": {
    "connection_id": "conn_8f2c41d07a9b4e6f",
    "user_id": "agency-42",
    "portal": "demo_carrier",
    "status": "reconnect_needed",
    "reason": "wrong_password"
  }
}

Delivery

Answer with any 2xx within 10 seconds. A delivery that fails is tried again after 5 seconds, 30 seconds and 2 minutes, then after 10 minutes, 1 hour, 6 hours and 16 hours: about a day in all. Pending deliveries are kept in our database, so a restart on our side does not lose one. A 4xx other than 408 or 429 is not retried. Delivery is at least once: use the event id (also in the Sidelatch-Event-Id header) to ignore a repeat. List deliveries or send an event again, here or in the console.

Verify the signature

Every request has a Sidelatch-Signature: t=<unix time>,v1=<hex> header: an HMAC-SHA256 of "<t>.<raw body>" keyed with your webhook secret. Reject anything older than five minutes.

Pythonimport hashlib, hmac, time

def verify(secret: str, header: str, body: bytes) -> bool:
    """header is the Sidelatch-Signature value; body is the raw request body."""
    parts = dict(p.split("=", 1) for p in header.split(","))
    if abs(time.time() - int(parts["t"])) > 300:
        return False
    expected = hmac.new(secret.encode(), f"{parts['t']}.".encode() + body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, parts["v1"])
Node.jsimport crypto from "node:crypto";

export function verify(secret, header, rawBody) {
  const parts = Object.fromEntries(header.split(",").map((p) => p.split("=")));
  if (Math.abs(Date.now() / 1000 - Number(parts.t)) > 300) return false;
  const expected = crypto.createHmac("sha256", secret).update(`${parts.t}.${rawBody}`).digest("hex");
  return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1));
}