CLI
kennra is the command-line client for Kennra. It reads and writes the customer memory through the public API with your token, like the admin and the MCP server. It has no shortcuts: if the API can't do something, the CLI can't either.
The CLI is built for people, CI pipelines and AI agents in a terminal. Every command runs without prompts, --json gives stable output, and exit codes are documented.
Install
macOS and Linux:
curl -fsSL https://raw.githubusercontent.com/Kennra/cli/main/install.sh | shWindows (PowerShell):
irm https://raw.githubusercontent.com/Kennra/cli/main/install.ps1 | iexThe script downloads the binary for your system from github.com/Kennra/cli, checks it against SHA256SUMS and puts kennra on your path. The binary has its own runtime, so you need nothing else. You can also download it from the release yourself.
With a package manager, from the npm registry. With Bun:
bun add -g kennraWith npm (Node.js 22 or newer):
npm i -g kennraOr run it once without installing, with bunx kennra --help or npx kennra --help.
The CLI is MIT licensed.
Check your setup:
kennra doctordoctor checks the connection, the token, scopes, the operations the CLI needs and versions.
Sign in
Create a developer token in Kennra under Settings → Tokens, then pipe it in:
pbpaste | kennra login --token-stdin
kennra whoamiThe token is read from stdin, so it stays out of your shell history. A developer token works in the workspace it was created in. kennra whoami shows the workspace, what your access allows, and on its Schema line what the token can do with the data model. Signing in through the browser comes in a later version, so today kennra login needs --token-stdin.
| Command | Use |
|---|---|
kennra login --token-stdin | Sign in with a token, for example a developer token from Settings → Tokens |
KENNRA_TOKEN=… kennra … | Use a token for one run. It overrides the profile and is never stored |
kennra logout | Delete the token for the profile |
Schema work
To build a workspace's structure (custom Kinds, traits, pipelines, programs and segments) from the CLI or an AI agent, pick Build the data model when you create the token. A schema owner creates it under Settings → Tokens, or with the CLI:
kennra tokens create --name "Data model" --preset schema| Preset | Use it for |
|---|---|
Read customer data (read) | Reports and exports |
Read and write customer data (read-write) | Scripts and integrations that write companies, people, deals, tasks and enrollments |
Build the data model (schema) | Everything in read-write, plus proposals for Kinds, traits, pipelines, programs and segments |
The token proposes and never publishes. In a test, development or demo workspace Kennra publishes its proposals at once. In staging and production they wait for a schema owner. kennra whoami shows what the token can do with the schema. A token without it is refused with exit code 4, and the message names the preset to create.
Tokens go to the OS keyring (macOS Keychain, Linux Secret Service) or to credentials.json with mode 0600, and renew themselves. Set KENNRA_KEYRING=off to force the file, for example in CI containers.
Workspaces and profiles
kennra whoami # workspace, actor, roles, scopes, purposes and PII level
kennra workspaces # the workspaces your login belongs to
kennra workspaces switch fjellsport-demoThe workspace is a profile setting, sent as the kennra-workspace header. A profile combines a workspace and a token. Choose one with --profile or KENNRA_PROFILE. The config lives in ~/.config/kennra/config.json and never holds tokens.
Common commands
kennra organizations find fjellsport
kennra organizations show "Fjellsport AS"
kennra parties timeline "Fjellsport AS" --first 20
kennra notes create --on "Fjellsport AS" "Asked for SSO before signing."
kennra tasks list --on "Fjellsport AS" --status open
kennra consent check <person id> --purpose marketing.email --channel email
kennra deals open "Fjellsport AS" --name "Expansion 2027" --amount "NOK 54000" --dry-runRun kennra --help for the full list and kennra <command> --help for one command. The main groups:
| Group | Commands |
|---|---|
| Read | organizations find, organizations show, organizations taste, people taste, parties timeline, tasks list, activity list, consent check, pipelines list, pipelines show, programs list, programs show, segments list, segments show, segments members |
| Write | organizations register, people register, prospects add, deals open, deals advance, deals win, deals lose, deals reopen, deals update, deals move-pipeline, interactions log, notes create, tasks create, traits set, consent record, programs enroll, programs move |
| Events and webhooks | events, events types, events define, events custom list, events custom show, events emit, webhooks list, webhooks create, webhooks update, webhooks rotate-secret, webhooks pause, webhooks resume, webhooks delete, webhooks deliveries, webhooks retry, webhooks replay, webhooks endpoints, webhooks test, listen |
| Data model as code | apply, export --blueprint, kinds list, kinds export, kinds apply, kinds draft, traits list, traits plan, traits apply, traits draft, traits migrate, pipelines apply, programs apply, segments apply, segments preview, segments recompute, segments sync, segments archive |
| Import and export | import organizations, import people, export |
| Apps and MCP | apps list, apps status, apps install, apps pause, apps resume, apps uninstall, apps run, apps validate, apps init, mcp install |
| Access | members list, members invite, members set-roles, members deactivate, members reactivate, roles list, teams list, teams create, teams add, tokens, agents list, agents show, agents token, agents pause, agents resume, agents kill, agents stop-all, proposals, audit search, dsr |
| Workspaces | workspaces, workspaces switch, workspace get, workspace set |
| Debug | query, operations list, logs list, logs tail, doctor |
Run any operation
kennra query runs a persisted operation by name. The CLI looks up its hash in /graphql/operations:
kennra query OrganizationList --var first=10 --json
kennra query OrganizationCard --vars '{"id":"01jd3k9q7xw2m8c4v6t5hpa1rz"}' --purpose sales.b2bWith the graphql:adhoc scope you can also run kennra query --adhoc "<GraphQL>" or -f file.graphql.
Global flags
| Flag | Meaning |
|---|---|
--json | One JSON document on stdout, also on errors |
--profile <name> | Use another profile |
--workspace <identifier> | Run one command in another workspace |
--purpose <purpose> | Send kennra-purpose. Must be in the operation's list and your grant |
--dry-run | Show what a write would do, without writing |
--idempotency-key <key> | Override the derived key for one write |
--yes | Confirm an action. Without it, confirming commands stop with exit code 2 |
--no-color | No colour or symbols, also on a terminal |
Writes send idempotency keys, so a retry gives the same result. Withheld fields show as [withheld: <reason>], never as empty.
Colour and output
On a terminal the CLI shows colour, symbols and a spinner for long operations. It leaves them out when the output goes to a pipe or a file, or with NO_COLOR set, TERM=dumb or --no-color. FORCE_COLOR=1 turns colour on anyway, and FORCE_COLOR=0 turns it off. --json never has colour or decoration, so scripts read the same bytes every time.
A workspace as code
A blueprint holds a workspace's whole structure in one file or a directory of files: custom Kinds, traits, pipelines, programs, segments, the workspace's own event types (events) and webhook endpoints, and demo data if you want it. Schema as code has the format and every section.
kinds:
- name: custom.maskin
label: Maskin
labelPlural: Maskiner
description: En maskin en kunde eier.
relations: [{ name: eier, target: organization, required: true, label: Eier, inverseLabel: Maskiner }]
pipelines:
- id: maskinsalg
label: Maskinsalg
stages:
- { id: lead, label: Lead, category: open }
- { id: vunnet, label: Vunnet, category: won }
- { id: tapt, label: Tapt, category: lost }kennra apply -f workspace/ --dry-run # one review of everything that would change
kennra apply -f workspace/ # applies Kinds, traits, pipelines, programs, segments, events, data, then webhooks
kennra export --blueprint -o current.yaml- Kennra checks the whole blueprint before it writes anything, and every reference must resolve.
- The layers are applied in order, and a run stops at the first layer that fails. Every step is idempotent, so running it again is safe: unchanged items report as unchanged.
- With schema rights, items are published. Otherwise they become proposals. In a test, development or demo workspace, proposals are published at once. In staging and production, an item that uses a proposal waits for it: run
applyagain once a schema owner has published it. - From a developer token, use the preset Build the data model (see Schema work).
data(companies, people, deals, records and enrollments) is written in test, development and demo workspaces. Elsewhere it needs--allow-data.kennra export --blueprintwrites the current structure, so you can compare workspaces or copy one to another.
Custom Kinds on their own: kennra kinds apply -f kinds.yaml. AI agents get the same through the MCP tool apply_blueprint.
Events
Read the workspace's events in the order they were committed, filtered by your token's access. --follow streams them and reconnects where it left off. Needs kennra:read and kennra:events:read (the developer token presets include both).
kennra events --types 'kennra.deal.*' --deal-stage won
kennra events --follow --types 'kennra.party.registered,kennra.deal.*'
kennra events --after c1_OTA1Ny4xMDY1NQ --field toStage=won,lost
kennra events types --area dealFilters: --field path=a,b (one of the values, * as a wildcard), --deal-pipeline, --deal-stage, --deal-types, or --filter '<JSON condition>'. With --json, a page is one JSON object and --follow prints one event per line. See Webhooks.
The workspace's own events (custom.<name>): define a rule or an emitted type from a YAML or JSON file, list them, and send one.
kennra events define -f big-subscription-won.yaml # publishes, or proposes without schema rights
kennra events custom list
kennra events custom show custom.big_subscription_won
kennra events emit custom.large_order --subject <record id> --data @order.jsondefine publishes a new version only when the file changed. Without kennra:schema:write, or with --propose, it saves a proposal for a schema owner. emit needs kennra:events:emit. See Your own events.
Webhooks
Your workspace's own endpoints (admins, kennra:apps:manage): the events you pick go to your URL, signed and retried.
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
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 test "Won deals to ERP" kennra.deal.stage_changed
kennra webhooks rotate-secret "Won deals to ERP" --overlap 24
kennra webhooks pause "Won deals to ERP"
kennra webhooks resume "Won deals to ERP"
kennra webhooks update "Won deals to ERP" --deal-stage won,lost
kennra webhooks delete "Won deals to ERP" --yescreate and rotate-secret print the signing secret once. Forward events to your machine while you build, and send test events to an app's endpoint (both need kennra:observe):
kennra listen --forward-to http://localhost:3000/webhooks --events 'kennra.deal.*'
kennra webhooks endpoints
kennra webhooks test my-app kennra.deal.stage_changedkennra listen prints a signing secret for the session and one line per delivery: time, event type, status and latency. See Webhooks for how events are signed and filtered.
Import
import organizations and import people read CSV or NDJSON with a mapping file:
{
"kind": "organization",
"columns": { "Company name": "legalName", "Org no": "orgNumber", "Country": "orgNumberCountry" },
"traits": { "custom.legacy_ref": { "Customer no": "customerNumber" } }
}kennra import organizations -f companies.csv --mapping mapping.json --dry-run
kennra import organizations -f companies.csv --mapping mapping.json --report report.ndjson --yesFor people, map to givenName, familyName, email, phone, title and organizationOrgNumber (with organizationOrgNumberCountry). The last links the person to the company, with the role in role (default USER). orgNumberCountry is the country that issued the number (ISO 3166-1 alpha-2). Without it, Kennra reads the number as Norwegian.
How import behaves:
- Each row is matched on strong identifiers (org number, email, phone), so a second run finds the same records instead of creating new ones.
- Rows without a strong identifier are skipped and listed in the report.
- Keys are derived from the row and the mapping, so the import is idempotent.
--dry-runreportscreate,matchorskipper row without writing.- Writing the import needs
--yes.
Other sources come as import plugins: a package named @kennra/import-<source> adds kennra import <source>. kennra import lists the sources you have.
Export
kennra export -o ./export --yesexport writes the current state of the workspace to NDJSON files in the directory you name, with file mode 0600.
Exit codes
| Code | Meaning |
|---|---|
| 0 | OK |
| 1 | Unexpected error |
| 2 | Usage error or missing --yes |
| 3 | Not authenticated |
| 4 | No access: scope, purpose or policy |
| 5 | Not found |
| 6 | Conflict: ambiguous match, reused idempotency key, identity conflict, or an import with failed rows |
| 7 | Validation failed |
| 8 | The API doesn't answer, or answers with a 5xx |
| 9 | Not available yet |
| 10 | traits plan --detailed-exitcode: there are changes |