Skip to content
nikcli
Docs
Documentation

API Reference

Every HTTP endpoint the nikcli server exposes — 349 operations across 290 paths, generated from the server's own OpenAPI document.

Overview

The nikcli server is a single Effect HttpApi. Every endpoint on this page is declared as a typed HttpApiEndpoint with schema-checked request and response bodies, so the reference below, the generated SDK and the running server all come from the same declaration — not from three copies of it that drift.

Surface

349 operations

Across 290 paths and 34 resource groups.

Types

616 schemas

Request and response shapes, each reachable from the endpoints that use it.

Contract

OpenAPI 3.1.0

Emitted by nikcli generate from the composed API, then consumed by the SDK generator and by this page.

Clients

One surface

The CLI, TUI, web app, desktop app and mobile app all talk to these same routes.

This page is generated; /docs/server-api is written

Read Server & API for how the server is built — the request pipeline, the auth layers, why some paths are raw handlers instead of typed endpoints. Read this section for the endpoints themselves.

Base URL

There is no hosted nikcli API: the server runs on your machine, or on a machine you control. Start one and the base URL is whatever it binds to.

Terminal
bash
# loopback, no password needed
nikcli serve --hostname 127.0.0.1 --port 4096

# reachable from the network — set a password first
NIKCLI_SERVER_PASSWORD=secret \
  nikcli serve --hostname 0.0.0.0 --port 4096

Server.listen() falls back to an ephemeral port rather than failing when the requested one is taken, so read the URL the command prints instead of assuming 4096.

The TUI's server is not an HTTP server

Inside the terminal UI, sdk.url is the synthetic origin http://nikcli.local and requests are dispatched in process. Use sdk.client.* there; a hand-built fetch() against that host fails DNS resolution silently.

Authentication

Four credential types resolve to one principal before any route runs. Which one you use depends on how the server was started; all of them are accepted on every non-public route.

SchemeSent asUsed by
bearerAuth Authorization: Bearer <token> Mobile pairing tokens and nku_ account tokens.
auth_token ?token=<token> The same tokens, for clients that cannot set headers — EventSource, mostly.
basicAuth Username and password NIKCLI_SERVER_PASSWORD, with the username defaulting to nikcli.
Tailscale identity Tailscale-User-Login Trusted only on a loopback listener with NIKCLI_SERVER_TAILSCALE_AUTH set.
Terminal
bash
curl -s http://127.0.0.1:4096/session \
  -H "Authorization: Bearer $NIKCLI_TOKEN"

curl -s -u nikcli:$NIKCLI_SERVER_PASSWORD \
  http://127.0.0.1:4096/session

The share routes — /s/:shareID, /share/:shareID and /api/share/:shareID — answer before the auth check, and /user/login, /user/register and /user/status are public so an account can be created in the first place.

Choosing an instance

One server hosts many project instances. Every endpoint below accepts directory and workspace query parameters that decide which project handles the request; the same values can travel as x-nikcli-directory and x-nikcli-workspace headers instead.

Terminal
bash
curl -s "http://127.0.0.1:4096/session?directory=/Users/me/project" \
  -H "Authorization: Bearer $NIKCLI_TOKEN"

curl -s http://127.0.0.1:4096/session \
  -H "x-nikcli-directory: /Users/me/project" \
  -H "Authorization: Bearer $NIKCLI_TOKEN"

With neither set, a /session/:sessionID/… path recovers the directory from the session itself, and everything else falls back to the server's working directory. The /global, /user and /account roots never bind a directory at all.

Why those parameters appear on every operation

Instance selection is transport middleware rather than endpoint input, so the generator adds directory and workspace to each operation when it writes the OpenAPI document. They are optional everywhere.

Conventions

  • JSON in, JSON out. Request and response bodies are application/json unless an operation says otherwise.
  • Operation ids are dotted. session.prompt, mobile.git.commit, experimental.workspace.warp. They map to the namespaced methods on the generated client — session.prompt is client.session.prompt — with a handful renamed where the dotted id would collide.
  • Errors are typed too. A failure schema such as ConfigUpdateError or ProviderAuthError is declared on the endpoint and encoded in the response, rather than collapsing into a bare 500.
  • Schema names ending in _2 are not duplicates. The OpenAPI emitter disambiguates same-named schemas declared by different groups; the shapes differ.

Streaming

The long-lived paths cannot round-trip through a response schema, so they are served as raw handlers ahead of the typed bridge — while still being declared in the API, which is why they appear in this reference at all.

PathShapeCarries
GET /eventSSEEvery event for the resolved instance.
GET /global/eventSSEEvery event across every instance the server hosts.
GET /sync/streamSSESync events; the one /sync/ path served instance-less.
GET /session/:id/v2/eventsSSEEntry-level events for one session.
POST /session/:id/messageStreamed bodyAssistant output as it is produced.
GET /pty/:ptyID/connectWebSocket upgradeTerminal input and output.
Terminal
bash
curl -N "http://127.0.0.1:4096/event?token=$NIKCLI_TOKEN"

Clients

@nikcli-ai/sdk/httpapi is generated from this same document, so every operation id below is a typed method on the client. Reach for it before hand-writing requests.

