RAG
Index a workspace for semantic code search and query it — /rag/index, /rag/query, /rag/status.
MisarCoder's retrieval layer indexes a workspace's files into chunks and searches them by meaning, by keyword, or by both.
Base URL: https://api.misar.io/coder. All three endpoints authenticate with Authorization: Bearer <API_KEY>.
Workspaces are derived, not created
There is no "create workspace" call. A workspace id is derived from your API token plus the workspace_path you send, so the same path under a different token is a different workspace. Send the same workspace_path on every call for a given project.
Index files
/rag/indexChunks and embeds a batch of files.
Request body
workspace_pathstringbodyrequiredAbsolute path of the workspace on the client machine. Used to derive the workspace id.
filesArray<{path, content}>bodyrequiredFiles to index. At most 200 per request.
workspace_namestringbodyHuman-readable workspace name.
backgroundbooleanbodydefault: falseQueue the work instead of blocking. The response is then just an acknowledgement.
Response fields
statusstringok for a synchronous run, queued when background was true.
workspace_idstringThe derived workspace id.
chunksnumberChunks produced. Synchronous runs only.
embeddednumberChunks embedded. Synchronous runs only.
filesnumberFiles processed. Synchronous runs only.
curl -X POST https://api.misar.io/coder/rag/index \
-H "Authorization: Bearer $MISARCODER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"workspace_path": "/Users/jane/acme-api",
"workspace_name": "acme-api",
"files": [{ "path": "src/server.ts", "content": "export const start = …" }]
}'{
"status": "ok",
"workspace_id": "ws_4c1a…",
"chunks": 128,
"embedded": 128,
"files": 1
}{ "status": "queued", "workspace_id": "ws_4c1a…" }Limits
| Limit | Value |
|---|---|
| Files per request | 200 |
| File content size | 512 KB each |
| Chunks per workspace | 10,000 |
Status codes
| Code | Meaning |
|---|---|
200 | Indexed or queued |
400 | Too many files, or one or more files exceed the size cap. The message names up to five offending paths. |
401 | Missing authorization or Invalid API key |
429 | Workspace chunk limit reached. Delete old files or contact support. |
500 | Indexing failed |
503 | RAG is unavailable — the server is not connected to a database |
Query
/rag/querySearches an indexed workspace.
Request body
workspace_pathstringbodyrequiredSame path you indexed under.
querystringbodyrequiredNatural-language or code query.
knumberbodydefault: 10Results to return, between 1 and 50.
modestringbodydefault: hybridhybrid, vector, or lexical. An unrecognised value silently falls back to hybrid.
Response fields
statusstringok.
workspace_idstringThe derived workspace id.
modestringThe mode that actually executed — not necessarily the one you asked for.
query_rewrittenstringThe query after rewriting.
query_typestringClassified query type. Hybrid mode only.
resultsobject[]Matches with file_path, symbol, content, chunk_level, start_byte, plus rank for lexical results or distance for vector results.
statsobject{ total_chunks, embedded_chunks, total_files } for the workspace.
curl -X POST https://api.misar.io/coder/rag/query \
-H "Authorization: Bearer $MISARCODER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"workspace_path": "/Users/jane/acme-api",
"query": "where is rate limiting applied",
"k": 10,
"mode": "hybrid"
}'{
"status": "ok",
"workspace_id": "ws_4c1a…",
"mode": "hybrid",
"query_rewritten": "rate limit middleware",
"query_type": "lookup",
"results": [
{
"file_path": "src/middleware/rate-limit.ts",
"symbol": "applyRateLimit",
"content": "export function applyRateLimit(…)",
"chunk_level": "function",
"start_byte": 412,
"distance": 0.18
}
],
"stats": { "total_chunks": 128, "embedded_chunks": 128, "total_files": 1 }
}`mode` in the response is what ran, not what you asked for
Requesting hybrid or vector against a workspace with no embedded chunks executes a lexical search and returns "mode": "lexical". Read the field back rather than assuming your requested mode was honoured.
Queries time out after 10 seconds. The query text is capped at 2000 characters.
Status codes
| Code | Meaning |
|---|---|
200 | Results returned |
401 | Missing authorization or Invalid API key |
422 | k outside 1–50, or a missing required field |
500 | Query failed |
504 | Query timed out |
Status
/rag/statusIndex statistics for a workspace. Use it to decide whether a re-index is needed before querying.
Request body
workspace_pathstringbodyrequiredAbsolute path of the workspace on the client machine.
Response fields
statusstringok.
workspace_idstringThe derived workspace id.
total_chunksnumberChunks stored. Compare against the 10,000 ceiling.
embedded_chunksnumberChunks with embeddings. Below total_chunks means vector search is incomplete.
total_filesnumberFiles represented in the index.
curl -X POST https://api.misar.io/coder/rag/status \
-H "Authorization: Bearer $MISARCODER_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "workspace_path": "/Users/jane/acme-api" }'{
"status": "ok",
"workspace_id": "ws_4c1a…",
"total_chunks": 128,
"embedded_chunks": 128,
"total_files": 1
}Status codes
| Code | Meaning |
|---|---|
200 | Statistics returned |
401 | Missing authorization or Invalid API key |
503 | RAG is unavailable — the server is not connected to a database |
RAG needs a database
All three endpoints return 503 when the deployment has no database configured. This is a deployment condition, not a transient fault — retrying will not help.