Skip to content
Guide
Index V2 (Beta)

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.

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

  1. Upload new files or remove outdated files from the directory.
  2. Call the sync endpoint.
  3. Poll the index status until it returns to ready.
  4. Resume retrieval or chat.
import asyncio
# Add a new file to the directory
with 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 sync
await client.beta.indexes.sync(index_id)
# Wait for it to finish
while 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)
# Get an index by ID
idx = await client.beta.indexes.get("<your-index-id>")
print(f"{idx.id}: status={idx.metadata['status']}")

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>")