For the complete documentation index, see llms.txt. This page is also available as Markdown.

Organization API keys

When to use: see Choose your auth for the decision rule. This page covers the Organization API key model — a backend credential that carries an organization role, for automating the K-AI Platform, Audit, and MCP/Retrieval APIs without a browser.

An Organization API key lets a backend service call the same platform APIs a user drives from the K-AI Studio portal — scoped to one organization and to the roles you grant the key. An Organization API key authenticates as a service account with organization-level roles, so the same role-based access control that governs the web apps applies to it.

There are two ways to present the key:

  • Exchange it for a short-lived Bearer token (below). Works on every platform API, including the K-AI Platform API.

  • Send it directly in Authorization: Bearer, with no exchange step, on the Audit and Retrieval APIs and on both MCP endpoints — see Sending the key directly. This is the path for autonomous agent platforms that have no human to complete an OAuth consent screen.

Organization API key

Identity

Service account, organization-scoped

Access control

Role-based, same roles as the portal

Targets

Platform / Audit / Retrieval APIs and both MCP endpoints

Credential

ks_org_… key — sent directly as a Bearer credential, or exchanged for a short-lived Bearer token

How it works

An Organization API key is a long-lived secret you exchange for a short-lived Bearer access token. The token is an ordinary JWT — identical in shape to one obtained via OAuth 2.1 — and is accepted on every platform API that takes a Bearer token.

1. Create a key

Organization administrators create keys from the K-AI Studio portal → Organization → API keys → Create key. Choose a name, the roles the key should carry, and an optional expiry.

The raw key is shown once, at creation, in the form ks_org_…. Store it immediately; it cannot be retrieved later.

2. Exchange the key for a token

Post the raw key to the token endpoint. No other credential is required.

Response — wrapped in the platform's { "response": ... } envelope:

The token lives 15 minutes and there is no refresh token for this flow: when it expires, exchange the key again. Cache it in memory for its lifetime rather than exchanging on every request.

3. Call the API

Send the access token as a Bearer credential. The same token is accepted on the K-AI Platform API, the Audit API (api-audit.kai-studio.ai), and the Retrieval API (api-retrieval.kai-studio.ai).

Sending the key directly

The K-AI Audit API, the K-AI Retrieval API, and both MCP endpoints also accept the raw key in the Authorization header — no exchange call, no OAuth:

K-AI resolves the key internally, so everything downstream is identical to a call made with an exchanged token: same organization RBAC, same group-based instance visibility, same audit trail.

Surface

Raw ks_org_… in Bearer

Audit API — api-audit.kai-studio.ai (REST + /mcp)

Yes

Retrieval API — api-retrieval.kai-studio.ai (REST + /mcp)

Yes

K-AI Platform API — back.kai-studio.ai

No — exchange first

The key is read from the Authorization header only; it is never accepted in a cookie.

Two failure codes come out of this path, and they mean opposite things: 401 means the key is invalid, revoked, or expired — stop; 503 with a Retry-After header means authentication is momentarily unavailable and the credential is not implicated — retry. Full guidance for agent platforms, including how to grant a key access to knowledge bases, is on Autonomous agents (API key).

Roles

A key carries one or more organization roles. The token it produces is authorized exactly as a portal user holding those roles would be — an endpoint the role cannot use returns 403.

Role
Grants, in practice

ADMIN

Full organization administration: members, instances, keys, and every workflow below. The broadest role assignable to a key.

AUTHORITY_MANAGER

View and create instances; define governance scope and run governance operations.

STEWARD

Governance operations plus the full Clean workflow (view, resolve, manage).

KNOWLEDGE_EXPERT

View and resolve Clean items on the instances they belong to.

ACTIVATION_MANAGER

Manage MCP/Retrieval exposure for the organization.

BILLING

View billing information.

CONSUMER

Organization access only — read-level membership.

ORG_OWNER cannot be assigned to a key, and keys never hold platform-wide administrator rights. A key's reach is bounded by its organization and its roles — nothing more.

Lifecycle & security

  • Scope to the minimum. One key, one purpose, the fewest roles. Create separate keys for separate integrations so you can revoke one without disrupting the rest.

  • Server-side only. Never embed an Organization API key — or a token derived from it — in browsers, mobile apps, or any client-side code. It is a machine-to-machine credential.

  • Expiry. Set an expires_at where you can; a key past its expiry stops minting tokens.

  • Revoke. Revoking a key from the portal stops it authenticating new callers. Expect a short tail rather than an instant cut: revocation is not instantaneous, and a token already minted from the key stops working when it expires.

  • Rotation. To rotate, create a new key, deploy it, then revoke the old one.

Which key do I need?

  • Backend automating organization, audit, or retrieval workflows with a role → Organization API keys (this page).

  • Autonomous agent platform driving MCP with no human in the loop → Organization API keys, sent directly in Authorization: Bearer → Autonomous agents.

  • Anything acting on behalf of a human, including interactive MCP clients → OAuth 2.1.

Last updated