Skip to content

HTTP API

KodaCode embeds an HTTP server (Echo) for programmatic access. The server starts automatically on a random port (configurable via server.port).

MethodPathDescription
GET/healthHealth check (returns HTTP 200)
GET/configRuntime config (tool count, MCP status, providers)
MethodPathDescription
POST/sessionsCreate new session (accepts agent_id, model_id)
GET/sessionsList all sessions
GET/sessions/:idGet session details (includes cost)
PATCH/sessions/:idUpdate session (change agent or model)
DELETE/sessions/:idDelete session
MethodPathDescription
POST/sessions/:id/messagesSend message (supports attachments and variant)
GET/sessions/:id/messagesList messages
POST/sessions/:id/answerRespond to permission/question prompts
POST/sessions/:id/branchBranch session from a specific message
MethodPathDescription
GET/sessions/:id/streamSSE stream for real-time updates
MethodPathDescription
GET/sessions/:id/snapshotsList snapshots for a session
POST/sessions/:id/snapshots/:turn/restoreRestore workspace to a snapshot
MethodPathDescription
GET/agentsList all agents
GET/agents/:idGet agent details
POST/agentsCreate agent
PUT/agents/:idUpdate agent
DELETE/agents/:idDelete agent (built-in agents cannot be deleted)
MethodPathDescription
GET/modelsList available models from all providers
POST/models/refreshRefresh model metadata cache
MethodPathDescription
GET/settings/:keyGet a setting value
PUT/settings/:keySet a setting value

The /sessions/:id/stream endpoint delivers real-time events:

EventDescription
deltaStreaming text from the model
reasoning_deltaStreaming reasoning/thinking tokens
reasoning_doneReasoning block complete
tool_startTool execution begins
tool_input_deltaStreaming tool input (for live diff preview)
tool_outputStreaming tool output
tool_endTool execution complete
doneTurn complete (includes session cost)
errorError occurred
retryRetrying after failure
title_updatedSession title changed
compactionContext compaction triggered
user_questionPermission or question prompt for the user

Example: Create a Session and Send a Message

Section titled “Example: Create a Session and Send a Message”
Terminal window
# Create a session
SESSION=$(curl -s -X POST http://localhost:PORT/sessions \
-H "Content-Type: application/json" \
-d '{"agent_id": "engineer"}' | jq -r '.id')
# Send a message
curl -X POST http://localhost:PORT/sessions/$SESSION/messages \
-H "Content-Type: application/json" \
-d '{"content": "Explain the main function"}'
# Stream responses
curl -N http://localhost:PORT/sessions/$SESSION/stream
Terminal window
curl -X POST http://localhost:PORT/agents \
-H "Content-Type: application/json" \
-d '{
"id": "reviewer",
"name": "reviewer",
"description": "Code review agent",
"tools": ["read", "grep", "glob", "search", "lsp", "git"],
"system_prompt": "You are a careful code reviewer."
}'
Terminal window
curl -s http://localhost:PORT/models | jq '.[].id'