kennraDocs

Webhooks

Kennra records every change as an event, for example when a deal moves stage or a person withdraws consent. You get those events in three ways, all filtered by the same rules and with the same event types and filters:

WayForSet up
Workspace endpointsYour own system: an ERP, a data warehouse, an automation toolSettings → Webhooks, kennra webhooks create, or a blueprint
App subscriptionsAn app you build for many workspacesThe app's manifest, approved at install
The event streamA process that reads events itself: no public URL neededGET /events, GET /events/stream, the SDKs, kennra events --follow

Webhooks are delivered at least once, signed, retried with backoff and logged. The stream and the feed are read in commit order with a cursor you can resume.

Workspace endpoints

A workspace endpoint sends the events you pick to a URL of your own. An admin (the kennra:apps:manage scope) adds one under Settings → Webhooks → Add endpoint, with the CLI, or with GraphQL:

kennra webhooks create --name "Won deals to ERP" --url https://erp.example.com/kennra \
  --events 'kennra.deal.stage_changed' --deal-stage won --purposes sales.b2b --amounts
Endpoint   Won deals to ERP  wep_3f9c2a7b1e4d8f6a0c5b9e2d7a
Signing secret  whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw
Copy it now: Kennra can't show it again. Verify each delivery with it (Standard Webhooks).

An endpoint has:

  • A name and an https URL. Kennra checks on every attempt that the address is public, and does not follow redirects.
  • Event types, as types or patterns (kennra.deal.*). The picker groups them by area.
  • Filters, so the endpoint gets only the events you care about.
  • Access: purposes, a personal data level and field groups. The endpoint gets data the way a token with that access would. It can never have more access than the person who saves it.
  • A signing secret (whsec_…), shown once. Rotate it with an overlap (24 hours by default, up to 7 days): until the old secret expires, each delivery carries a signature for both, so you can switch without missing an event.
  • A status. Pause an endpoint and Kennra keeps its events, then sends them in order when you resume it.

Creating, changing, rotating, pausing and deleting an endpoint are audited. Deleting one cancels the events still queued for it and destroys its secret. A workspace has at most 25 endpoints. An endpoint writes nothing in Kennra, so nothing it causes comes back to it.

In a blueprint, endpoints are a webhooks section, found again by name (kennra apply -f). kennra export --blueprint writes them back, never with their secrets:

webhooks:
  - name: Won deals to ERP
    url: https://erp.example.com/kennra
    events: [kennra.deal.stage_changed]
    filter: { type: deal, stage: won }
    purposes: [sales.b2b]
    piiLevel: contact_basic
    fieldGroups: [commercial]

Filters

A filter is a condition on the event, in the same shape as segment definitions. Combine conditions with all, any and not:

ConditionMatchesExample
fieldA field of the event's data: eq, neq, in, notIn, like (with *), exists, notExists, gt, gte, lt, lte, between{ "type": "field", "path": "toStage", "op": "in", "value": ["won", "lost"] }
dealThe deal the event is about: pipeline, stage, dealTypes{ "type": "deal", "pipeline": "sales", "dealTypes": ["subscription"] }

More examples:

  • Deals won over NOK 100 000: types kennra.deal.won, { "type": "field", "path": "amountAtClose", "op": "gt", "value": "NOK 100000" }. An amount is Money and compares only within its currency, so a deal won in SEK never matches. Use eq, gt, gte, lt, lte or between ("value": ["NOK 10000", "NOK 50000"]) on an amount, and <amount>.currency for its currency: { "path": "amountAtClose.currency", "op": "eq", "value": "EUR" }.
  • A trait value set on a machine field: types kennra.entity.attribute_asserted, { "type": "field", "path": "trait", "op": "like", "value": "custom.maskin_*" }.
  • People entering one segment: types kennra.segment.member_entered, { "type": "field", "path": "segmentId", "op": "eq", "value": "seg_vip" }.
  • Records of one Kind, custom Kinds included: types kennra.record.*, { "type": "field", "path": "kind", "op": "eq", "value": "custom.machine" }.

