> For the complete documentation index, see [llms.txt](https://krynix.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://krynix.gitbook.io/docs/reference/api.md). Agents can also search and read this documentation through its [MCP server](https://krynix.gitbook.io/docs/~gitbook/mcp).

# API

The API is how your own agents send Krynix their records and ask it for decisions. If you use Claude Code or Codex, the install does this for you and you do not need this page; see [Connect your agents](https://krynix.gitbook.io/docs/connect-your-agents/connect-any-agent.md).

Everything else, from reading sessions and findings to changing policies, agents, controls, retention and members, is done in the dashboard.

Base URL: `https://api.krynix.dev`. Every request except `GET /health` needs an API key. Every error is `{ "error": { "code": "…", "message": "…" } }` with a status; the codes are in [Error codes](https://krynix.gitbook.io/docs/reference/error-codes.md).

```bash
curl -s https://api.krynix.dev/health
# {"status":"ok","version":"0.12.0","uptime_seconds":…,"checks":{"store":"ok","blob":"ok"}}
```

## Authentication

Send the key as a bearer token: `Authorization: Bearer kx_live_…`.

An owner or admin creates keys under **Settings → API keys**; the key is shown once. A key can send records and ask for decisions, and nothing else: it cannot read your organisation's evidence or change a rule, so a key that leaks from a machine cannot be used to read or rewrite the record. Any other route answers `403 KEY_SCOPE_INSUFFICIENT`. A key created before 12 October 2026 can also read your organisation's evidence; revoke it and create a new one. A missing or revoked key is `401 AUTH_REQUIRED`, with no detail about why.

Requests are rate-limited per key: 50 requests a second sustained with a burst of 500, and the same again separately for `/v1/decide`, so a flood of records never refuses a key's decisions. Over budget is `429 RATE_LIMITED` with `Retry-After`.

## Records

| Method and path                                    | What it does                                                                                                                                                                                                                                                                                                                                                                                                                 |
| -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `POST /v1/sessions/:id/events`                     | Append a batch of events. Creates the session on first use from the first event's `agent_id`; `run_id` in the body groups sessions into a run. Krynix assigns `sequence_num`, `prev_hash` and `event_hash`. A batch is accepted whole or refused whole (`400`). A duplicate of a record already in the chain (same `tool_use_id` or `request_id`) is kept only where it adds a field the first copy lacked. 10 MiB body cap. |
| `POST /v1/sessions/:id/close`                      | End the session. Signs the chain, runs verification and the controls.                                                                                                                                                                                                                                                                                                                                                        |
| `GET /v1/sessions/:id/status`                      | State, chain tip (`seq_num`, `head_hash`), how it ended (`closed_by`), legal hold, and `kind` for a session that is not a run.                                                                                                                                                                                                                                                                                               |
| `POST /v1/traces`                                  | Upload a whole pre-hashed trace (JSON Lines). See [Trace format](https://krynix.gitbook.io/docs/reference/trace-format.md).                                                                                                                                                                                                                                                                                                  |
| `POST /v1/otlp/v1/traces`, `POST /v1/otlp/v1/logs` | OpenTelemetry, JSON or binary protobuf. No metrics route.                                                                                                                                                                                                                                                                                                                                                                    |

The event envelope and the eight event types are in [Event types](https://krynix.gitbook.io/docs/reference/event-types.md).

## Decisions

| Method and path                                                  | What it does                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `POST /v1/decide`                                                | Decide one tool call before it runs. Body: the agent id, the session id, the tool call. Answer: `pass`, `redact` (with `arguments` to use instead), `deny` or `require-approval`, with the policy and rule that decided and every policy that took part. The decision is recorded in the session in the same call; if it cannot be recorded, `503 EVIDENCE_UNAVAILABLE` and no verdict. A suspended agent gets `deny` before any policy. No binding and no baseline: `422 POLICY_UNBOUND`. |
| `POST /v1/sessions/:id/approvals`, `GET …/approvals/:approvalId` | Submit and poll a `require-approval` decision.                                                                                                                                                                                                                                                                                                                                                                                                                                             |

## Clients

* `@krynix/sdk` (TypeScript): the `ActivityRecorder` for records, the pipeline for decisions, with batching, retries and an offline buffer.
* `krynix` (Python): capture and call-site enforcement.
* `@krynix/gateway`: the MCP gateway, streaming its decisions here with `--ingest-url`.

The TypeScript packages install from npm with your organisation's read token. See [Connect any other agent](https://krynix.gitbook.io/docs/connect-your-agents/connect-any-agent.md).
