Symbols API
Index and search workspace symbols — functions, classes, variables, and imports — for fast navigation and cross-reference analysis.
Overview
The Symbols API maintains a structured index of named symbols across your workspace. The agent uses it to locate definitions, find all references, and understand cross-file dependencies without reading every file on each turn.
Index Symbols
/symbols/indexParse files and index their named symbols into a workspace. Symbol indexing is language-aware — the parser extracts structured metadata rather than treating code as plain text.
Request body
workspace_idstringbodyrequiredWorkspace to index into.
filesarraybodyrequiredFiles to parse. Each item has path and content.
Response fields
symbols_indexednumberNumber of symbols indexed.
files_processednumberNumber of files processed.
duration_msnumberIndexing duration in milliseconds.
POST /symbols/index
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"workspace_id": "my-project",
"files": [
{
"path": "src/lib/auth.ts",
"content": "export function validateToken(token: string): boolean { ... }"
}
]
}{
"symbols_indexed": 128,
"files_processed": 12,
"duration_ms": 87
}Symbol indexing is language-aware. The parser extracts structured metadata (name, kind, signature, location) rather than treating code as plain text.
Search Symbols
/symbols/searchSearch indexed symbols by name substring or pattern, optionally filtered by type.
Query parameters
qstringqueryrequiredSearch query (name substring or pattern).
typestringquerydefault: allFilter by symbol type: function, class, variable, import.
limitnumberquerydefault: 20Maximum results to return.
workspace_idstringqueryScope search to a specific workspace.
Response fields
symbolsarrayMatching symbols. Each includes name, kind, path, start_line, end_line, signature, and exported.
totalnumberTotal number of matches.
query_msnumberQuery duration in milliseconds.
GET /symbols/search?q=validateToken&type=function&limit=20
Authorization: Bearer YOUR_API_KEY
{
"symbols": [
{
"name": "validateToken",
"kind": "function",
"path": "src/lib/auth.ts",
"start_line": 14,
"end_line": 28,
"signature": "function validateToken(token: string): boolean",
"exported": true
}
],
"total": 1,
"query_ms": 4
}Symbol Kinds
| Kind | Examples |
|---|---|
function | Functions, methods, arrow functions, lambdas |
class | Classes, abstract classes, interfaces, structs |
variable | Constants, let/var declarations, module-level bindings |
import | Import statements, require calls, use declarations |
Find References
/symbols/refsFind all references to a symbol by exact name, along with its definition.
Query parameters
namestringqueryrequiredExact symbol name to find references for.
workspace_idstringqueryScope to a specific workspace.
Response fields
symbolstringThe symbol name that was searched.
definitionobjectThe symbol definition, including path and start_line.
referencesarrayReference sites. Each includes path, line, and context.
reference_countnumberTotal number of references found.
GET /symbols/refs?name=validateToken&workspace_id=my-project
Authorization: Bearer YOUR_API_KEY
{
"symbol": "validateToken",
"definition": {
"path": "src/lib/auth.ts",
"start_line": 14
},
"references": [
{ "path": "src/api/session.ts", "line": 42, "context": "if (!validateToken(req.token)) {" },
{ "path": "src/middleware.ts", "line": 8, "context": "const valid = validateToken(token);" }
],
"reference_count": 2
}Database Stats
/symbols/statsReturn symbol index statistics for a workspace.
Query parameters
workspace_idstringqueryWorkspace to report on.
Response fields
workspace_idstringThe workspace identifier.
total_symbolsnumberTotal number of indexed symbols.
by_kindobjectCounts per symbol kind: function, class, variable, import.
files_indexednumberNumber of files indexed.
last_indexedstringISO-8601 timestamp of the last indexing operation.
GET /symbols/stats?workspace_id=my-project
Authorization: Bearer YOUR_API_KEY
{
"workspace_id": "my-project",
"total_symbols": 2847,
"by_kind": {
"function": 1203,
"class": 284,
"variable": 1190,
"import": 170
},
"files_indexed": 94,
"last_indexed": "2026-03-21T14:32:00Z"
}Use /symbols/refs to safely understand the blast radius before the agent renames or refactors a symbol. A symbol with many references warrants a careful, multi-file edit approach.