Kennra checks a filter against the schemas of the types you picked when you save it. A field must be on every picked type, so pipelineId on kennra.deal.* is refused (kennra.deal.won has none). Use the deal condition there: it reads the stage and pipeline from the event when it has them, and the deal as it is now otherwise. kennra events types and the eventTypes query list each type's fields.

The same filters work on the feed and the stream, as query parameters: field.<path>=a,b (one of the values; * is a wildcard), deal.pipeline, deal.stage, deal.dealTypes, or filter=<JSON>.

Conditions in the admin

Under Settings → Webhooks, Only when builds the same filter in words. Each field has a name in English and Norwegian (Amount at close, Company, Stage), with its path in small type under it. Fields the admin has no name for, such as the data of your own events, get one from their path (customerTier reads as Customer tier).

The value fits the field: the pipeline's stages by name, a search for a company, person or deal, a currency list, a yes/no switch, or an amount in one currency. The rules fit it too: a name or an id is, is one of or is not, and an amount or a number is greater than, less than or between. A line under the conditions says the whole filter in one sentence:

The conditions of a webhook endpoint: Amount at close is greater than NOK 100 000, Company is Fjellsport AS, and the sentence under them

Sends deal.won when the amount at close is over 100,000 kr and the company is Fjellsport AS.

The admin stores what the API takes, so a filter from the CLI, a blueprint or the API opens in the form as it is:

In the formStored
is{ "op": "eq", "value": "org_…" }
is one of{ "op": "in", "value": ["qualified", "quote"] }
is not{ "op": "neq", "value": "lost" }, or notIn with several values
greater than, less thangt, lt, with Money for an amount: "NOK 100000.00"
between{ "op": "between", "value": ["NOK 10000.00", "NOK 50000.00"] }
yes or no{ "op": "eq", "value": true }

A company, a person or a deal is stored by its id and shown by its name. A stage is stored by its id (qualified). Operators the form doesn't offer for a field, such as like or gte, stay as they are when you open and save the filter.

Your own events

A workspace can define its own event types, named custom.<name>. They reach the feed, the stream, workspace endpoints and app subscriptions like Kennra's own events, with the same filters and the same personal data rules. Subscribe to all of them with custom.*. They also show on the timeline of the record they are about, with their label.

There are two kinds:

KindWho sends itDefined with
A ruleKennra, when one of its own events matches a conditionTriggers, a condition and the fields to carry
An emitted typeYour app or system, with emitEventA JSON Schema and a personal data class per field

Schema owners (kennra:schema:write or kennra:schema:publish) define them under Settings → Events, with kennra events define, or in a blueprint (events:). Agents, apps and developer tokens propose them: Kennra publishes a proposal at once in a test, development or demo workspace, and a schema owner publishes it in staging and production. Every change is audited.

A rule

"A subscription deal over 1 000 000 NOK was won":

type: custom.big_subscription_won
kind: rule
label: { en: Big subscription won, nb: Stort abonnement vunnet }
triggers: [kennra.deal.won]
condition:
  type: all
  conditions:
    - { type: deal, dealTypes: [subscription] }
    - { type: record, path: deal.amount, op: gt, value: NOK 1000000 }
fields:
  - { name: dealId, from: event.dealId }
  - { name: amount, from: deal.amount }
  - { name: company, from: organization.name }
kennra events define -f big-subscription-won.yaml
  • Triggers are Kennra's own event types. A rule never listens to custom events, so one rule can't set off another.
  • The condition uses the filter language above, plus a record condition on the record the event is about as it is now: deal.amount (Money, compared within its currency), deal.currency, deal.dealTypes, deal.stage, organization.organizationTypes, organization.lifecycleStage, organization.segments, person.segments, and trait values as <record>.traits.<trait>.<field>. Under Settings → Events, Only if builds it with the same names, values and rules as webhook conditions, and says the rule in one sentence: "Records Big subscription won on deal.won when the deal type is Subscription and the amount at close is over 1,000,000 kr."
  • Fields say what the event carries: event.<path> from the trigger, or a record path. Kennra derives the event's schema from them.
  • Order and once only: Kennra evaluates rules in commit order, after its read models include the trigger, and emits once per rule and trigger. The event's causedBy is the id of the trigger.
  • Versions: a change publishes a new version. A rule applies to events recorded after its version was published, and never emits for history. The preview in Settings → Events shows which events of the last 7 days would have matched, without emitting anything.

