> ## Documentation Index
> Fetch the complete documentation index at: https://docs.voiceflow.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Knowledge base API

> Manage your agent's knowledge base documents programmatically

The Knowledge base API gives you programmatic access to the documents that power your agent's knowledge base. YYou can use it to [create](/api-reference/kbpublicapidocument/create-document), [retrieve](/api-reference/kbpublicapidocument/get-document), [update](/api-reference/kbpublicapidocument/update-chunks-metadata), and [delete](/api-reference/kbpublicapidocument/delete-document) documents, as well as manage their metadata and individual chunks.

## Endpoints

| Endpoint                                                                                                                                                   | Description                                                                                                    |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| **Document**                                                                                                                                               |                                                                                                                |
| <Badge color="green" size="sm">GET</Badge>[**Search documents**](/api-reference/kbpublicapidocument/search-documents)                                      | Retrieve all documents in a project, or filter by type, page, and limit.                                       |
| <Badge color="green" size="sm">GET</Badge>[**Get document**](/api-reference/kbpublicapidocument/get-document)                                              | Fetch a single document by ID, including its chunks and metadata.                                              |
| <Badge color="blue" size="sm">POST</Badge>[**Create document**](/api-reference/kbpublicapidocument/create-document)                                        | Add a new document to the knowledge base from a URL or integration source.                                     |
| <Badge color="blue" size="sm">POST</Badge>[**Upload table document**](/api-reference/kbpublicapidocument/upload-table-document)                            | Upload structured table data as a knowledge base document, with optional chunking and LLM processing settings. |
| <Badge color="yellow" size="sm">PUT</Badge>[**Replace document**](/api-reference/kbpublicapidocument/replace-document)                                     | Replace an existing document's source and metadata entirely.                                                   |
| <Badge color="orange" size="sm">PATCH</Badge>[**Update chunk metadata**](/api-reference/kbpublicapidocument/update-chunks-metadata)                        | Update the metadata on a specific chunk within a document.                                                     |
| <Badge color="orange" size="sm">PATCH</Badge>[**Update chunk metadata by chunk ID**](/api-reference/kbpublicapidocument/update-chunk-metadata-by-chunk-id) | Update the metadata associated with the specified document chunk                                               |
| <Badge color="red" size="sm">DEL</Badge>[**Delete document**](/api-reference/kbpublicapidocument/delete-document)                                          | Permanently remove a document from the knowledge base by ID.                                                   |

## Documents

Documents are the content sources your agent draws from when answering questions. Each document has a type — URL, PDF, DOCX, plain text, CSV, XLSX, or table — and is processed into chunks that get indexed for retrieval. You can [create documents](/api-reference/kbpublicapidocument/create-document) from a URL or external integration, [upload structured table data](/api-reference/kbpublicapidocument/upload-table-document) directly, or [replace](/api-reference/kbpublicapidocument/replace-document) an existing document entirely when its source changes. URL documents support a `refreshRate` setting (`daily`, `weekly`, `monthly`, or `never`) that controls how often Voiceflow re-fetches and re-indexes the content.

## Chunks and metadata

When a document is processed, it's split into chunks, smaller segments of content that are individually indexed and retrieved during conversations. You can [update the metadata on a specific chunk](/api-reference/kbpublicapidocument/update-chunks-metadata) to add context that improves retrieval accuracy without modifying the document itself.

## Knowledge base and environments

The knowledge base is project-wide: every [environment](/documentation/deploy/environments) in the project points at the same set of documents, and editing a document's content affects all of them. Individual environments hold their own pointers into that shared set, so you can add a document from a non-Main environment and only that environment will see it until the environment is merged into Main.

Knowledge base API endpoints accept an optional environment alias parameter. When provided, the request targets the document pointers for that environment.
