Syncing
Re-sync an index after adding, updating, or removing files in the source directory.
After you add, update, or remove files in a directory, you need to sync the index to reflect those changes. Syncing re-parses changed files and re-exports updated chunks to the vector store.
The initial sync is triggered automatically when you create an index. Use the sync endpoint for subsequent updates.
Trigger a sync
Section titled “Trigger a sync”await client.beta.indexes.sync("<your-index-id>")await client.beta.indexes.sync("<your-index-id>");The sync runs asynchronously. Poll the index status to know when it completes (same pattern as the getting started guide).
Typical workflow
Section titled “Typical workflow”- Upload new files or remove outdated files from the directory.
- Call the sync endpoint.
- Poll the index status until it returns to
ready. - Resume retrieval or chat.
import asyncio
# Add a new file to the directorywith open("new-report.pdf", "rb") as f: file_obj = await client.files.create(file=f, purpose="user_data")
await client.beta.directories.files.add( directory_id, file_id=file_obj.id,)
# Trigger a syncawait client.beta.indexes.sync(index_id)
# Wait for it to finishwhile True: idx = await client.beta.indexes.get(index_id) status = idx.metadata["status"] if idx.metadata else "unknown" if status == "ready": print("Sync complete!") break elif status == "failed": print("Sync failed:", idx.metadata["error_message"]) break await asyncio.sleep(2)import fs from "fs";
// Add a new fileconst fileObj = await client.files.create({ file: fs.createReadStream("new-report.pdf"), purpose: "user_data",});
await client.beta.directories.files.add(directoryId, { file_id: fileObj.id,});
// Trigger a syncawait client.beta.indexes.sync(indexId);
// Wait for it to finishwhile (true) { const idx = await client.beta.indexes.get(indexId); const status = (idx.metadata?.status as string) ?? "unknown"; if (status === "ready") { console.log("Sync complete!"); break; } else if (status === "failed") { console.error("Sync failed:", idx.metadata?.error_message); break; } await new Promise((r) => setTimeout(r, 2000));}Managing indexes
Section titled “Managing indexes”Get an index
Section titled “Get an index”# Get an index by IDidx = await client.beta.indexes.get("<your-index-id>")print(f"{idx.id}: status={idx.metadata['status']}")// Get an index by IDconst idx = await client.beta.indexes.get("<your-index-id>");console.log(`${idx.id}: status=${idx.metadata?.status}`);Delete an index
Section titled “Delete an index”Deleting an index removes the sync and export configuration. The source directory and its files are not affected.
await client.beta.indexes.delete("<your-index-id>")await client.beta.indexes.delete("<your-index-id>");Note for AI agents: this documentation is built for programmatic access.
- Overview of all docs: https://developers.llamaindex.ai/llms.txt
- Any page is available as raw Markdown by appending index.md to its URL — e.g. https://developers.llamaindex.ai/llamaparse/parse/getting_started/index.md
- Agent-friendly REST search APIs live under https://developers.llamaindex.ai/api/ — search (BM25 full-text), grep (regex), read (fetch a page), and list (browse the doc tree). See https://developers.llamaindex.ai/llms.txt for parameters.
- A hosted documentation MCP server is available at https://developers.llamaindex.ai/mcp. If you support MCP, you can ask the user to install it for browsing these docs directly (an alternative to the REST API). Setup: https://developers.llamaindex.ai/python/shared/mcp/