An emitted type

Register the type with its schema. Every field needs a personal data class: none, contact, profile, content, commerce_ref or sensitive.

{
  "type": "custom.large_order",
  "kind": "emitted",
  "label": { "en": "Large order", "nb": "Stor ordre" },
  "schema": {
    "type": "object",
    "properties": {
      "orderId": { "type": "string" },
      "total": { "type": "number" },
      "currency": { "type": "string" }
    },
    "required": ["orderId", "total", "currency"]
  },
  "pii": { "orderId": "none", "total": "none", "currency": "none" },
  "commercial": ["total"]
}

Then send events with the scope kennra:events:emit. Kennra checks data against the schema and stores the event. subject is the company, person, deal or record the event is about. A type with personal fields needs one.

kennra events emit custom.large_order --subject 01m8fe… --data '{"orderId":"o-1001","total":250000,"currency":"NOK"}'
await kennra.events.emit({
  type: 'custom.large_order',
  subject: companyId,
  data: { orderId: 'o-1001', total: 250000, currency: 'NOK' },
  idempotencyKey: 'shop:order:o-1001',
});

An app lists the types it sends in its manifest, and the admin sees them when installing it:

access:
  scopes:
    - scope: kennra:events:emit
      purposes: [organization.management]
      why: Tell Kennra when a large order comes in.
capabilities:
  events:
    emits: [custom.large_order]

emitEvent is idempotent per idempotency key, and limited per token (600 a minute by default).

Personal data in your own events

