Skip to main content
For the complete documentation index for agents and LLMs, see llms.txt.

Filter Files to Index with the REST API

Choose which files an index processes by setting a file name prefix filter

with the REST API. Only matching files are indexed.


About This Task​

You set the filters with the Update Index endpoint. You can update the filters only while the index is disabled. Changing a filter doesn't re-index files that were already indexed. For more background, see Choose Files to Index.

Prerequisites​

  • You need an API key. For details, see Generate API Keys.
  • You need a disabled index.

Set a File Name Prefix Filter​

Pass a comma-separated list of prefixes in file_name_prefix_filter. A file is indexed if its name starts with any of the prefixes. The trailing * is optional: docs/ and docs/* both match names that start with docs/.

To index only files whose names start with legal or contracts/, send this request:

curl --request PATCH \
--url https://api.cloud.deepset.ai/api/v1/workspaces/<YOUR_WORKSPACE>/indexes/<INDEX_NAME> \
--header 'accept: application/json' \
--header 'authorization: Bearer <YOUR_API_KEY>' \
--header 'content-type: application/json' \
--data '
{
"file_name_prefix_filter": "legal*,contracts/"
}
'

Clear the File Name Prefix Filter​

To remove the prefix filter, set file_name_prefix_filter to null:

curl --request PATCH \
--url https://api.cloud.deepset.ai/api/v1/workspaces/<YOUR_WORKSPACE>/indexes/<INDEX_NAME> \
--header 'accept: application/json' \
--header 'authorization: Bearer <YOUR_API_KEY>' \
--header 'content-type: application/json' \
--data '{"file_name_prefix_filter": null}'