Skip to content
Developers

Webhooks and chat channels

Send your organization's notifications to Slack, Google Chat, Discord, Telegram or your own HTTPS endpoint, and verify every webhook request.

Base URLhttps://makani-gke-eu.lamah.com

Connect a channel

In the console, open Integrations and choose a service. Pick which notification types the channel receives and the language it is written in. A webhook channel shows its signing secret once, right after you connect it: store it with your server's secrets.

What a webhook request carries

Each notification is a POST with a JSON body. Three headers come with it:

  • x-makani-event: the notification type, such as usage.alert.
  • x-makani-delivery: a unique id for this delivery. Use it to ignore a request you already handled.
  • x-makani-signature: t=<unix seconds>,v1=<signature>.

Verify the signature

The signature is the hex HMAC-SHA256 of the timestamp, a dot and the raw request body, keyed with the signing secret. To check a request:

  • Read t and v1 from x-makani-signature.
  • Compute HMAC-SHA256 of <t>.<raw body> with your secret, as hex.
  • Compare it with v1 in constant time, and refuse a t more than a few minutes old.
import { createHmac, timingSafeEqual } from "node:crypto" // Read the raw body: verify the bytes exactly as they arrived.export function verifyMakaniSignature(rawBody, header, secret) {  const parts = Object.fromEntries(    header.split(",").map((part) => part.trim().split("="))  )  const t = Number(parts.t)  if (!t || !parts.v1) return false  // Refuse requests older than five minutes (replays).  if (Math.abs(Date.now() / 1000 - t) > 300) return false  const expected = createHmac("sha256", secret)    .update(`${t}.${rawBody}`)    .digest("hex")  const a = Buffer.from(expected, "hex")  const b = Buffer.from(parts.v1, "hex")  return a.length === b.length && timingSafeEqual(a, b)}

Answer 2xx quickly once a request is verified, and do the work afterwards.

Testing and failures

Send test in the console posts a sample message and shows whether it arrived. A channel that fails shows the last error beside it; turn it off or fix the address and test again.