A custom event never carries more than its definer may read. Kennra derives the personal paths of a rule from the fields it projects (a person's name is personal; a trait field has its own class) and takes them from the schema of an emitted type. It encrypts those fields with the key of the person or company, and every reader below the full level gets them as null. Commercial fields are left out for readers without the commercial field group. GET /schemas with your token includes the workspace's own types, with x-kennra-pii.

The delivery log

Settings → Webhooks opens each endpoint with its health and its deliveries:

  • Each attempt with the time, the result, the HTTP status, how long your server took and the first 300 characters of its answer. Kept for 30 days.
  • Health: deliveries and failures in the last 24 hours, events waiting, events Kennra gave up on, the last success and the last failure.
  • Retry a failed delivery, send again what an endpoint got between two times (at most 1,000 events at a time, with their original webhook-id), and send a test event.

If deliveries fail for 3 days with no success in between, Kennra pauses the endpoint and says why. Fix your server, then resume it: the events are kept.

kennra webhooks list
kennra webhooks deliveries "Won deals to ERP" --failed
kennra webhooks retry <delivery-id>
kennra webhooks replay "Won deals to ERP" --from 2026-11-27T08:00 --to 2026-11-27T10:00
kennra webhooks rotate-secret "Won deals to ERP" --overlap 24
kennra webhooks pause "Won deals to ERP"

Subscribe in the manifest

An app declares the events it wants in its manifest, and a workspace admin approves them when installing the app.

access:
  piiLevel: contact_basic
  scopes:
    - scope: kennra:read
      purposes: [sales.b2b]
      why: Keep our quoting tool in step with deal stages in Kennra.
capabilities:
  webhooks:
    url: https://quotes.example.com/kennra/events
    events:
      - kennra.deal.stage_changed
      - kennra.deal.won
      - kennra.consent.withdrawn

A manifest names Kennra's event types exactly, and the workspace's own as custom.* or by name; filters are for workspace endpoints and the stream. Subscriptions need the kennra:read scope. They start when the app is installed: events recorded before the install are not sent. Events caused by the app's own writes are not sent back to it.

GET /schemas returns the JSON Schema of every event type, and GET /schemas/{type}/{version} one of them. Event types are named kennra.<area>.<what_happened>, for example kennra.party.registered, kennra.task.created or kennra.segment.member_entered.

The request

Kennra sends one POST per event, with a CloudEvents 1.0 JSON body:

POST /kennra/events HTTP/1.1
Host: quotes.example.com
content-type: application/json
kennra-installation: 01jd5x2n8q4r7t9v3w6y1z0abc
webhook-id: msg_3f9c2a7b1e4d8f6a0c5b9e2d7a1f4c8b
webhook-timestamp: 1762790400
webhook-signature: v1,K5oZfzN95Z9UVu1EsfQmfVNQhnkZ2pj9o9NDN/H/pI4=
 
{
  "specversion": "1.0",
  "id": "01jd5x3a9b2c4d6e8f0g1h3j5k",
  "type": "kennra.deal.stage_changed",
  "source": "kennra:fjellsport-demo",
  "subject": "01jd3k9q7xw2m8c4v6t5hpa1rz",
  "time": "2026-11-10T13:20:00.000Z",
  "installationId": "01jd5x2n8q4r7t9v3w6y1z0abc",
  "workspace": "fjellsport-demo",
  "data": { "…": "…" }
}
FieldMeaning
idThe event id
typeThe event type
subjectThe main record the event is about, when there is one
timeWhen Kennra recorded the event
dataThe event payload, filtered by your PII level (see below)
dataWithheldtrue when the whole payload was withheld

A workspace endpoint gets the same body with endpointId instead of installationId, a kennra-webhook-endpoint header, and withheldReason (pii_level, purpose_not_granted or record_visibility) or withheldFields when its access left data out.

Answer with any 2xx status within 5 seconds. Any other status, a timeout or no connection counts as a failed attempt. Do slow work after you answer.

Verify the signature

Every request from Kennra to an app is signed per Standard Webhooks: webhooks, lifecycle calls, lookups and schedule ticks alike.

  • The signed content is <webhook-id>.<webhook-timestamp>.<raw body>.
  • The signature is an HMAC-SHA256 with the installation's signing secret (whsec_ plus base64), sent as v1,<base64>.
  • Reject requests whose timestamp is more than 5 minutes from your clock.

The App SDK verifies requests for you before your handler runs. To verify by hand, use verifyWebhook from @kennra/sdk, or verify from @kennra/app-sdk/signature in an app:

import { verifyWebhook, WebhookVerificationError } from '@kennra/sdk';
 
export async function handle(req: Request, signingSecret: string): Promise<Response> {
  let event: { id: string; type: string };
  try {
    event = await verifyWebhook(req, signingSecret); // 5 minutes tolerance by default
  } catch (e) {
    if (e instanceof WebhookVerificationError) return new Response(e.code, { status: 401 });
    throw e;
  }
  // Deduplicate on the webhook-id header, then queue the work for event.type.
  return new Response(null, { status: 204 });
}

Both accept a list of secrets, so you can keep the old one during a rotation. Your app reads its signing secrets from GET /apps/installation. A workspace endpoint's secret is shown once when you create or rotate it.

Deduplicate with webhook-id

webhook-id is stable per event and installation (or endpoint), across retries and replays. Store the ids you have handled and skip repeats. The timestamp and signature are new on every attempt.

Retries and dead letters

StepBehaviour
First retryAfter 10 seconds
BackoffDoubles per attempt, capped at 6 hours, with jitter (50–100 % of the delay)
Attempts15, about 1.5 days in total
After the last attemptThe message is dead-lettered and waits for a replay

While an admin has paused an app or an endpoint, its messages wait without using up attempts. Uninstalling the app, or deleting the endpoint, cancels undelivered messages.

Ordering

Kennra delivers an installation's or endpoint's messages in the order the events were recorded. A failing message holds back later ones only for its first 3 attempts. After that it retries on its own schedule while newer events flow, so one bad event can't block your app for a day and a half.

If you need strict order, compare the event's time before you apply it.

Replay

In the admin, Settings → Webhooks shows every attempt, each message's state (retrying with the next try, delivered or dead-lettered) and a Replay action. A replay sends the message again at once, with the same webhook-id.

Replay is the replayWebhookDelivery mutation. It needs the kennra:observe scope and a person, not an agent, and it is audited. The WebhookDeliveries operation lists deliveries.

Test events

Send a test event to check your endpoint before real events arrive. In the admin, open Settings → Webhooks and choose Send test event (for a workspace endpoint, on its own page). From the terminal:

kennra webhooks test "Won deals to ERP" kennra.deal.stage_changed
kennra webhooks endpoints                       # app endpoints
kennra webhooks test my-app kennra.deal.stage_changed

Kennra sends a realistic sample payload for that event type, filtered by the app's PII level and signed with the installation's secret, exactly like a real delivery. The body carries "test": true:

{
  "specversion": "1.0",
  "id": "8d1c9f5e-2b7a-4c3d-9e1f-6a5b4c3d2e1f",
  "type": "kennra.deal.stage_changed",
  "source": "kennra:fjellsport-demo",
  "time": "2026-11-21T09:30:00.000Z",
  "installationId": "01jd5x2n8q4r7t9v3w6y1z0abc",
  "workspace": "fjellsport-demo",
  "data": { "dealId": "01jd5x3a9b2c4d6e8f0g1h3j5k", "fromStage": "qualified", "toStage": "proposal", "…": "…" },
  "test": true
}

A test event has no recorded event behind it: don't act on it in production. Its webhook-id starts with msg_test_. The attempt shows in the delivery list with a Test badge. It is never retried or replayed. Sending one needs the kennra:observe scope and a person, is audited, and is limited to 10 a minute per workspace.

Listen to the event stream

Read the workspace's events yourself, without a public URL. The feed is the same events a webhook would get, in the order they were committed, filtered by your token's access. It needs a token with kennra:read and kennra:events:read (the developer token presets include both).

Pages: GET /events

curl -s -H "Authorization: Bearer $KENNRA_TOKEN" \
  "https://api.kennra.com/events?types=kennra.deal.*&deal.stage=won&limit=50"
{
  "events": [
    {
      "specversion": "1.0",
      "id": "01a21e96-3b43-7a46-b34c-8ab5bdd4bb86",
      "type": "kennra.deal.stage_changed",
      "source": "kennra:fjellsport-demo",
      "subject": "01jd3k9q7xw2m8c4v6t5hpa1rz",
      "time": "2026-11-27T13:20:00.000Z",
      "datacontenttype": "application/json",
      "workspace": "fjellsport-demo",
      "data": { "dealId": "01jd3k9q7xw2m8c4v6t5hpa1rz", "fromStage": "proposal", "toStage": "won", "…": "…" },
      "cursor": "c1_OTA1Ny4xMDY1NQ"
    }
  ],
  "cursor": "c1_OTA1Ny4xMDY1NQ",
  "hasMore": false
}

Pass the page's cursor as after for the next page. The cursor is opaque: store it as it is. Without after, the feed starts 7 days back; since=<ISO time> starts at a time, after=now from now.

Long poll: wait

Add wait=<seconds> (at most 25) and Kennra answers as soon as an event arrives, or with an empty page when the time is up:

curl -s -H "Authorization: Bearer $KENNRA_TOKEN" "https://api.kennra.com/events?after=$CURSOR&wait=25"

Server-Sent Events: GET /events/stream

curl -N -H "Authorization: Bearer $KENNRA_TOKEN" \
  "https://api.kennra.com/events/stream?types=kennra.party.registered,kennra.deal.*"
retry: 3000
: connected
 
id: c1_OTA1Ny4xMDY1NQ
event: kennra.party.registered
data: {"specversion":"1.0","type":"kennra.party.registered","data":{"legalName":"Hardanger Frukt AS","…":"…"},"…":"…"}
 
id: c1_OTA2MS4xMDY2MA
: heartbeat 2026-11-27T13:20:15.000Z
  • id: is the cursor, event: the type, data: the event as JSON.
  • A heartbeat comment comes every 15 seconds. It carries the cursor as id:, so a reconnect starts past events that didn't match your filter.
  • After about an hour Kennra closes the stream cleanly. Reconnect with the Last-Event-ID header (browsers' EventSource does it for you) and you get every event after it, none twice.
import { Kennra } from '@kennra/sdk';
 
const kennra = new Kennra({ token: process.env.KENNRA_TOKEN });
 
// Reconnects with Last-Event-ID on its own. Store e.cursor to resume after a restart.
for await (const e of kennra.events.stream({
  types: ['kennra.deal.*'],
  filters: { 'deal.stage': 'won' },
  after: savedCursor,
})) {
  console.log(e.type, e.data, e.cursor);
}
 
// A page in commit order: kennra.events.list({ types, filter, after, first })

Limits

LimitValue
Events per page1 to 500, 100 by default
Long pollwait at most 25 seconds
Streams and long polls open at once5 per token, 100 per workspace, per API instance (429 with Retry-After)
Pages120 a minute per token (429 with Retry-After)
Stream lifetimeAbout 1 hour, then reconnect with Last-Event-ID
Resume window7 days. An older cursor answers 410 cursor_expired with a restart cursor for now; catch up on what you missed through the API

Governance events (kennra.access.*, kennra.agent.*) need kennra:audit:governance, and privacy events (kennra.privacy.*) need kennra:privacy. Without them the feed leaves those events out.

Develop locally with kennra listen

kennra listen forwards the workspace's events to a URL on your machine as they happen, signed like real webhooks. You don't need a public URL or an installed app:

kennra listen --forward-to http://localhost:3000/webhooks --events 'kennra.deal.*'
Ready. Forwarding kennra.deal.* to http://localhost:3000/webhooks
Signing secret for this session: whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw
Verify with it like a real webhook (Standard Webhooks). Events are filtered by your access (PII level full).
Session 01jd9a…, ends 2026-11-21 17:30 UTC. Ctrl-C to stop.
 
09:31:12  kennra.deal.stage_changed           → 200  14 ms  3f9c2a7b-1e4d-4f6a-8c5b-9e2d7a1f4c8b
09:31:40  kennra.deal.won                     ✗ HTTP 500  9 ms  7a1f4c8b-3f9c-4f6a-8c5b-9e2d1e4d2a7b
  • Signing. The CLI signs each request with the session's secret (whsec_…, Standard Webhooks), so the verify code above works unchanged. The secret is made on your machine and never sent to Kennra. Pass --secret whsec_… (or set KENNRA_LISTEN_SECRET) to keep the same one across sessions.
  • Body and headers. The same CloudEvent as a real delivery, without installationId, plus a kennra-listener header with the session id. webhook-id is stable per event and session.
  • Filters. --events takes event types and patterns (kennra.deal.*, comma-separated or repeated); without it you get every event type.
  • Your access, not an app's. Events are filtered by your own access, on every read: the PII filter above at your PII level, data withheld (dataWithheld: true with a withheldReason) for events under purposes you don't hold or when your roles limit which records you see, and deal amounts withheld without the commercial field group.
  • Limits. A session needs the kennra:observe scope and a person's token. It only sees events from when it started, ends when you press Ctrl-C or after 8 hours, and is audited. You can have 3 open at once and start 20 an hour.
  • No retries. Each event is sent once, with a 5 second timeout. The log line shows the status or what went wrong.
  • Forward targets. localhost over http, anything else over https only.

Under the hood the CLI uses the public API: StartWebhookListener, then WebhookListenerEvents as a long poll, and StopWebhookListener on the way out.

PII filtering

Kennra filters each payload by the PII level of the installation, the endpoint or your token before sending it:

  • With PII level full, data is sent as recorded.
  • Below full, the personal data fields that the event type declares are set to null.
  • Below full, an event type with no personal data declaration carries no data at all: data is {} and dataWithheld is true. Kennra fails closed rather than send fields it can't classify.

Workspace endpoints and the feed also leave data out for events under purposes they don't hold (withheldReason: purpose_not_granted) or when the reader's roles limit which records it sees (record_visibility), and leave deal amounts out without the commercial field group (withheldFields).

When you need a withheld value, read it through the GraphQL API under a purpose your grant holds.