API

API Reference

Integrate ALIN into your workflow with the REST API.

Authentication

All API requests require a JWT token in the Authorization header:

Authorization: Bearer <your-token>

Obtain a token via POST /api/auth/login or POST /api/auth/signup. Tokens expire after 7 days.

Auth Endpoints

POST /api/auth/signup — Create account. Body: { email, password, displayName }. Returns { token, user }.

POST /api/auth/login — Sign in. Body: { email, password }. Returns { token, user }.

GET /api/auth/me — Get current user profile. Requires auth.

PATCH /api/auth/profile — Update profile. Body: { displayName?, email? }. Requires auth.

POST /api/auth/change-password — Change password. Body: { oldPassword, newPassword }. Requires auth.

Chat Streaming

POST /api/chat/stream — Stream an AI response via SSE. Requires auth + plan check. Body: { messages, model, provider, system?, tools?, thinking?, thinkingBudget?, maxTokens? }.

SSE events: start, text_delta, thinking_start, thinking_delta, tool_use, usage, done, error.

POST /api/chat/continue — Continue after tool results. Same format as /stream.

Conversations

GET /api/conversations — List all conversations.

POST /api/conversations — Create conversation. Body: { id, title?, model? }.

GET /api/conversations/:id — Get conversation with messages.

PATCH /api/conversations/:id — Update conversation metadata.

DELETE /api/conversations/:id — Delete conversation and messages.

Messages

POST /api/messages — Create message. Body: { id, conversationId, role, content, model?, tokens?, thinkingContent? }.

PATCH /api/messages/:id — Update message.

DELETE /api/messages/:id — Delete message.

TBWO

GET /api/tbwos — List all TBWOs.

POST /api/tbwos — Create TBWO. Requires Pro plan.

GET /api/tbwos/:id — Get TBWO details.

PATCH /api/tbwos/:id — Update TBWO.

POST /api/tbwo/:id/receipts — Add receipt to TBWO.

Memory

GET /api/memories — List memory entries.

POST /api/memories — Create memory entry.

DELETE /api/memories/:id — Delete memory entry.

Self-Model

POST /api/self-model/outcomes — Record execution outcome.

GET /api/self-model/outcomes — List outcomes. Query: ?type=&limit=.

POST /api/self-model/tool-reliability — Record tool usage.

GET /api/self-model/tool-reliability — Get tool stats.

POST /api/self-model/corrections — Record user correction.

GET /api/self-model/corrections — List corrections. Query: ?minCount=.

POST /api/self-model/layer-memory — Store layer memory.

GET /api/self-model/layer-memory — List layer memories. Query: ?layer=&limit=.

POST /api/self-model/layer-memory/prune — Remove expired memories.

File Operations (Desktop Only)

POST /api/files/read — Read file. Body: { filePath }.

POST /api/files/write — Write file. Body: { filePath, content }.

POST /api/files/list — List directory. Body: { dirPath }.

POST /api/files/scan — Scan directory tree with contents.

POST /api/files/search — Search code across files.

Code Execution (Desktop Only)

POST /api/code/execute — Run code. Body: { code, language }. Supports Python, JavaScript, shell.

System

GET /api/health — Health check.

GET /api/system/metrics — CPU, memory, GPU metrics (Desktop only).

Rate Limits

Free: 10 messages/hour, max 3 tool calls/message. Pro: unlimited. Enterprise: unlimited with custom routing. Rate limit headers: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset.