# JSON-RPC guide

> The unified JSON-RPC 2.0 gateway — address, authentication, request shape, batching, event streams and error handling.

Kernuq exposes its whole control plane through one JSON-RPC 2.0 gateway: `POST /rpc`. It shares one transactional domain service with MCP tools, the CLI and the console (100% UI–Tool parity).

## Address and auth

- Default: `http://127.0.0.1:7680/rpc` (loopback only)
- The local owner needs no login; other callers send `Authorization: Bearer <token>`, issued by `iam.create_token` and revocable with `iam.revoke_token`.

## Request

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "harness.get",
  "params": { "uri": "harness://ops/log-analyzer" }
}
```

Methods are named `namespace.verb` across 18 namespaces: `system`, `cortex`, `agent`, `session`, `harness`, `formation`, `resource`, `provider`, `vfs`, `asset`, `sdui`, `event`, `bus`, `iam`, `org`, `vault`, `compute`, `prompt`. See the [API reference](/en/api/#rpc) for every method.

## Batching

Per JSON-RPC 2.0, send an array to batch calls; responses are matched by `id`.

## Event stream

`GET /events/sse` pushes KIEP interaction events (`notice`, `asset_ready`, `approval`, `choice`, `form_input`) and `kernel.entity.mutated`:

```js
const es = new EventSource('http://127.0.0.1:7680/events/sse')
es.addEventListener('kiep', (e) => console.log(JSON.parse(e.data)))
```

Reply to approvals, choices and forms with `event.respond`; mark as read with `event.ack_read`.

## Other HTTP endpoints

| Endpoint | Purpose |
| --- | --- |
| `GET /healthz` | Health, version, RSS |
| `GET /cortex/stream` | Cortex conversation stream |
| `ANY /mcp/v1` | MCP Streamable HTTP |
| `WS /acp/reverse` | ACP host reverse registration |
| `POST /webhooks/*` | Ingress webhook channel |
| `GET /vfs/raw` · `POST /vfs/upload` | Raw VFS streams and uploads |

## Errors

| code | Meaning |
| --- | --- |
| `-32700` | Parse error |
| `-32600` | Invalid request |
| `-32601` | Method not found |
| `-32602` | Invalid params |
| `-32603` | Internal error |

KSP extension errors (not found, permission denied, approval required…) use negative codes and carry hints in `error.data` that agents can act on.

## Try it live

The [API reference](/en/api/#sandbox) includes a read-only sandbox on the Cloudflare edge you can call directly.
