> For the complete documentation index, see [llms.txt](https://docs.stackai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stackai.com/technical-reference/files-knowledge-and-retrieval/file-and-folder-selection.md).

# File and Folder Selection

Source selection narrows which files and folders a knowledge-base query considers. Use it when a workflow should search a specific part of a collection.

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSQ1Sgy933krTyK0S4JpP%2Fuploads%2F6RlRF9pHsxRQLrgrluqM%2FG037A.mp4?alt=media&token=da592b44-fc72-4fa9-a921-8e34eaaafabf>" %}

## Before you begin

Access to the knowledge base and the files or folders to select.

## Key concepts

| Term               | Definition                                                                                                                                |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------- |
| Folder             | A collection used to organize projects. A folder can also have access settings. Review effective access when sharing or moving a project. |
| Filter             | A condition that narrows the records eligible for an operation. A filter can exclude relevant content before ranking occurs.              |
| Source permissions | Access rules for the original documents or records. Knowledge-base sharing does not necessarily grant access to every source.             |

## Configuration options

| Option           | Purpose                                        | Behavior                                                                            |
| ---------------- | ---------------------------------------------- | ----------------------------------------------------------------------------------- |
| Source selection | The files or folders included in an operation. | An empty optional selection can mean the whole knowledge base rather than no files. |

## Select files and folders

1. Open the source selection for the retrieval step.
2. Select the intended files or folders and inspect the resulting scope.

![Select the documents to include, then load the selected files.](https://content.gitbook.com/content/SQ1Sgy933krTyK0S4JpP/blobs/b0DIuirZNtgwzR0C2tWE/assets/g037a-g037a-02-selection.png)

Select the documents to include, then load the selected files.

3. Run a query and inspect the source identifiers in the returned results.

The query uses the configured source scope together with applicable filters and permissions.

## Behavior and limitations

For knowledge-base queries that use an optional file selection, leaving the selection empty can search the whole knowledge base. Select an explicit scope when you need to restrict sources. Metadata filters and access settings can narrow the results further. Selecting a folder does not grant access to its contents.

## Related resources

[Import selected Google Drive files](https://docs.stackai.com/guides-and-quickstarts/knowledge-and-retrieval/import-selected-google-drive-files.md)

[File Inputs, Supported Formats, and Size Limits](https://docs.stackai.com/technical-reference/files-knowledge-and-retrieval/file-inputs-supported-formats-and-size-limits.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stackai.com/technical-reference/files-knowledge-and-retrieval/file-and-folder-selection.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
