Skip to content

GuidesEvents and webhooks

Receive webhooks

Get each event at your own https address as it happens, check that it came from Kontiga, answer fast, and try it all with the test inbox before you deploy. The compatible document webhooks are checked with Kontiga’s public key.

Updated

Ask about this pageRead this page as Markdown

Add an endpoint

An endpoint is an https address of yours on a public host, for Kontiga’s own events or for the compatible document events, live or test. Its signing secret is in the answer once: store it with your other secrets.

curl -X POST https://api.kontiga.com/v1/webhook_endpoints \
  -H "Authorization: Bearer $KONTIGA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://claims.example.com/kontiga/events",
    "events": [
      "document.checked",
      "document.failed"
    ],
    "mode": "test"
  }'

POST /v1/webhook_endpoints

What arrives

A POST with a JSON body: {id, type, created_at, workspace, mode, data: {object}}, where data.object is the object as the API answers it at that moment. The headers are Content-Type: application/json, User-Agent: Kontiga-Webhooks/1.0, Kontiga-Event-Id (the event’s id) and Kontiga-Signature.

A delivery
POST /kontiga/events HTTP/1.1
Content-Type: application/json
User-Agent: Kontiga-Webhooks/1.0
Kontiga-Event-Id: evt_0193c1a2d0017a2b8c3d4e5f60718293
Kontiga-Signature: t=1764150522,v1=6b1e0c...

{"id":"evt_0193c1a2d0017a2b8c3d4e5f60718293","type":"document.checked","created_at":"2026-11-26T09:48:42.118Z","workspace":"ws_0193c1a2b3c44d5e8f9a0b1c2d3e4f50","mode":"test","data":{"object":{"id":"doc_0193c1a2d0017a2b8c3d4e5f60718294","object":"document","verdict":"review"}}}

Verify the signature

Kontiga-Signature is t=<unix seconds>,v1=<hex>, where the hex is the HMAC-SHA256 of <t>.<raw body> keyed with the endpoint’s secret. Check that t is within five minutes of your clock and that one v1 matches, comparing in constant time. During a secret’s roll a delivery carries one v1 for each secret still valid, so either one verifies.

import crypto from "node:crypto";

// Verify a Kontiga webhook: the raw body (bytes, before any JSON parsing),
// the Kontiga-Signature header, and your endpoint's signing secret.
export function verifyKontiga(rawBody, header, secret, toleranceSeconds = 300) {
  const parts = header.split(",").map((p) => p.trim());
  const t = Number(parts.find((p) => p.startsWith("t="))?.slice(2));
  const signatures = parts.filter((p) => p.startsWith("v1=")).map((p) => p.slice(3));
  if (!Number.isFinite(t) || signatures.length === 0) return false;
  if (Math.abs(Date.now() / 1000 - t) > toleranceSeconds) return false;
  const expected = crypto.createHmac("sha256", secret).update(`${t}.`).update(rawBody).digest();
  return signatures.some((s) => {
    const given = Buffer.from(s, "hex");
    return given.length === expected.length && crypto.timingSafeEqual(given, expected);
  });
}
In a server
import express from "express";
import { verifyKontiga } from "./verify.js";

const app = express();

// Keep the raw bytes: the signature is over them, not over parsed JSON.
app.post("/kontiga/events", express.raw({ type: "application/json" }), (req, res) => {
  if (!verifyKontiga(req.body, req.get("Kontiga-Signature") ?? "", process.env.KONTIGA_WEBHOOK_SECRET)) {
    return res.status(400).send("bad signature");
  }
  const event = JSON.parse(req.body.toString("utf8"));
  // Answer at once; do the work after. An event can arrive twice: keep its id.
  res.sendStatus(200);
  queueWork(event);
});

Answer fast, and once

  • Answer with a 2xx within 10 seconds, then do the work. A redirect is not followed and counts as a failure.
  • An event can arrive more than once. Keep the ids you have handled (id, the same as Kontiga-Event-Id) and skip a repeat.
  • Events of different objects can arrive out of order. When the order matters, read the object again with the API.

Retries and when an endpoint is turned off

  • A failed delivery is tried again with waits that double from 1 minute, at most 6 hours apart, for 72 hours. A Retry-After header longer than the wait is honoured.
  • A 410 Gone turns a Kontiga endpoint off at once.
  • After 72 hours of failures with no success, an endpoint is turned off and its workspace’s owners, admins and developers get one email.
  • Once fixed, enable it again and send what failed again with one call:
curl -X POST https://api.kontiga.com/v1/webhook_endpoints/whe_0193c1a2d0017a2b8c3d4e5f60718291/recover \
  -H "Authorization: Bearer $KONTIGA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "since": "2026-11-24"
  }'

POST /v1/webhook_endpoints/{endpoint_id}/recover

Try it with the test inbox

Every workspace has a test inbox: an address on Kontiga’s host that keeps the last 100 requests of 7 days, each with whether its signature verifies. Send a sample of any event to your endpoint or to the inbox; it is a real signed request, logged as a test send.

curl -X POST https://api.kontiga.com/v1/webhook_endpoints/whe_0193c1a2d0017a2b8c3d4e5f60718291/test \
  -H "Authorization: Bearer $KONTIGA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "document.checked",
    "target": "inbox"
  }'

POST /v1/webhook_endpoints/{endpoint_id}/test

curl -X GET https://api.kontiga.com/v1/webhook_inbox \
  -H "Authorization: Bearer $KONTIGA_API_KEY"

GET /v1/webhook_inbox

Roll a secret

Give an endpoint a new secret, shown once. The old one keeps verifying for the overlap you choose, none to 7 days, so you can deploy the new one without missing an event.

curl -X POST https://api.kontiga.com/v1/webhook_endpoints/whe_0193c1a2d0017a2b8c3d4e5f60718291/roll_secret \
  -H "Authorization: Bearer $KONTIGA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "overlap": "24h"
  }'

POST /v1/webhook_endpoints/{endpoint_id}/roll_secret

Compatible document webhooks

An endpoint in the compatible format gets document.analyzed, document.rejected and document.monitoring_event exactly as Bynn sends them: the same body with its jwt, the same headers and X-Bynn-Signature, the same retries. A new compatible endpoint takes all three. Verify a delivery with Kontiga’s RSA public key, read with no credential:

curl -X GET https://api.kontiga.com/v1/webhooks/public_key

GET /v1/webhooks/public_key

Verify X-Bynn-Signature
import crypto from "node:crypto";

// A compatible document webhook: X-Bynn-Signature is a JWT (RS256) whose
// sha256 claim is the hex SHA-256 of the raw body. Fetch the public key from
// GET /compat/v1/webhooks/public_key (or /v1/webhooks/public_key) and cache it.
export function verifyCompatible(rawBody, signatureHeader, publicKeyPem) {
  const [header, claims, signature] = signatureHeader.split(".");
  if (!header || !claims || !signature) return false;
  const ok = crypto.verify(
    "RSA-SHA256",
    Buffer.from(`${header}.${claims}`),
    publicKeyPem,
    Buffer.from(signature, "base64url"),
  );
  if (!ok) return false;
  const { sha256, exp } = JSON.parse(Buffer.from(claims, "base64url").toString("utf8"));
  const digest = crypto.createHash("sha256").update(rawBody).digest("hex");
  return sha256 === digest && exp * 1000 > Date.now();
}

A client that already verifies Bynn’s webhooks keeps its code: fetch the key from Kontiga’s base URL once, as it fetched Bynn’s. The body’s jwt verifies with the same key, and its data claim is the body without jwt.