Authentication
Every call to the Kennra API carries a bearer token. The token proves who is calling. Kennra then looks up, on its own side, what that caller may do.
POST /graphql HTTP/1.1
Host: api.kennra.com
authorization: Bearer <token>
kennra-workspace: fjellsport-demoThree kinds of token
| Token | Who it is for | Issued by | Lifetime |
|---|---|---|---|
| Sign-in token | A person using the admin or the CLI | Kennra's sign-in provider at https://auth.kennra.com (OIDC) | Short, renewed with a refresh token |
| Agent token | An agent that acts for you: an MCP client you connected with OAuth (MCP), or a script with a personal agent token | Kennra | OAuth: one hour, renewed with a refresh token until you disconnect. Personal: you choose, at most 90 days (default 30) |
| App installation token | An app installed in a workspace, acting as itself or for one member | Kennra (POST /apps/token) | 15 minutes |
Kennra signs its own tokens (agent and installation tokens) with ES256. The public keys are at GET https://api.kennra.com/.well-known/jwks.json.
The token says who, Kennra decides what
A token carries an identity, not permissions. Roles, purposes, PII level, teams and record visibility live in Kennra per workspace, and the API looks them up on every request. This has two effects:
- When an admin changes your roles, the change applies at your next request. You don't need a new token.
- When a member is deactivated, their tokens and the agent tokens that act for them stop working at once.
Scopes and roles
A scope names a kind of action, such as kennra:read, kennra:party:write or kennra:deal:write. A role is a named bundle of scopes, purposes, a PII level and field groups, for example Sales, Customer service or Viewer. A person can hold several roles and gets the union of them.
The default roles are fixed. An admin makes a custom role by cloning one and changing it in a permission matrix: object types (companies and people, deals, tasks …) × actions (create, update, move stage, win or lose …). Each action maps to a scope and the commands it covers, and has a mode:
| Mode | What happens when the person runs the command |
|---|---|
Allowed (DIRECT) | The write runs |
Needs approval (SUGGEST) | Kennra saves a proposal, and the mutation returns ProposalCreated with the approver: the person's team manager, or else someone who may approve suggestions. When it is approved, the write runs as the person, with approvedBy |
Not allowed (DENY) | The write is refused with FORBIDDEN, reason role_write_denied |
With several roles, the most permissive mode of the roles that hold the action's scope applies. Nobody approves their own proposal. An admin can only give access they have themselves, and nobody can widen a role they hold. The roles query returns each role with its writeModes, and permissionCatalog lists the matrix.
Agents and apps have their own grant with the same parts:
- An agent acting for you gets the intersection of your access and its grant. It never gets more than you. Per command it gets the stricter of its write mode and your role's mode: if your role says a deal win needs approval, so does your agent's, and your approver decides, not you.
- An app acting as itself gets its installation grant only, approved by an admin at install.
- An app acting for a member gets the intersection of its grant and the member's access. See Acting for a member.
Some scopes can never be held by agents or apps, whatever the grant. Examples are kennra:privacy and the workspace and user management scopes.
The Viewer query returns your workspace, actor, roles, scopes, purposes and PII level. Run it when a call is refused and you want to know why. Every scope is listed in Scopes.
Sign-in tokens (OIDC)
People sign in through Kennra's OIDC provider at https://auth.kennra.com. Kennra accepts JWT access tokens whose audience is the Kennra API. Clients use standard flows:
- The admin uses Authorization Code with PKCE.
- The CLI signs in with a developer token today (
kennra login --token-stdin); signing in through the browser comes in a later version. See CLI.
The kennra-workspace header
A sign-in token is not bound to a workspace. You name the workspace with its identifier in the kennra-workspace header. Without the header, the API uses your only workspace. If you belong to several, it answers 401 workspace_required.
Membership is checked on every request, so one token works in every workspace you belong to.
POST /session
Call POST /session with your bearer token right after sign-in. It returns who you are and the workspaces you can pick:
curl -s -XPOST https://api.kennra.com/session -H "authorization: Bearer $TOKEN"{
"user": { "id": "…", "email": "mia@fjellsport.example", "name": "Mia" },
"workspaces": [
{ "identifier": "fjellsport-demo", "name": "Fjellsport (demo)", "kind": "b2b", "role": "admin" }
],
"joined": []
}The first time you sign in, this call links your sign-in identity to the invitation sent to your verified email, and accepts it. joined lists workspaces whose invitations were accepted on this call.
Sign-in errors
Errors on /graphql carry extensions.code and extensions.reason. POST /session returns the reason as error.
| Status | Reason | What to do |
|---|---|---|
| 401 | invalid_token | The signature, expiry, issuer or audience is wrong. Get a new token |
| 401 | unknown_user | No Kennra user and no invitation match this identity. Ask an admin to invite your email |
| 401 | email_not_verified | An invitation matches, but the provider has not verified your email. Verify it, then sign in again |
| 401 | workspace_required | You belong to several workspaces. Send kennra-workspace |
| 401 | identity_provider_unavailable | Kennra can't reach the sign-in provider and has no cached keys. Try again shortly |
| 403 | not_a_member, member_deactivated | You are not, or no longer, a member of the named workspace. Ask a workspace admin |
| 403 | workspace_suspended | Kennra has suspended the workspace. Its data is untouched, but every request is refused. Ask the workspace owner to contact Kennra support |
Developer tokens
A developer token is the quickest way to call the API from a script, a backend or the SDK. Create one in the admin under Settings → Tokens, or with the CLI:
kennra tokens create --name "Order sync" --preset read-write --expires 30d| Preset | What the token may do |
|---|---|
Read customer data (read) | Read under organization.management and sales.b2b, at PII level contact_basic, and read the event feed |
Read and write customer data (read-write) | Also write companies, people, traits, deals, tasks and programs |
Build the data model (schema) | Also propose custom Kinds, traits, pipelines, programs and segments. Never publishes. Only a schema owner can create it |
The token is shown once, lasts at most 90 days, and acts for you: it never gets more access than you have. An agent is who acts, and a token is the key it signs in with. Each developer token creates its own agent, named after the token, so every script has its own activity log and the write modes, budgets, pause, kill switch and audit below apply to that script alone. Under Agents you see what it did, pause it or revoke its token, and add more tokens to it. You can have up to 25 developer agents with a working token. Revoke a token you no longer use to free its place. In a test, development or demo workspace its writes are direct. In staging and production they start as suggest, so each write becomes a proposal you approve. A Build the data model token's proposals for the structure are published at once in a test, development or demo workspace, and wait for a schema owner in staging and production.
kennra tokens list shows your tokens with their agent, fingerprint, last use and status, and kennra tokens revoke <id> ends one at once. Send the token as a bearer token:
import { Kennra } from '@kennra/sdk';
const kennra = new Kennra({ token: process.env.KENNRA_TOKEN });
const viewer = await kennra.request('Viewer');curl -s https://api.kennra.com/graphql \
-H "authorization: Bearer $KENNRA_TOKEN" \
-H 'content-type: application/json' \
-d '{"operationName": "Viewer"}'printf '%s' "$KENNRA_TOKEN" | kennra login --token-stdin
kennra whoamiA developer token belongs to one workspace, so it needs no kennra-workspace header.
Personal agent tokens
A personal agent token lets an agent, a script or a tool such as Claude Code act for you. The token is bound to you and to one agent. It carries no scopes of its own: Kennra looks up the agent's grant.
Create one in the admin under Agents (New agent, then Create token), or with the CLI:
kennra agents token create --name "Claude Code" --template cli-developer --expires 30dThe token is shown once. Kennra keeps only a fingerprint. You can rotate or revoke it from the agent's page or with kennra agents token rotate and kennra agents token revoke.
Each agent has a write mode per command:
| Mode | What happens |
|---|---|
direct | The write runs |
suggest | Kennra saves a proposal, and the mutation returns ProposalCreated. You approve or reject it in the admin |
deny | The write is refused |
Commands without a configured mode default to suggest. Kennra never asks an agent token for a second confirmation: the write mode already says what you allowed. See MCP. You can pause or kill an agent at any time; a killed agent's tokens are revoked.
App installation tokens
Apps get short-lived tokens for one installation with the client credentials grant:
curl -s -XPOST https://api.kennra.com/apps/token \
-H 'content-type: application/json' \
-d '{"grant_type":"client_credentials","client_id":"<app id>","client_secret":"<secret>","installation":"<installation id>"}'{ "access_token": "…", "token_type": "Bearer", "expires_in": 900, "workspace": "fjellsport-demo", "scope": "kennra:read kennra:party:write" }Add scope, a space-separated list, to narrow the token to some of the grant's scopes. A scope outside the grant is refused with 400 invalid_scope, with message and next.
Acting for a member
An app can get a token that acts for one member of the workspace. Its calls then get the intersection of the app's grant and the member's access, and the audit log shows the app acting for that member. There are two ways, both at POST /apps/token:
| Way | For | The app sends |
|---|---|---|
| Token exchange | Apps that declare access.actsForMembers, used by a member who is signed in to Kennra | grant_type urn:ietf:params:oauth:grant-type:token-exchange and subject_token, the member's Kennra token |
| Delegation | Private apps, and published apps that declare access.delegation | The same grant_type and requested_subject, the member's email or user id. The member needs no Kennra sign-in |
Delegation trusts the app's own sign-in, so it is off until a workspace admin turns it on for the installation and picks the members it covers: all, or a list. Kennra checks on every call that delegation is still on and that the member is listed and active. Turning it off stops issued tokens at once.
curl -s -XPOST https://api.kennra.com/apps/token \
-H 'content-type: application/json' \
-d '{"grant_type":"urn:ietf:params:oauth:grant-type:token-exchange","client_id":"fjellsport--sales-tool","client_secret":"<secret>","installation":"<installation id>","requested_subject":"ola@fjellsport.example"}'{ "access_token": "…", "token_type": "Bearer", "expires_in": 900, "workspace": "fjellsport-demo", "installation": "…", "on_behalf_of": "…" }| Status | error | When |
|---|---|---|
| 400 | invalid_request | requested_subject is empty, or sent together with subject_token |
| 400 | invalid_grant | The app may not use delegation here, delegation is off, or Kennra can't act for that member. The answer is the same for an unknown email, an unlisted member and an inactive one |
| 401 | invalid_client | Wrong client id or secret, an unknown installation, or the app is paused or uninstalled |
| 403 | workspace_suspended | The workspace is suspended |
A token that acts for a member never gets governance, privacy or erasure access, even when the member is an owner.
Private apps
A private app is created by a workspace admin under Settings → Apps → Private apps. It gets a client id (<workspace>--<slug>), a client secret shown once, and a grant of the scopes an agent may hold, plus kennra:commerce:write for orders, quotes and subscriptions. An admin changes the grant later under Edit access on the app's page; the client id and secret stay. Access the admin removes stops at once, and added access reaches the next token the app gets.
Keep original dates (import). A workspace admin can let a private app hold kennra:import:backdate, so a migration or sync gives records the source system's dates. It is off by default, and every change is in the audit log. The scope is opt-in per token: only a token that asks for it gets it.
{ "grant_type": "client_credentials", "client_id": "fjellsport--syncer", "client_secret": "…", "installation": "<installation id>", "scope": "kennra:read kennra:party:write kennra:import:backdate" }recordedAt always stays the real time, and the audit log shows the app. A delegated token gets the scope only when it asks for it and the member's roles hold it too. Turn the option off when the migration is done. See Migrate to Kennra.
The grant is checked on every call, so pausing or uninstalling an app refuses its token at once. The App SDK fetches and caches these tokens for you.
Scopes
Roles carry scopes, and agents and apps get them in their grant. The Agents column says whether an agent can hold the scope, and Apps whether an app may ask for it in its manifest. An agent or an app that acts for a member never gets more than that member has.
| Scope | What it allows | Agents | Apps |
|---|---|---|---|
kennra:read | Read customer data under the purposes you hold | Yes | Yes |
kennra:party:write | Register and change companies and people | Yes | Yes |
kennra:deal:write | Open, move, update, win and lose deals, and decide deal link and renewal proposals | Yes | Yes |
kennra:work:write | Write notes and tasks, and log interactions | Yes | Yes |
kennra:program:write | Enroll people and companies in programs, and move enrollments | Yes | No |
kennra:trait:write | Set trait values | Yes | Yes |
kennra:consent:write | Record consent and withdrawals | Yes | Yes |
kennra:interaction:write | Capture meetings and email from a source system, and attach meeting notes | Yes | Yes |
kennra:work:assign | Assign tasks to other members | Yes | No |
kennra:proposal:approve | Approve or reject the proposals of your team | No | No |
kennra:reports:team | See per-person figures for the teams you manage | Yes | No |
kennra:schema:draft | Propose traits, custom Kinds, pipelines, programs, segments and event types | Yes | Yes |
kennra:schema:write | Change and publish the schema | No | No |
kennra:schema:publish | Publish proposals for the schema | No | No |
kennra:workspace:write | Change workspace settings | No | No |
kennra:workspace:owner | The duties only an owner has in the workspace | No | No |
kennra:users:manage | Invite members, set their roles and deactivate them | No | No |
kennra:teams:manage | Create teams and set members and regions | No | No |
kennra:access:manage | Create and change roles and visibility presets | No | No |
kennra:apps:manage | Install, pause and remove apps, and manage workspace webhook endpoints | No | No |
kennra:agents:manage | Manage every agent in the workspace | No | No |
kennra:agents:own | Create agents that act for you | No | No |
kennra:audit:governance | Read governance events | No | No |
kennra:audit:read | Search the audit log | No | No |
kennra:privacy | Run data subject requests and erasure | No | No |
kennra:privacy:intake | Take in a data subject request for the DPO | Yes | No |
kennra:retention:manage | Manage retention policies | No | No |
kennra:legal_hold:manage | Place and lift legal holds | No | No |
kennra:segment:write | Publish, archive and recompute segments | Yes | No |
kennra:segment:sync | Connect segments and programs to apps | No | No |
kennra:segment:approve | Approve the first sync of a profiling segment | No | No |
kennra:import:backdate | Write records with past dates. Only a token that asks for it gets it | No | Yes |
kennra:observe | See logs, deliveries and usage, run kennra listen and send test events | Yes | No |
kennra:events:read | Read the event feed and stream, with kennra:read | Yes | Yes |
kennra:events:emit | Emit events of the workspace's own registered custom.<name> types | Yes | Yes |
graphql:adhoc | Run ad hoc GraphQL instead of persisted operations | No | No |
kennra:commerce:write | Mirror orders, quotes and subscriptions from a source system | No | Yes |
kennra:export | Export the workspace's data | No | Yes |
kennra:segment:read | Read segment members for the app's sync targets | No | Yes |
kennra:suggestions:decide | Pass on a member's own decision on a suggestion, when the app acts for them | No | Yes |
kennra:consent:grant | Record a consent a person gave in the app | No | Yes |
kennra:consent:import | Import earlier consents with evidence | No | Yes |
kennra:engagement:write | Report engagement such as opens and clicks | No | Yes |
The last seven are for apps only: no role holds them. Apps also never get kennra:privacy, the workspace scopes or the right to publish the schema. Private apps hold the scopes an agent may hold, plus kennra:commerce:write. See Apps for how scopes bind to purposes.
Discovery
| Endpoint | What it returns |
|---|---|
GET /.well-known/oauth-protected-resource | Protected resource metadata (RFC 9728) for /graphql, naming Kennra's sign-in provider |
GET /.well-known/oauth-protected-resource/mcp/<workspace> | Protected resource metadata for the MCP server, naming Kennra as the authorization server. See MCP |
GET /.well-known/oauth-authorization-server | Kennra's OAuth 2.1 metadata for MCP clients: /oauth/authorize, /oauth/token, /oauth/register (RFC 7591) and /oauth/revoke |
GET /.well-known/jwks.json | Public keys for Kennra's own tokens |
GET /healthz | Liveness of the API |