REST API Reference¶
This document describes all REST API endpoints available in AI Code UI.
Base URL¶
- Development:
http://localhost:3001/api - Production:
http://your-domain/api
Authentication¶
Most endpoints require JWT authentication.
Headers¶
Optional API Key¶
If API_KEY environment variable is set:
Auth Endpoints¶
POST /api/auth/register¶
Create a new user account.
Request:
Response:
{
"token": "jwt-token",
"user": {
"id": 1,
"username": "string",
"hasCompletedOnboarding": false
}
}
POST /api/auth/login¶
Authenticate and get JWT token.
Request:
Response:
{
"token": "jwt-token",
"user": {
"id": 1,
"username": "string",
"hasCompletedOnboarding": true,
"gitName": "string",
"gitEmail": "string"
}
}
GET /api/auth/status¶
Check authentication status.
Response:
Projects Endpoints¶
GET /api/projects¶
Get all projects with sessions.
Query Parameters:
- includeHidden (boolean) - Include hidden projects
Response:
{
"projects": [
{
"path": "/path/to/project",
"name": "project-name",
"sessions": [
{
"id": "session-id",
"provider": "claude|cursor|codex",
"lastModified": "2024-01-01T00:00:00Z",
"messageCount": 42
}
]
}
]
}
POST /api/projects¶
Add a manual project.
Request:
DELETE /api/projects/:encodedPath¶
Remove a manual project from the project list.
DELETE /api/projects/:projectName/with-sessions¶
Delete a project and all its associated sessions.
Query Parameters:
- force (boolean) - Force deletion even if project has sessions
Response:
GET /api/projects/:encodedPath/sessions¶
Get sessions for a specific project.
GET /api/projects/:encodedPath/sessions/:sessionId¶
Get session details and messages.
Response:
{
"session": {
"id": "session-id",
"provider": "claude",
"messages": [
{
"role": "user|assistant",
"content": "string",
"timestamp": "2024-01-01T00:00:00Z"
}
]
}
}
POST /api/projects/:encodedPath/sessions¶
Create a new session.
Request:
DELETE /api/projects/:encodedPath/sessions/:sessionId¶
Delete a session.
Files Endpoints¶
GET /api/files¶
List files in a directory.
Query Parameters:
- path (string, required) - Directory path
Response:
{
"files": [
{
"name": "file.js",
"path": "/path/to/file.js",
"type": "file|directory",
"size": 1234
}
]
}
GET /api/files/content¶
Get file content.
Query Parameters:
- path (string, required) - File path
Response:
PUT /api/files/content¶
Update file content.
Request:
POST /api/files/create¶
Create a new file or directory.
Request:
DELETE /api/files¶
Delete a file or directory.
Query Parameters:
- path (string, required)
Git Endpoints¶
GET /api/git/status¶
Get git status for a project.
Query Parameters:
- projectPath (string, required)
Response:
{
"branch": "main",
"staged": ["file1.js"],
"modified": ["file2.js"],
"untracked": ["file3.js"],
"ahead": 0,
"behind": 0
}
POST /api/git/stage¶
Stage files for commit.
Request:
POST /api/git/unstage¶
Unstage files.
Request:
POST /api/git/commit¶
Create a commit.
Request:
POST /api/git/push¶
Push to remote.
Request:
POST /api/git/pull¶
Pull from remote.
Request:
GET /api/git/branches¶
Get branches.
Query Parameters:
- projectPath (string, required)
Response:
POST /api/git/checkout¶
Checkout a branch.
Request:
GET /api/git/diff¶
Get diff for a file.
Query Parameters:
- projectPath (string, required)
- file (string, required)
- staged (boolean) - Get staged diff
Response:
GET /api/git/log¶
Get commit history.
Query Parameters:
- projectPath (string, required)
- limit (number) - Number of commits
Response:
{
"commits": [
{
"hash": "abc123",
"message": "commit message",
"author": "name",
"date": "2024-01-01T00:00:00Z"
}
]
}
Settings Endpoints¶
GET /api/settings¶
Get user settings.
Response:
{
"theme": "dark|light|system",
"defaultProvider": "claude|cursor|codex",
"gitName": "string",
"gitEmail": "string"
}
PUT /api/settings¶
Update user settings.
Request:
PUT /api/settings/git¶
Update git configuration.
Request:
User Endpoints¶
GET /api/user/profile¶
Get current user profile.
Response:
{
"id": 1,
"username": "string",
"gitName": "string",
"gitEmail": "string",
"hasCompletedOnboarding": true,
"createdAt": "2024-01-01T00:00:00Z"
}
PUT /api/user/profile¶
Update user profile.
Request:
PUT /api/user/onboarding¶
Complete onboarding.
Request:
API Keys Endpoints¶
GET /api/keys¶
Get user's API keys.
Response:
{
"keys": [
{
"id": 1,
"keyName": "My API Key",
"createdAt": "2024-01-01T00:00:00Z",
"lastUsed": "2024-01-02T00:00:00Z",
"isActive": true
}
]
}
POST /api/keys¶
Create a new API key.
Request:
Response:
DELETE /api/keys/:id¶
Delete an API key.
Credentials Endpoints¶
GET /api/credentials¶
Get user's stored credentials.
Response:
{
"credentials": [
{
"id": 1,
"credentialName": "GitHub Token",
"credentialType": "token",
"description": "Personal access token",
"isActive": true
}
]
}
POST /api/credentials¶
Store a new credential.
Request:
{
"credentialName": "GitHub Token",
"credentialType": "token",
"credentialValue": "ghp_xxx",
"description": "Personal access token"
}
DELETE /api/credentials/:id¶
Delete a credential.
MCP Endpoints¶
GET /api/mcp/servers¶
Get MCP server configurations.
Response:
{
"servers": [
{
"name": "server-name",
"command": "node",
"args": ["server.js"],
"enabled": true
}
]
}
POST /api/mcp/servers¶
Add MCP server configuration.
Request:
PUT /api/mcp/servers/:name¶
Update MCP server.
DELETE /api/mcp/servers/:name¶
Remove MCP server.
POST /api/mcp/servers/:name/restart¶
Restart an MCP server.
TaskMaster Endpoints¶
GET /api/taskmaster/projects¶
Get TaskMaster projects.
GET /api/taskmaster/projects/:id/tasks¶
Get tasks for a project.
POST /api/taskmaster/projects/:id/tasks¶
Create a new task.
Request:
PUT /api/taskmaster/projects/:id/tasks/:taskId¶
Update a task.
DELETE /api/taskmaster/projects/:id/tasks/:taskId¶
Delete a task.
Health Check¶
GET /api/health¶
Check server health.
Response:
Error Responses¶
All endpoints return errors in this format:
Common Error Codes¶
| Status | Code | Description |
|---|---|---|
| 400 | BAD_REQUEST | Invalid request parameters |
| 401 | UNAUTHORIZED | Missing or invalid token |
| 403 | FORBIDDEN | Insufficient permissions |
| 404 | NOT_FOUND | Resource not found |
| 500 | INTERNAL_ERROR | Server error |
Rate Limiting¶
Currently no rate limiting is implemented. Consider adding rate limiting for production deployments.
Pagination¶
Endpoints that return lists support pagination:
Query Parameters:
- page (number) - Page number (1-indexed)
- limit (number) - Items per page
Response includes: