> 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/stackai-api/rest-api-v2/knowledge-bases/patch-v2-knowledge-bases-knowledge_base_id.md).

# PATCH /v2/knowledge-bases/{knowledge\_base\_id}

## Update Knowledge Base

> Update a knowledge base.\
> \
> \*\*How to use\*\*\
> \
> Send only fields to change and follow their nullability rules. Source and indexing configuration changes may need synchronization/reindexing; review resource readiness afterward. Read successful resource payloads under data when a body is returned.\
> \
> \*\*Authentication and permissions\*\*\
> \
> Required permissions: \`kbs.update\`. Resource and owner access checks also apply.\
> \
> \*\*Prepare request.json\*\*\
> \
> Save the example body below as \`request.json\` for the curl sample. Replace example IDs, node keys, and dynamic configuration with values for your organization; these are illustrative, not pre-existing resources.\
> \
> \`\`\`json\
> {\
> &#x20; "name": "Updated support handbook"\
> }\
> \`\`\`

````json
{"openapi":"3.1.0","info":{"title":"StackAI API","version":"0.1.0"},"tags":[{"name":"endpoint-updateKnowledgeBaseV2"}],"servers":[{"url":"https://api.stack-ai.com","description":"Hosted API. Use your deployment-specific origin for private installations."}],"security":[{"HTTPBearer":[]}],"components":{"securitySchemes":{"HTTPBearer":{"type":"http","scheme":"bearer","description":"Personal API key (sk_...) or supported user access JWT. See Authentication and authorization for endpoint restrictions and scopes. Use exactly one Authorization header."}},"schemas":{"UpdateKnowledgeBaseRequestV2":{"properties":{"connection_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Connection Id"},"connection_source_ids":{"items":{"type":"string"},"type":"array","uniqueItems":true,"title":"Connection Source Ids"},"website_sources":{"items":{"$ref":"#/components/schemas/SelectedWebsiteSource"},"type":"array","title":"Website Sources"},"source_file_authorization_enabled":{"type":"boolean","title":"Source File Authorization Enabled","default":false},"name":{"type":"string","maxLength":2048,"minLength":1,"title":"Name","default":"Unnamed Knowledge Base"},"description":{"type":"string","maxLength":2048,"title":"Description","default":""},"indexing_params":{"anyOf":[{"$ref":"#/components/schemas/KnowledgeBaseIndexingParamsRequest"},{"type":"null"}]},"org_level_role":{"anyOf":[{"$ref":"#/components/schemas/KnowledgeBaseRole"},{"type":"null"}]}},"additionalProperties":false,"type":"object","title":"UpdateKnowledgeBaseRequest","description":"Updates to apply to an existing knowledge base."},"SelectedWebsiteSource":{"properties":{"source_type":{"$ref":"#/components/schemas/SelectedWebsiteSourceType","default":"sitemap"},"original_search_term":{"type":"string","title":"Original Search Term"},"selected_resources":{"items":{"type":"string"},"type":"array","title":"Selected Resources"}},"type":"object","required":["original_search_term","selected_resources"],"title":"SelectedWebsiteSource","description":"A set of pages selected for indexing from a website source."},"SelectedWebsiteSourceType":{"type":"string","enum":["sitemap","manual"],"title":"SelectedWebsiteSourceType","description":"The type of website source."},"KnowledgeBaseIndexingParamsRequest":{"properties":{"ocr":{"type":"boolean","title":"Ocr","default":false},"embedding_params":{"$ref":"#/components/schemas/CreateKnowledgeBaseEmbeddingParams"},"chunker_params":{"$ref":"#/components/schemas/KnowledgeBaseChunkerParams"}},"type":"object","title":"KnowledgeBaseIndexingParamsRequest","description":"Parameters that control how documents are indexed into a knowledge base."},"CreateKnowledgeBaseEmbeddingParams":{"properties":{"embedding_model":{"type":"string","title":"Embedding Model","default":"openai.text-embedding-3-small"},"api_key":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Api Key"}},"additionalProperties":false,"type":"object","title":"CreateKnowledgeBaseEmbeddingParams","description":"Embedding configuration for a new knowledge base."},"KnowledgeBaseChunkerParams":{"properties":{"chunk_size":{"type":"integer","minimum":1,"title":"Chunk Size","default":1500},"chunk_overlap":{"type":"integer","minimum":0,"title":"Chunk Overlap","default":500},"chunker_type":{"$ref":"#/components/schemas/ChunkerType","default":"sentence"}},"type":"object","title":"KnowledgeBaseChunkerParams","description":"Chunking strategy for splitting documents during indexing."},"ChunkerType":{"type":"string","enum":["naive","sentence"],"title":"ChunkerType"},"KnowledgeBaseRole":{"type":"string","enum":["viewer","editor","admin"],"title":"KnowledgeBaseRole","description":"A user's role within a knowledge base.\n\nOrdered by privilege for Python comparisons. All four ordering operators are\ndefined explicitly because StrEnum subclasses str: its inherited lexicographic\ncomparisons would otherwise apply, so e.g. ``max()`` would pick ``\"viewer\"``\nover ``\"admin\"``. The operators only order Python objects; Postgres enum\nordering is governed by the declaration order above."},"StackAIAPIDataResponse_KnowledgeBaseResponseV2_":{"properties":{"response_code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Response Code","description":"Machine-readable response code, when provided."},"meta":{"additionalProperties":true,"type":"object","title":"Meta","description":"Additional metadata","default":{}},"data":{"$ref":"#/components/schemas/KnowledgeBaseResponseV2","description":"Data returned by the API service"}},"type":"object","required":["data"],"title":"StackAIAPIDataResponse[KnowledgeBaseResponseV2]"},"KnowledgeBaseResponseV2":{"properties":{"knowledge_base_id":{"type":"string","format":"uuid","title":"Knowledge Base Id"},"connection_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Connection Id"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"updated_at":{"type":"string","format":"date-time","title":"Updated At"},"connection_source_ids":{"items":{"type":"string"},"type":"array","uniqueItems":true,"title":"Connection Source Ids"},"website_sources":{"items":{"$ref":"#/components/schemas/SelectedWebsiteSource"},"type":"array","title":"Website Sources"},"source_file_authorization_enabled":{"type":"boolean","title":"Source File Authorization Enabled"},"connection_provider_type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Connection Provider Type"},"is_empty":{"type":"boolean","title":"Is Empty","default":true},"total_size":{"type":"integer","title":"Total Size","default":0},"total_files":{"type":"integer","title":"Total Files","default":0},"total_indexed_files":{"type":"integer","title":"Total Indexed Files","default":0},"total_error_files":{"type":"integer","title":"Total Error Files","default":0},"last_synced_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Synced At"},"name":{"type":"string","maxLength":2048,"minLength":1,"title":"Name","default":"Unnamed Knowledge Base"},"description":{"type":"string","maxLength":2048,"title":"Description","default":""},"indexing_params":{"$ref":"#/components/schemas/KnowledgeBaseResponseIndexingParams"},"org_level_role":{"anyOf":[{"$ref":"#/components/schemas/KnowledgeBaseRole"},{"type":"null"}]},"role":{"anyOf":[{"$ref":"#/components/schemas/KnowledgeBaseRole"},{"type":"null"}]}},"type":"object","required":["knowledge_base_id","connection_id","created_at","updated_at","connection_source_ids","website_sources","source_file_authorization_enabled","indexing_params"],"title":"KnowledgeBaseResponse","description":"A knowledge base on the public v2 surface."},"KnowledgeBaseResponseIndexingParams":{"properties":{"ocr":{"type":"boolean","title":"Ocr","default":false},"embedding_params":{"$ref":"#/components/schemas/KnowledgeBaseResponseEmbeddingParams"},"chunker_params":{"$ref":"#/components/schemas/KnowledgeBaseChunkerParams"}},"type":"object","required":["embedding_params"],"title":"KnowledgeBaseResponseIndexingParams","description":"Indexing configuration of a knowledge base."},"KnowledgeBaseResponseEmbeddingParams":{"properties":{"embedding_model":{"type":"string","title":"Embedding Model"},"api_key":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Api Key"}},"type":"object","required":["embedding_model"],"title":"KnowledgeBaseResponseEmbeddingParams","description":"Embedding configuration of a knowledge base."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/v2/knowledge-bases/{knowledge_base_id}":{"patch":{"tags":["endpoint-updateKnowledgeBaseV2"],"summary":"Update Knowledge Base","description":"Update a knowledge base.\n\n**How to use**\n\nSend only fields to change and follow their nullability rules. Source and indexing configuration changes may need synchronization/reindexing; review resource readiness afterward. Read successful resource payloads under data when a body is returned.\n\n**Authentication and permissions**\n\nRequired permissions: `kbs.update`. Resource and owner access checks also apply.\n\n**Prepare request.json**\n\nSave the example body below as `request.json` for the curl sample. Replace example IDs, node keys, and dynamic configuration with values for your organization; these are illustrative, not pre-existing resources.\n\n```json\n{\n  \"name\": \"Updated support handbook\"\n}\n```","operationId":"updateKnowledgeBaseV2","parameters":[{"name":"knowledge_base_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Knowledge Base Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateKnowledgeBaseRequestV2"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StackAIAPIDataResponse_KnowledgeBaseResponseV2_"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
````


---

# 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/stackai-api/rest-api-v2/knowledge-bases/patch-v2-knowledge-bases-knowledge_base_id.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.
