Workspace API
Canonical reference: docs/api-reference.md (generated endpoint directory) — this page is a task-oriented summary.
The workspace API provides file operations for managing files within the configured workspace root directory.
All paths are relative to the workspace root. Path traversal (..), absolute paths, URI-style paths (://), and symlinks are rejected (403). Read and search require the workspace:read permission (or admin); write and edit are admin-only.
Read File
POST /api/v1/workspace/read
{ "path": "src/main.erl" }
Response:
{
"path": "src/main.erl",
"content": "-module(main).\n",
"size": 15
}
Reads are open-then-verify (the opened file’s inode must match the validated leaf). Errors: 400 path is required / path is a directory, 403 permission denied or path-validation refusals, 404 file not found, 413 when the file exceeds the 10 MB read cap (body_too_large).
Write File
POST /api/v1/workspace/write
Atomic write (write to temp, then rename). Creates parent directories automatically.
{ "path": "src/new_file.erl", "content": "-module(new_file).\n" }
Edit File
POST /api/v1/workspace/edit
Find-and-replace with exact match. Rejects if old_text appears more than once.
{
"path": "src/main.erl",
"old_text": "-module(old_name)",
"new_text": "-module(new_name)"
}
Response on multiple matches (or no match — old_text not found in file):
{ "error": "multiple matches", "matches": 3 }
Both mismatch classes answer 409 (Zerg handler responses; the body shown is the handler’s structured conflict payload).
Search Files
POST /api/v1/workspace/search
{ "query": "*.erl", "max_results": 50 }
query is a glob (required); max_results defaults to 50 and is capped at
1000. Results outside the workspace root are dropped and counted in the
omitted field.
Response:
{
"results": [
{ "path": "src/main.erl", "size": 256, "modified": "2026-05-18T14:30:45Z" }
],
"count": 1,
"omitted": 0
}
List Files
GET /api/v1/workspace/list?path=.&recursive=true
(POST to the same path is also accepted.) Recursive listings walk four
levels deep; the listing is capped at 1000 entries.
Response:
{
"path": ".",
"entries": [
{ "path": "src/main.erl", "type": "file", "size": 256, "modified": "2026-05-18T14:30:45Z" },
{ "path": "src", "type": "directory", "size": 4096, "modified": "2026-05-18T12:00:00Z" }
],
"count": 2
}