kennraDocs

Live lookups

A live lookup fetches details that Kennra doesn't store from the app that owns them: the lines of an order, the price phases of a subscription, the description of a meeting. Kennra calls the app at the moment someone reads the field, checks and caches the answer, and falls back to its stored copy when the app doesn't answer.

Kennra keeps every rule on its own side. It checks the caller's purpose, PII level and access before it calls the app. The app never learns who is asking, only a stable pseudonym it can use for its own rate limits and logs.

Read live details

FieldLookup objectWhat comes back
CommerceFact.detailsorder.details, subscription.detailsLines with name, SKU, quantity, image, prices and booking; payment status; subscription state and phases; externalUrl, the fact in the app's own UI
CommerceFact.details on an invoiceinvoice.detailsLines with VAT rate, payments, reminders, the payment reference (kid) and a short-lived link to the PDF, which the app serves
Document.detailsdocument.detailsTitle, file type, size, last change, owner, a thumbnail and links to open or download the file, read with the connection of the member who linked it
Interaction.detailsinteraction.detailsDescription, location, conference link and attendee count of a captured meeting or email
organizationRegisterSearch(country, text)organization.searchUp to 10 companies from a public company register, by name or organization number
externalObjectSearch, externalObjectsobject.search, object.resolveObjects in an app that an external field points at, such as product variants. See External fields

Each answer says where it came from:

FieldMeaning
liveLIVE (the app answered now), CACHED (an answer from the last 60 seconds, by default) or UNAVAILABLE
reasonWhy it is unavailable: not_found, no_access, timeout, error, invalid_response, circuit_open, concurrency, not_configured, app_paused, app_uninstalled or app_unhealthy
sourceThe app's source system and the time it fetched the data

When the app doesn't answer, the field falls back to Kennra's stored copy, and extensions.kennra.degraded lists it. Show the stored copy with a note, not an error.

A live field costs 200 points of the query cost. A query gets at most three live answers; the rest come back UNAVAILABLE with reason: concurrency. Read details for one record at a time, not for a list.

query OrderLines($id: ID!) {
  commerceFact(id: $id) {
    id
    status
    lines { sku quantity booking { start end unitId } }
    details {
      live
      reason
      source { system fetchedAt }
      externalUrl
      lines { name sku quantity unitPrice booking { start end unitId } }
    }
  }
}

This query runs as an ad hoc query. The persisted operation CommerceFactDetails reads the same fields.

lines is Kennra's stored copy at reference level, and details.lines is what the app answers now. booking is set on a line that books something for a period, such as a rental: the period and the unit, never the reservation's state.

Answer lookups in your app

Declare each lookup in the manifest:

capabilities:
  lookups:
    - object: order.details
      refPattern: "shop:*:order:*"
      url: /lookup/order
      timeoutMs: 1000
      cacheTtlSeconds: 60
      purposes: [organization.management, sales.b2b]
FieldMeaning
objectorder.details, subscription.details, invoice.details, document.details, interaction.details, organization.search, organization.profile, organization.logo, person.photo, object.search or object.resolve
refPatternThe refs the app answers for, with * as a wildcard. A mirrored fact's ref is {system}:{instance}:{type}:{id}. For organization.search it is <country>:<text>, for example NO:*. For organization.profile and organization.logo it is domain:<domain> or identifier:ORG_NUMBER:<country>:<value>, and the request's query carries the same question as { domain?, identifier? }
urlWhere Kennra sends the signed request
timeoutMsDefault 300, at most 1000. Kennra stops waiting after it
cacheTtlSecondsDefault 60, at most 3600
purposesThe purposes the lookup may serve
delegatedtrue when the app answers with a member's own connection, such as their mailbox. Kennra decides access first and sends onBehalfOf

Apps with lookups also declare health.url.

The request

Kennra sends a POST, signed like every call to an app (see Webhooks):

{
  "type": "lookup",
  "object": "order.details",
  "ref": "shop:fjellsport:order:6721",
  "installationId": "01jd5x2n8q4r7t9v3w6y1z0abc",
  "workspace": "fjellsport-demo",
  "purposeClass": "organization.management",
  "requestedBy": { "type": "user", "pseudonym": "u_7f3a…" },
  "deadline": "2026-11-21T14:02:00.300Z"
}

The answer

