Skip to main content
The KontextManagementClient is the typed management layer for the Kontext identity control plane. Use it to automate applications, integrations, service accounts, sessions, and traces in CI/CD pipelines, admin tooling, or internal automation.

Install

Initialize

The client authenticates using OAuth client credentials. It fetches and caches an access token on the first request and refreshes it automatically when it expires.

Constructor config

Create service account credentials in the Kontext dashboard under Settings > Service Accounts, or programmatically with client.serviceAccounts.create(). Resource IDs used by the Management API are UUIDs. OAuth client IDs are separate (app_<uuid> for applications and sa_<uuid> for service accounts).

Applications

Manage applications registered with your organization.

List applications

Get an application

Create an application

Update an application

Archive an application

Rotate client secret

Generates a new client secret and returns the full OAuth configuration. The previous secret is revoked immediately.

OAuth configuration

Manage integrations

Attach or detach integrations from an application. An application can only use tools from its attached integrations.

Method reference

Integrations

Manage integrations — the external services your applications connect to.

List integrations

Create an integration

Validate an integration

Tests the connection to the integration’s MCP endpoint and returns the result. status is one of "pending", "valid", or "invalid".

Method reference

Service accounts

Service accounts provide machine-to-machine credentials for the Management API. Each service account gets a clientId and clientSecret pair.

Create a service account

Rotate credentials

The previous secret is revoked immediately.

Revoke a service account

Method reference

Sessions

View and manage active MCP sessions for your applications.

List sessions

Get a session

Revoke all sessions

Terminates all active sessions for the application. Connected clients will need to re-authenticate.

Method reference

Traces

Query tool execution traces for observability and debugging.

List traces

Filter by userId, sessionId, or agentId to narrow results.

Get a trace with events

Returns the trace metadata and its full event timeline.

Trace statistics

Method reference

Events

Query trace events directly, without going through a specific trace.

Method reference

Token management

The client handles token lifecycle automatically. Two methods are available for manual control.
Use clearToken() when rotating service account credentials — the client picks up the new secret on the next request.

Complete example

Create an application, set up an integration, and attach them together:

Error handling

The management client throws the same error types as the rest of the SDK. See Errors for the full reference.
Common cases:
  • 401 — Invalid or expired service account credentials. Check your clientId and clientSecret.
  • 403 — Insufficient permissions. The service account may need additional scopes.
  • 404 — Resource not found. Verify the ID.
  • 429 — Rate limit exceeded. The error includes a retryAfter value in seconds.

Next steps

  • TypeScript SDK — Overview of all SDK entry points and subpath exports.
  • Errors — Full error hierarchy, error codes, and handling patterns.