@nikcli-ai/sdk/httpapi
ts
import { createNikcliClient } from "@nikcli-ai/sdk/httpapi"

const client = createNikcliClient({
  baseUrl: "http://127.0.0.1:4096",
  directory: "/Users/me/project",
})

// calls resolve with { data, error } unless throwOnError is set
const { data: sessions } = await client.session.list()
const { data: session } = await client.session.create({ title: "from the SDK" })

For code running inside the nikcli process — plugins, tools, the TUI — the embedded SDK binds the same client to the in-process server instead of a socket.

Resources

349 operations, grouped the way the server declares them. The mobile surface is split across five pages because it is a third of the API on its own.

Core

11 endpoints

Core

Instance lifecycle, resolved paths, version control status and apply, and the registries of commands, agents, skills, language servers and formatters.

Open reference →
42 endpoints

Sessions

The session lifecycle: create, fork, revert, share and delete sessions, read messages and parts, inspect todos, diffs, context and goals, and drive background delegations and monitors.

Open reference →
2 endpoints

Prompting

The two entry points that send a prompt to a session: the synchronous call that returns the assistant message, and the async call that returns immediately and streams over the event feed.

Open reference →
2 endpoints

Events

Server-sent event feeds. One feed is scoped to the resolved instance, the other spans every instance the server hosts.

Open reference →
7 endpoints

Files & Search

Reading and writing files in the resolved project, listing a directory, reading the working-tree status, and the three search endpoints behind text, filename and symbol lookup.

Open reference →
7 endpoints

Projects

Project registry: the known projects, the one the current request resolved to, the directories inside it, and the project-copy lifecycle.

Open reference →
13 endpoints

Tools & Worktrees

Experimental surface: the tool registry, the resource list, plain git worktrees, and the managed worktrees that carry parent/child links.

Open reference →
11 endpoints

Workspaces

Workspace contexts — create, list, restore and remove them, read their status and event feed, and warp a session from one workspace into another.

Open reference →
10 endpoints

Configuration

Read and patch the merged nikcli config, reload it from disk, resolve the provider table, and manage MCP server entries and config profiles.

Open reference →
8 endpoints

Providers & Auth

Model providers and the credentials behind them: list providers and their auth state, set or remove an API key, and run the OAuth authorize/callback pair.

Open reference →
4 endpoints

Connectors

Connector status, per-connector credentials, and cache invalidation.

Open reference →
9 endpoints

MCP

Model Context Protocol servers: status, adding a server, connecting and disconnecting it, toggling it, and the OAuth flow for servers that need one.

Open reference →
3 endpoints

Permissions

Pending permission requests and the reply that approves or denies one.

Open reference →
3 endpoints

Questions

Questions an agent has asked the user, and the reply or rejection that unblocks it.

Open reference →
14 endpoints

Loops

Loop definitions and their runs: list, upsert, generate from a description, toggle, run, pause, resume and abort, plus the run history.

Open reference →
13 endpoints

Missions

Mission definitions, their feature list, and the execution lifecycle — start, pause, cancel — along with recent executions.

Open reference →
2 endpoints

Brain

Background learning status and the manual trigger that forces a pass.

Open reference →
6 endpoints

Profile

The declared user profile and the habits the Brain learned, plus the preview of what actually reaches the system prompt.

Open reference →
6 endpoints

Analytics

Usage rollups: global and daily totals, per-session detail, the session list that backs the project breakdown, the leaderboard, and the combined data payload.

Open reference →
9 endpoints

Sync

Event-sourced sync: push events, read the outbox and snapshots, stream changes, and manage the connection and drain.

Open reference →
6 endpoints

Terminals

Pseudo-terminal sessions — create, resize, remove, and the upgrade endpoint that attaches to one.

Open reference →
14 endpoints

TUI Control

The control channel a running terminal UI exposes: append or submit a prompt, open a dialog, execute a command, show a toast, and the request/response pair behind remote control.

Open reference →
3 endpoints

Chatbots

Registered chat bots and the start/stop control for each one.

Open reference →
4 endpoints

Discord

Discord integration status, first-time setup, and the start/stop control.

Open reference →
1 endpoints

Voice

Audio transcription for voice input.

Open reference →
3 endpoints

Skills & Logs

Creating and deleting skills, and the log sink clients write into.

Open reference →
6 endpoints

Accounts & Users

The nikcli account behind a server (login and its completion step) and the local UserDB records the server owns.

Open reference →
4 endpoints

Sharing

Public read endpoints for a shared session, in both the page and JSON forms.

Open reference →
3 endpoints

Health & Doctor

Server health, global dispose, and the doctor report that checks the install end to end.

Open reference →

Mobile

The OpenAPI document

The document behind this reference is served from this site and checked into the repository at packages/sdk/openapi.json. Point a generator at it to build a client in any language.

Terminal
bash
curl -s https://nikcli-ai.dev/docs/api/openapi.json -o nikcli-openapi.json

# or regenerate it from a checkout
bun run script/generate.ts

Download the OpenAPI document · OpenAPI 3.1.0, 290 paths, 616 schemas.