StatusBodyKennra shows
200{ "data": { … }, "fetchedAt": "…" }The data, checked against the object's shape
404Anyreason: not_found
403Anyreason: no_access, when the source system refuses
Anything else, or no answer before the deadlinereason: error or timeout

Kennra drops fields that the object's shape doesn't have. A data that doesn't match the shape gives invalid_response, and the caller gets the stored copy.

With the App SDK, a handler returns { data }, { notFound: true } or { noAccess: true }. The SDK verifies the signature first:

import type { OrderDetails } from '@kennra/app-sdk';
import { Money } from '@newnormal/money';
 
// app is the createApp(…) from your app's entry point.
 
app.lookup('order.details', async ({ ref, ctx }) => {
  const order = await shop.getOrder(ref.split(':').at(-1)!, String(ctx.secrets['apiToken']));
  if (!order) return { notFound: true };
  const data: OrderDetails = {
    paymentStatus: order.paymentStatus,
    paymentProviders: [order.provider],
    lines: order.items.map((i) => ({
      name: i.name,
      sku: i.sku,
      quantity: i.quantity,
      imageUrl: i.imageUrl,
      // i.price is the shop's decimal string, e.g. "499" → "NOK 499.00".
      unitPrice: Money.of(order.currency, i.price).toString(),
      subTotal: Money.of(order.currency, i.price).multiply(i.quantity, 'half-up').toString(),
      booking: i.rental ? { start: i.rental.start, end: i.rental.end, unitId: i.rental.unitId } : null,
    })),
    meta: [],
  };
  return { data };
});

shop stands for your own client of the source system.

Shapes

Money is one string, "NOK 499.00": the ISO 4217 code, a space and the amount with the currency's decimals (see Money). Money comes from @newnormal/money. Times are ISO 8601 strings.

Objectdata
order.detailspaymentStatus, paymentProviders[], lines[] (name, sku, quantity, imageUrl, unitPrice, subTotal, optional booking { start, end, unitId }), meta[] ({ key, value }) and an optional url
subscription.detailsstate, renewAt, activeUntil, item (sku, name, quantity, imageUrl), phases[] (name, price, period, unit), meta[] and an optional url
invoice.detailslines[] (description, sku, quantity, unitPrice, vatRate, net), payments[] (date, amount, method), reminders[] (date, kind, fee), and optionally kid, pdfUrl and url
document.detailstitle, and optionally mimeType, sizeBytes, modifiedAt, owner, url, thumbnailUrl and downloadUrl
interaction.detailsdescription, location, conferenceUrl, attendeeCount, and optionally url, attachments[] (names and sizes only) and attendees[] with their responses. htmlLink is deprecated: use url
organization.searchresults[], at most 10: name, orgNumber, country, organizationFormCode, organizationFormName, city, industry, employees and status (active, bankrupt, liquidation or deleted)
organization.profilename, and optionally identifiers[], country, industry, employees, address, website, domains[], parent, status and source
person.photourl, and optionally width, height and source. The ref is sha256:<hex> and the query { emailSha256 }: a SHA-256 hash of the contact's email address, never the address. Kennra asks only while the workspace has turned on profile pictures for contacts
organization.logourl, and optionally width, height, format, source, fetchedAt, square { url, width, height } and wide { url, width, height }

url is the order, quote or subscription in the app's own UI. Kennra shows it as Open in the app, as CommerceFact.details.externalUrl, only when it is https and on a host the manifest declares in capabilities.ui.domains or capabilities.ui.links. Any other link is dropped, and the rest of the answer stays. A manifest that declares no hosts may link to any https host.

For organization.logo, Kennra fetches the image itself, once: square when you give it, else url. The URL must be https on a host in your manifest's capabilities.ui.domains, resolve to public addresses, and answer a PNG, JPEG, WebP, GIF or AVIF of at most 5 MB, recognized by its bytes. SVG is never used. Kennra keeps a copy scaled to fit 500 × 500 and serves it from its own API, so the browser never loads your URL. It asks again at most once a month. A logo someone chose in Kennra is never replaced, and a company set to No logo is not asked about. wide is a horizontal wordmark that Kennra keeps for later and does not show as an avatar.

The TypeScript types are OrderDetails, SubscriptionDetails and InteractionDetails in @kennra/app-sdk.