MisarMisar Docs
MisarMailMisarBlogMisarReachMisarPostMisarDevMisarCoderMisarSEOMisar PlatformMisar SSO
API Reference

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

POST/rag/index

Chunks and embeds a batch of files.

Request body

workspace_pathstringbodyrequired

Absolute path of the workspace on the client machine. Used to derive the workspace id.

filesArray<{path, content}>bodyrequired

Files to index. At most 200 per request.

workspace_namestringbody

Human-readable workspace name.

backgroundbooleanbodydefault: false

Queue the work instead of blocking. The response is then just an acknowledgement.

Response fields

statusstring

ok for a synchronous run, queued when background was true.

workspace_idstring

The derived workspace id.

chunksnumber

Chunks produced. Synchronous runs only.

embeddednumber

Chunks embedded. Synchronous runs only.

filesnumber

Files processed. Synchronous runs only.

Request
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 = …" }]
  }'
200 — Indexed
{
  "status": "ok",
  "workspace_id": "ws_4c1a…",
  "chunks": 128,
  "embedded": 128,
  "files": 1
}
200 — Queued
{ "status": "queued", "workspace_id": "ws_4c1a…" }

Limits

LimitValue
Files per request200
File content size512 KB each
Chunks per workspace10,000

Status codes

CodeMeaning
200Indexed or queued
400Too many files, or one or more files exceed the size cap. The message names up to five offending paths.
401Missing authorization or Invalid API key
429Workspace chunk limit reached. Delete old files or contact support.
500Indexing failed
503RAG is unavailable — the server is not connected to a database

Query

POST/rag/query

Searches an indexed workspace.

Request body

workspace_pathstringbodyrequired

Same path you indexed under.

querystringbodyrequired

Natural-language or code query.

knumberbodydefault: 10

Results to return, between 1 and 50.

modestringbodydefault: hybrid

hybrid, vector, or lexical. An unrecognised value silently falls back to hybrid.

Response fields

statusstring

ok.

workspace_idstring

The derived workspace id.

modestring

The mode that actually executed — not necessarily the one you asked for.

query_rewrittenstring

The query after rewriting.

query_typestring

Classified 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.

Request
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"
  }'
200 — OK
{
  "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

CodeMeaning
200Results returned
401Missing authorization or Invalid API key
422k outside 1–50, or a missing required field
500Query failed
504Query timed out

Status

POST/rag/status

Index statistics for a workspace. Use it to decide whether a re-index is needed before querying.

Request body

workspace_pathstringbodyrequired

Absolute path of the workspace on the client machine.

Response fields

statusstring

ok.

workspace_idstring

The derived workspace id.

total_chunksnumber

Chunks stored. Compare against the 10,000 ceiling.

embedded_chunksnumber

Chunks with embeddings. Below total_chunks means vector search is incomplete.

total_filesnumber

Files represented in the index.

Request
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" }'
200 — OK
{
  "status": "ok",
  "workspace_id": "ws_4c1a…",
  "total_chunks": 128,
  "embedded_chunks": 128,
  "total_files": 1
}

Status codes

CodeMeaning
200Statistics returned
401Missing authorization or Invalid API key
503RAG 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.