# Knowledge Bases

## Get Knowledge Bases

> List all available knowledge bases for the specified flow.

```json
{"openapi":"3.1.0","info":{"title":"StackAI API","version":"0.1.0"},"servers":[{"url":"https://api.stack-ai.com","description":"StackAI API Server"}],"security":[{"HTTPBearer":[]}],"components":{"securitySchemes":{},"schemas":{"PaginationDirection":{"type":"string","enum":["next","prev"],"title":"PaginationDirection","description":"Direction for cursor-based pagination."},"KnowledgeBaseResponse":{"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"},"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","description":"Total size of all the files in the KB in bytes","default":0},"total_files":{"type":"integer","title":"Total Files","description":"Total number of files in the KB","default":0},"total_indexed_files":{"type":"integer","title":"Total Indexed Files","description":"Total number of indexed files in the KB","default":0},"total_error_files":{"type":"integer","title":"Total Error Files","description":"Total number of error files in the KB","default":0},"last_synced_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Synced At","description":"Timestamp when the knowledge base was last successfully synced from its source"},"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_id":{"type":"string","title":"Org Id"},"role":{"anyOf":[{"$ref":"#/components/schemas/KnowledgeBaseRole"},{"type":"null"}]},"org_level_role":{"anyOf":[{"$ref":"#/components/schemas/KnowledgeBaseRole"},{"type":"null"}]},"user_metadata_schema":{"anyOf":[{"$ref":"#/components/schemas/MetadataSchema"},{"type":"null"}]},"dataloader_metadata_schema":{"anyOf":[{"$ref":"#/components/schemas/MetadataSchema"},{"type":"null"}]}},"type":"object","required":["knowledge_base_id","connection_id","created_at","updated_at","connection_source_ids","website_sources","indexing_params","org_id"],"title":"KnowledgeBaseResponse","description":"Knowledge base response payload for public API endpoints."},"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 class representing the selected resources to be indexed in a website knowledge base.\n\nAttributes:\n    original_search_term (str): The search term that the user did input to get the selected resources.\n        This is used by the frontend to re-create the same folder structure that was displayed when the\n        user made first selected which pages to index, so the selection can easily be edited.\n    selected_resources (list[str]): The list of resource IDs that were selected from the website source."},"SelectedWebsiteSourceType":{"type":"string","enum":["sitemap","manual"],"title":"SelectedWebsiteSourceType","description":"The type of website source."},"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 params returned by knowledge base responses."},"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 params returned by KB responses."},"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":"Public chunking params exposed by the API."},"ChunkerType":{"type":"string","enum":["naive","sentence"],"title":"ChunkerType"},"KnowledgeBaseRole":{"type":"string","enum":["viewer","editor","admin"],"title":"KnowledgeBaseRole","description":"Enumerates all the possible roles for a user in a knowledge base.\n\nAttributes\n----------\n- ADMIN: Admin permissions allow full control over the knowledge base, including deletion.\n- EDITOR: Editor permissions allow the user to modify the knowledge base, but not delete it.\n- VIEWER: Viewer permissions allow the user to view the knowledge base, but not modify it."},"MetadataSchema":{"properties":{"properties":{"patternProperties":{"^[^\\t\\n\\r\\f\\v]+$":{"anyOf":[{"$ref":"#/components/schemas/StringProperty"},{"$ref":"#/components/schemas/NumberProperty"},{"$ref":"#/components/schemas/BooleanProperty"},{"$ref":"#/components/schemas/DateProperty"},{"$ref":"#/components/schemas/StringListProperty-Output"}]}},"propertyNames":{"maxLength":64,"minLength":1},"type":"object","title":"Properties"}},"type":"object","required":["properties"],"title":"MetadataSchema"},"StringProperty":{"properties":{"type":{"type":"string","const":"string","title":"Type","default":"string"},"description":{"type":"string","maxLength":1024,"title":"Description","default":""},"order":{"type":"integer","minimum":0,"title":"Order","description":"Order of the property in the schema, used for sorting in the frontend","default":0},"subtype":{"$ref":"#/components/schemas/StringSubtypeEnum","default":"plain"}},"type":"object","title":"StringProperty"},"StringSubtypeEnum":{"type":"string","enum":["plain","email","url","phone","file_path"],"title":"StringSubtypeEnum"},"NumberProperty":{"properties":{"type":{"type":"string","const":"number","title":"Type","default":"number"},"description":{"type":"string","maxLength":1024,"title":"Description","default":""},"order":{"type":"integer","minimum":0,"title":"Order","description":"Order of the property in the schema, used for sorting in the frontend","default":0}},"type":"object","title":"NumberProperty"},"BooleanProperty":{"properties":{"type":{"type":"string","const":"boolean","title":"Type","default":"boolean"},"description":{"type":"string","maxLength":1024,"title":"Description","default":""},"order":{"type":"integer","minimum":0,"title":"Order","description":"Order of the property in the schema, used for sorting in the frontend","default":0}},"type":"object","title":"BooleanProperty"},"DateProperty":{"properties":{"type":{"type":"string","const":"date","title":"Type","default":"date"},"description":{"type":"string","maxLength":1024,"title":"Description","default":""},"order":{"type":"integer","minimum":0,"title":"Order","description":"Order of the property in the schema, used for sorting in the frontend","default":0}},"type":"object","title":"DateProperty"},"StringListProperty-Output":{"properties":{"type":{"type":"string","const":"string_list","title":"Type","default":"string_list"},"description":{"type":"string","maxLength":1024,"title":"Description","default":""},"order":{"type":"integer","minimum":0,"title":"Order","description":"Order of the property in the schema, used for sorting in the frontend","default":0},"options":{"items":{"$ref":"#/components/schemas/StringListOption"},"type":"array","title":"Options"}},"type":"object","title":"StringListProperty","description":"A property that contains a list of strings. Can be used to store tags as well."},"StringListOption":{"properties":{"id":{"type":"string","title":"Id"},"label":{"type":"string","title":"Label"},"description":{"type":"string","maxLength":1024,"title":"Description","default":""},"color":{"$ref":"#/components/schemas/StringListOptionColor","default":"gray"},"order":{"type":"integer","maximum":10000000,"minimum":0,"title":"Order","default":0}},"type":"object","required":["label"],"title":"StringListOption"},"StringListOptionColor":{"type":"string","enum":["red","green","blue","yellow","purple","gray"],"title":"StringListOptionColor","description":"Store the different colors that can be used for the string list options."},"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":{"/v1/knowledge-bases":{"get":{"tags":["Knowledge Bases"],"summary":"Get Knowledge Bases","description":"List all available knowledge bases for the specified flow.","operationId":"get_knowledge_bases_v1_knowledge_bases_get","parameters":[{"name":"cursor","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Optional identifier for the page that should be returned. If it is not provided, the first page will be returned.","title":"Cursor"},"description":"Optional identifier for the page that should be returned. If it is not provided, the first page will be returned."},{"name":"page_size","in":"query","required":false,"schema":{"type":"integer","maximum":1000,"minimum":1,"description":"Number of items to be returned in the page.","default":50,"title":"Page Size"},"description":"Number of items to be returned in the page."},{"name":"direction","in":"query","required":false,"schema":{"$ref":"#/components/schemas/PaginationDirection","description":"Direction for pagination: 'next' to advance through pages (older items), 'prev' to go back (newer items)","default":"next"},"description":"Direction for pagination: 'next' to advance through pages (older items), 'prev' to go back (newer items)"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/KnowledgeBaseResponse"},"title":"Response Get Knowledge Bases V1 Knowledge Bases Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```

## Create Knowledge Base

> Create a new knowledge base.

```json
{"openapi":"3.1.0","info":{"title":"StackAI API","version":"0.1.0"},"servers":[{"url":"https://api.stack-ai.com","description":"StackAI API Server"}],"security":[{"HTTPBearer":[]}],"components":{"securitySchemes":{},"schemas":{"CreateKnowledgeBaseRequest":{"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"},"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/KnowledgeBaseIndexingParamsRequest"},"org_level_role":{"anyOf":[{"$ref":"#/components/schemas/KnowledgeBaseRole"},{"type":"null"}]}},"additionalProperties":false,"type":"object","title":"CreateKnowledgeBaseRequest","description":"Model for FastAPI endpoints."},"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 class representing the selected resources to be indexed in a website knowledge base.\n\nAttributes:\n    original_search_term (str): The search term that the user did input to get the selected resources.\n        This is used by the frontend to re-create the same folder structure that was displayed when the\n        user made first selected which pages to index, so the selection can easily be edited.\n    selected_resources (list[str]): The list of resource IDs that were selected from the 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":"Indexing params accepted by knowledge base create and update requests."},"CreateKnowledgeBaseEmbeddingParams":{"properties":{"embedding_model":{"type":"string","title":"Embedding Model","default":"openai.text-embedding-3-large"},"api_key":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Api Key"}},"additionalProperties":false,"type":"object","title":"CreateKnowledgeBaseEmbeddingParams","description":"Embedding params accepted by create KB requests."},"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":"Public chunking params exposed by the API."},"ChunkerType":{"type":"string","enum":["naive","sentence"],"title":"ChunkerType"},"KnowledgeBaseRole":{"type":"string","enum":["viewer","editor","admin"],"title":"KnowledgeBaseRole","description":"Enumerates all the possible roles for a user in a knowledge base.\n\nAttributes\n----------\n- ADMIN: Admin permissions allow full control over the knowledge base, including deletion.\n- EDITOR: Editor permissions allow the user to modify the knowledge base, but not delete it.\n- VIEWER: Viewer permissions allow the user to view the knowledge base, but not modify it."},"KnowledgeBaseResponse":{"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"},"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","description":"Total size of all the files in the KB in bytes","default":0},"total_files":{"type":"integer","title":"Total Files","description":"Total number of files in the KB","default":0},"total_indexed_files":{"type":"integer","title":"Total Indexed Files","description":"Total number of indexed files in the KB","default":0},"total_error_files":{"type":"integer","title":"Total Error Files","description":"Total number of error files in the KB","default":0},"last_synced_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Synced At","description":"Timestamp when the knowledge base was last successfully synced from its source"},"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_id":{"type":"string","title":"Org Id"},"role":{"anyOf":[{"$ref":"#/components/schemas/KnowledgeBaseRole"},{"type":"null"}]},"org_level_role":{"anyOf":[{"$ref":"#/components/schemas/KnowledgeBaseRole"},{"type":"null"}]},"user_metadata_schema":{"anyOf":[{"$ref":"#/components/schemas/MetadataSchema"},{"type":"null"}]},"dataloader_metadata_schema":{"anyOf":[{"$ref":"#/components/schemas/MetadataSchema"},{"type":"null"}]}},"type":"object","required":["knowledge_base_id","connection_id","created_at","updated_at","connection_source_ids","website_sources","indexing_params","org_id"],"title":"KnowledgeBaseResponse","description":"Knowledge base response payload for public API endpoints."},"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 params returned by knowledge base responses."},"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 params returned by KB responses."},"MetadataSchema":{"properties":{"properties":{"patternProperties":{"^[^\\t\\n\\r\\f\\v]+$":{"anyOf":[{"$ref":"#/components/schemas/StringProperty"},{"$ref":"#/components/schemas/NumberProperty"},{"$ref":"#/components/schemas/BooleanProperty"},{"$ref":"#/components/schemas/DateProperty"},{"$ref":"#/components/schemas/StringListProperty-Output"}]}},"propertyNames":{"maxLength":64,"minLength":1},"type":"object","title":"Properties"}},"type":"object","required":["properties"],"title":"MetadataSchema"},"StringProperty":{"properties":{"type":{"type":"string","const":"string","title":"Type","default":"string"},"description":{"type":"string","maxLength":1024,"title":"Description","default":""},"order":{"type":"integer","minimum":0,"title":"Order","description":"Order of the property in the schema, used for sorting in the frontend","default":0},"subtype":{"$ref":"#/components/schemas/StringSubtypeEnum","default":"plain"}},"type":"object","title":"StringProperty"},"StringSubtypeEnum":{"type":"string","enum":["plain","email","url","phone","file_path"],"title":"StringSubtypeEnum"},"NumberProperty":{"properties":{"type":{"type":"string","const":"number","title":"Type","default":"number"},"description":{"type":"string","maxLength":1024,"title":"Description","default":""},"order":{"type":"integer","minimum":0,"title":"Order","description":"Order of the property in the schema, used for sorting in the frontend","default":0}},"type":"object","title":"NumberProperty"},"BooleanProperty":{"properties":{"type":{"type":"string","const":"boolean","title":"Type","default":"boolean"},"description":{"type":"string","maxLength":1024,"title":"Description","default":""},"order":{"type":"integer","minimum":0,"title":"Order","description":"Order of the property in the schema, used for sorting in the frontend","default":0}},"type":"object","title":"BooleanProperty"},"DateProperty":{"properties":{"type":{"type":"string","const":"date","title":"Type","default":"date"},"description":{"type":"string","maxLength":1024,"title":"Description","default":""},"order":{"type":"integer","minimum":0,"title":"Order","description":"Order of the property in the schema, used for sorting in the frontend","default":0}},"type":"object","title":"DateProperty"},"StringListProperty-Output":{"properties":{"type":{"type":"string","const":"string_list","title":"Type","default":"string_list"},"description":{"type":"string","maxLength":1024,"title":"Description","default":""},"order":{"type":"integer","minimum":0,"title":"Order","description":"Order of the property in the schema, used for sorting in the frontend","default":0},"options":{"items":{"$ref":"#/components/schemas/StringListOption"},"type":"array","title":"Options"}},"type":"object","title":"StringListProperty","description":"A property that contains a list of strings. Can be used to store tags as well."},"StringListOption":{"properties":{"id":{"type":"string","title":"Id"},"label":{"type":"string","title":"Label"},"description":{"type":"string","maxLength":1024,"title":"Description","default":""},"color":{"$ref":"#/components/schemas/StringListOptionColor","default":"gray"},"order":{"type":"integer","maximum":10000000,"minimum":0,"title":"Order","default":0}},"type":"object","required":["label"],"title":"StringListOption"},"StringListOptionColor":{"type":"string","enum":["red","green","blue","yellow","purple","gray"],"title":"StringListOptionColor","description":"Store the different colors that can be used for the string list options."},"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":{"/v1/knowledge-bases":{"post":{"tags":["Knowledge Bases"],"summary":"Create Knowledge Base","description":"Create a new knowledge base.","operationId":"create_knowledge_base_v1_knowledge_bases_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateKnowledgeBaseRequest"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeBaseResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```

## Get Knowledge Base By Id

> Get a knowledge base by its ID in the current organization.

```json
{"openapi":"3.1.0","info":{"title":"StackAI API","version":"0.1.0"},"servers":[{"url":"https://api.stack-ai.com","description":"StackAI API Server"}],"security":[{"HTTPBearer":[]}],"components":{"securitySchemes":{},"schemas":{"KnowledgeBaseResponse":{"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"},"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","description":"Total size of all the files in the KB in bytes","default":0},"total_files":{"type":"integer","title":"Total Files","description":"Total number of files in the KB","default":0},"total_indexed_files":{"type":"integer","title":"Total Indexed Files","description":"Total number of indexed files in the KB","default":0},"total_error_files":{"type":"integer","title":"Total Error Files","description":"Total number of error files in the KB","default":0},"last_synced_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Synced At","description":"Timestamp when the knowledge base was last successfully synced from its source"},"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_id":{"type":"string","title":"Org Id"},"role":{"anyOf":[{"$ref":"#/components/schemas/KnowledgeBaseRole"},{"type":"null"}]},"org_level_role":{"anyOf":[{"$ref":"#/components/schemas/KnowledgeBaseRole"},{"type":"null"}]},"user_metadata_schema":{"anyOf":[{"$ref":"#/components/schemas/MetadataSchema"},{"type":"null"}]},"dataloader_metadata_schema":{"anyOf":[{"$ref":"#/components/schemas/MetadataSchema"},{"type":"null"}]}},"type":"object","required":["knowledge_base_id","connection_id","created_at","updated_at","connection_source_ids","website_sources","indexing_params","org_id"],"title":"KnowledgeBaseResponse","description":"Knowledge base response payload for public API endpoints."},"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 class representing the selected resources to be indexed in a website knowledge base.\n\nAttributes:\n    original_search_term (str): The search term that the user did input to get the selected resources.\n        This is used by the frontend to re-create the same folder structure that was displayed when the\n        user made first selected which pages to index, so the selection can easily be edited.\n    selected_resources (list[str]): The list of resource IDs that were selected from the website source."},"SelectedWebsiteSourceType":{"type":"string","enum":["sitemap","manual"],"title":"SelectedWebsiteSourceType","description":"The type of website source."},"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 params returned by knowledge base responses."},"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 params returned by KB responses."},"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":"Public chunking params exposed by the API."},"ChunkerType":{"type":"string","enum":["naive","sentence"],"title":"ChunkerType"},"KnowledgeBaseRole":{"type":"string","enum":["viewer","editor","admin"],"title":"KnowledgeBaseRole","description":"Enumerates all the possible roles for a user in a knowledge base.\n\nAttributes\n----------\n- ADMIN: Admin permissions allow full control over the knowledge base, including deletion.\n- EDITOR: Editor permissions allow the user to modify the knowledge base, but not delete it.\n- VIEWER: Viewer permissions allow the user to view the knowledge base, but not modify it."},"MetadataSchema":{"properties":{"properties":{"patternProperties":{"^[^\\t\\n\\r\\f\\v]+$":{"anyOf":[{"$ref":"#/components/schemas/StringProperty"},{"$ref":"#/components/schemas/NumberProperty"},{"$ref":"#/components/schemas/BooleanProperty"},{"$ref":"#/components/schemas/DateProperty"},{"$ref":"#/components/schemas/StringListProperty-Output"}]}},"propertyNames":{"maxLength":64,"minLength":1},"type":"object","title":"Properties"}},"type":"object","required":["properties"],"title":"MetadataSchema"},"StringProperty":{"properties":{"type":{"type":"string","const":"string","title":"Type","default":"string"},"description":{"type":"string","maxLength":1024,"title":"Description","default":""},"order":{"type":"integer","minimum":0,"title":"Order","description":"Order of the property in the schema, used for sorting in the frontend","default":0},"subtype":{"$ref":"#/components/schemas/StringSubtypeEnum","default":"plain"}},"type":"object","title":"StringProperty"},"StringSubtypeEnum":{"type":"string","enum":["plain","email","url","phone","file_path"],"title":"StringSubtypeEnum"},"NumberProperty":{"properties":{"type":{"type":"string","const":"number","title":"Type","default":"number"},"description":{"type":"string","maxLength":1024,"title":"Description","default":""},"order":{"type":"integer","minimum":0,"title":"Order","description":"Order of the property in the schema, used for sorting in the frontend","default":0}},"type":"object","title":"NumberProperty"},"BooleanProperty":{"properties":{"type":{"type":"string","const":"boolean","title":"Type","default":"boolean"},"description":{"type":"string","maxLength":1024,"title":"Description","default":""},"order":{"type":"integer","minimum":0,"title":"Order","description":"Order of the property in the schema, used for sorting in the frontend","default":0}},"type":"object","title":"BooleanProperty"},"DateProperty":{"properties":{"type":{"type":"string","const":"date","title":"Type","default":"date"},"description":{"type":"string","maxLength":1024,"title":"Description","default":""},"order":{"type":"integer","minimum":0,"title":"Order","description":"Order of the property in the schema, used for sorting in the frontend","default":0}},"type":"object","title":"DateProperty"},"StringListProperty-Output":{"properties":{"type":{"type":"string","const":"string_list","title":"Type","default":"string_list"},"description":{"type":"string","maxLength":1024,"title":"Description","default":""},"order":{"type":"integer","minimum":0,"title":"Order","description":"Order of the property in the schema, used for sorting in the frontend","default":0},"options":{"items":{"$ref":"#/components/schemas/StringListOption"},"type":"array","title":"Options"}},"type":"object","title":"StringListProperty","description":"A property that contains a list of strings. Can be used to store tags as well."},"StringListOption":{"properties":{"id":{"type":"string","title":"Id"},"label":{"type":"string","title":"Label"},"description":{"type":"string","maxLength":1024,"title":"Description","default":""},"color":{"$ref":"#/components/schemas/StringListOptionColor","default":"gray"},"order":{"type":"integer","maximum":10000000,"minimum":0,"title":"Order","default":0}},"type":"object","required":["label"],"title":"StringListOption"},"StringListOptionColor":{"type":"string","enum":["red","green","blue","yellow","purple","gray"],"title":"StringListOptionColor","description":"Store the different colors that can be used for the string list options."},"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":{"/v1/knowledge-bases/{knowledge_base_id}":{"get":{"tags":["Knowledge Bases"],"summary":"Get Knowledge Base By Id","description":"Get a knowledge base by its ID in the current organization.","operationId":"get_knowledge_base_by_id_v1_knowledge_bases__knowledge_base_id__get","parameters":[{"name":"knowledge_base_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Knowledge Base Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeBaseResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```

## Delete Kowledge Base

> Delete a knowledge base by its ID.

```json
{"openapi":"3.1.0","info":{"title":"StackAI API","version":"0.1.0"},"servers":[{"url":"https://api.stack-ai.com","description":"StackAI API Server"}],"security":[{"HTTPBearer":[]}],"components":{"securitySchemes":{},"schemas":{"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":{"/v1/knowledge-bases/{knowledge_base_id}":{"delete":{"tags":["Knowledge Bases"],"summary":"Delete Kowledge Base","description":"Delete a knowledge base by its ID.","operationId":"delete_kowledge_base_v1_knowledge_bases__knowledge_base_id__delete","parameters":[{"name":"knowledge_base_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Knowledge Base Id"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```

## Update Knowledge Base

> Update a knowledge base.

```json
{"openapi":"3.1.0","info":{"title":"StackAI API","version":"0.1.0"},"servers":[{"url":"https://api.stack-ai.com","description":"StackAI API Server"}],"security":[{"HTTPBearer":[]}],"components":{"securitySchemes":{},"schemas":{"UpdateKnowledgeBaseRequest":{"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"},"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":"Request model to update a 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 class representing the selected resources to be indexed in a website knowledge base.\n\nAttributes:\n    original_search_term (str): The search term that the user did input to get the selected resources.\n        This is used by the frontend to re-create the same folder structure that was displayed when the\n        user made first selected which pages to index, so the selection can easily be edited.\n    selected_resources (list[str]): The list of resource IDs that were selected from the 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":"Indexing params accepted by knowledge base create and update requests."},"CreateKnowledgeBaseEmbeddingParams":{"properties":{"embedding_model":{"type":"string","title":"Embedding Model","default":"openai.text-embedding-3-large"},"api_key":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Api Key"}},"additionalProperties":false,"type":"object","title":"CreateKnowledgeBaseEmbeddingParams","description":"Embedding params accepted by create KB requests."},"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":"Public chunking params exposed by the API."},"ChunkerType":{"type":"string","enum":["naive","sentence"],"title":"ChunkerType"},"KnowledgeBaseRole":{"type":"string","enum":["viewer","editor","admin"],"title":"KnowledgeBaseRole","description":"Enumerates all the possible roles for a user in a knowledge base.\n\nAttributes\n----------\n- ADMIN: Admin permissions allow full control over the knowledge base, including deletion.\n- EDITOR: Editor permissions allow the user to modify the knowledge base, but not delete it.\n- VIEWER: Viewer permissions allow the user to view the knowledge base, but not modify it."},"KnowledgeBaseResponse":{"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"},"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","description":"Total size of all the files in the KB in bytes","default":0},"total_files":{"type":"integer","title":"Total Files","description":"Total number of files in the KB","default":0},"total_indexed_files":{"type":"integer","title":"Total Indexed Files","description":"Total number of indexed files in the KB","default":0},"total_error_files":{"type":"integer","title":"Total Error Files","description":"Total number of error files in the KB","default":0},"last_synced_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Synced At","description":"Timestamp when the knowledge base was last successfully synced from its source"},"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_id":{"type":"string","title":"Org Id"},"role":{"anyOf":[{"$ref":"#/components/schemas/KnowledgeBaseRole"},{"type":"null"}]},"org_level_role":{"anyOf":[{"$ref":"#/components/schemas/KnowledgeBaseRole"},{"type":"null"}]},"user_metadata_schema":{"anyOf":[{"$ref":"#/components/schemas/MetadataSchema"},{"type":"null"}]},"dataloader_metadata_schema":{"anyOf":[{"$ref":"#/components/schemas/MetadataSchema"},{"type":"null"}]}},"type":"object","required":["knowledge_base_id","connection_id","created_at","updated_at","connection_source_ids","website_sources","indexing_params","org_id"],"title":"KnowledgeBaseResponse","description":"Knowledge base response payload for public API endpoints."},"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 params returned by knowledge base responses."},"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 params returned by KB responses."},"MetadataSchema":{"properties":{"properties":{"patternProperties":{"^[^\\t\\n\\r\\f\\v]+$":{"anyOf":[{"$ref":"#/components/schemas/StringProperty"},{"$ref":"#/components/schemas/NumberProperty"},{"$ref":"#/components/schemas/BooleanProperty"},{"$ref":"#/components/schemas/DateProperty"},{"$ref":"#/components/schemas/StringListProperty-Output"}]}},"propertyNames":{"maxLength":64,"minLength":1},"type":"object","title":"Properties"}},"type":"object","required":["properties"],"title":"MetadataSchema"},"StringProperty":{"properties":{"type":{"type":"string","const":"string","title":"Type","default":"string"},"description":{"type":"string","maxLength":1024,"title":"Description","default":""},"order":{"type":"integer","minimum":0,"title":"Order","description":"Order of the property in the schema, used for sorting in the frontend","default":0},"subtype":{"$ref":"#/components/schemas/StringSubtypeEnum","default":"plain"}},"type":"object","title":"StringProperty"},"StringSubtypeEnum":{"type":"string","enum":["plain","email","url","phone","file_path"],"title":"StringSubtypeEnum"},"NumberProperty":{"properties":{"type":{"type":"string","const":"number","title":"Type","default":"number"},"description":{"type":"string","maxLength":1024,"title":"Description","default":""},"order":{"type":"integer","minimum":0,"title":"Order","description":"Order of the property in the schema, used for sorting in the frontend","default":0}},"type":"object","title":"NumberProperty"},"BooleanProperty":{"properties":{"type":{"type":"string","const":"boolean","title":"Type","default":"boolean"},"description":{"type":"string","maxLength":1024,"title":"Description","default":""},"order":{"type":"integer","minimum":0,"title":"Order","description":"Order of the property in the schema, used for sorting in the frontend","default":0}},"type":"object","title":"BooleanProperty"},"DateProperty":{"properties":{"type":{"type":"string","const":"date","title":"Type","default":"date"},"description":{"type":"string","maxLength":1024,"title":"Description","default":""},"order":{"type":"integer","minimum":0,"title":"Order","description":"Order of the property in the schema, used for sorting in the frontend","default":0}},"type":"object","title":"DateProperty"},"StringListProperty-Output":{"properties":{"type":{"type":"string","const":"string_list","title":"Type","default":"string_list"},"description":{"type":"string","maxLength":1024,"title":"Description","default":""},"order":{"type":"integer","minimum":0,"title":"Order","description":"Order of the property in the schema, used for sorting in the frontend","default":0},"options":{"items":{"$ref":"#/components/schemas/StringListOption"},"type":"array","title":"Options"}},"type":"object","title":"StringListProperty","description":"A property that contains a list of strings. Can be used to store tags as well."},"StringListOption":{"properties":{"id":{"type":"string","title":"Id"},"label":{"type":"string","title":"Label"},"description":{"type":"string","maxLength":1024,"title":"Description","default":""},"color":{"$ref":"#/components/schemas/StringListOptionColor","default":"gray"},"order":{"type":"integer","maximum":10000000,"minimum":0,"title":"Order","default":0}},"type":"object","required":["label"],"title":"StringListOption"},"StringListOptionColor":{"type":"string","enum":["red","green","blue","yellow","purple","gray"],"title":"StringListOptionColor","description":"Store the different colors that can be used for the string list options."},"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":{"/v1/knowledge-bases/{knowledge_base_id}":{"patch":{"tags":["Knowledge Bases"],"summary":"Update Knowledge Base","description":"Update a knowledge base.","operationId":"update_knowledge_base_v1_knowledge_bases__knowledge_base_id__patch","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/UpdateKnowledgeBaseRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeBaseResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```

## List Resources

> List files in the knowledge base with optional cursor pagination.

```json
{"openapi":"3.1.0","info":{"title":"StackAI API","version":"0.1.0"},"servers":[{"url":"https://api.stack-ai.com","description":"StackAI API Server"}],"security":[{"HTTPBearer":[]}],"components":{"securitySchemes":{},"schemas":{"PaginationDirection":{"type":"string","enum":["next","prev"],"title":"PaginationDirection","description":"Direction for cursor-based pagination."},"KnowledgeBaseResourcesResponse":{"additionalProperties":true,"type":"object"},"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":{"/v1/knowledge-bases/{knowledge_base_id}/resources":{"get":{"tags":["Knowledge Bases"],"summary":"List Resources","description":"List files in the knowledge base with optional cursor pagination.","operationId":"list_resources_v1_knowledge_bases__knowledge_base_id__resources_get","parameters":[{"name":"knowledge_base_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Knowledge Base Id"}},{"name":"cursor","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Optional identifier for the page that should be returned. If it is not provided, the first page will be returned.","title":"Cursor"},"description":"Optional identifier for the page that should be returned. If it is not provided, the first page will be returned."},{"name":"page_size","in":"query","required":false,"schema":{"type":"integer","maximum":100,"minimum":1,"description":"Number of items to be returned in the page.","default":50,"title":"Page Size"},"description":"Number of items to be returned in the page."},{"name":"direction","in":"query","required":false,"schema":{"$ref":"#/components/schemas/PaginationDirection","description":"Direction for pagination: 'next' to advance through pages (older items), 'prev' to go back (newer items)","default":"next"},"description":"Direction for pagination: 'next' to advance through pages (older items), 'prev' to go back (newer items)"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeBaseResourcesResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```

## Create Resource

> Upload a file directly to a knowledge base and start indexing.\
> \
> This endpoint allows API users to upload files directly without needing to use\
> presigned URLs. The file is uploaded to storage and indexing is started automatically.

```json
{"openapi":"3.1.0","info":{"title":"StackAI API","version":"0.1.0"},"servers":[{"url":"https://api.stack-ai.com","description":"StackAI API Server"}],"security":[{"HTTPBearer":[]}],"components":{"securitySchemes":{},"schemas":{"Body_create_resource_v1_knowledge_bases__knowledge_base_id__resources_post":{"properties":{"file":{"type":"string","format":"binary","title":"File","description":"The file to upload to the knowledge base"}},"type":"object","required":["file"],"title":"Body_create_resource_v1_knowledge_bases__knowledge_base_id__resources_post"},"apps__modules__knowledge_bases__api__request_models__MessageResponse":{"properties":{"message":{"type":"string","title":"Message"}},"type":"object","required":["message"],"title":"MessageResponse","description":"Standard response payload for endpoints that return a simple confirmation message."},"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":{"/v1/knowledge-bases/{knowledge_base_id}/resources":{"post":{"tags":["Knowledge Bases"],"summary":"Create Resource","description":"Upload a file directly to a knowledge base and start indexing.\n\nThis endpoint allows API users to upload files directly without needing to use\npresigned URLs. The file is uploaded to storage and indexing is started automatically.","operationId":"create_resource_v1_knowledge_bases__knowledge_base_id__resources_post","parameters":[{"name":"knowledge_base_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Knowledge Base Id"}}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_create_resource_v1_knowledge_bases__knowledge_base_id__resources_post"}}}},"responses":{"202":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/apps__modules__knowledge_bases__api__request_models__MessageResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```

## Get Resource By Id

> Get one file resource by ID from the knowledge base.

```json
{"openapi":"3.1.0","info":{"title":"StackAI API","version":"0.1.0"},"servers":[{"url":"https://api.stack-ai.com","description":"StackAI API Server"}],"security":[{"HTTPBearer":[]}],"components":{"securitySchemes":{},"schemas":{"KnowledgeBaseFileResponse":{"properties":{"knowledge_base_id":{"type":"string","format":"uuid","title":"Knowledge Base Id"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"modified_at":{"type":"string","format":"date-time","title":"Modified At"},"indexed_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Indexed At"},"resource_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Resource Id"},"resource_path":{"type":"string","minLength":1,"title":"Resource Path"},"dataloader_metadata":{"patternProperties":{"^[^\\t\\n\\r\\f\\v]+$":{"anyOf":[{},{"type":"null"}]}},"propertyNames":{"maxLength":64,"minLength":1},"type":"object","title":"Dataloader Metadata"},"user_metadata":{"patternProperties":{"^[^\\t\\n\\r\\f\\v]+$":{"anyOf":[{},{"type":"null"}]}},"propertyNames":{"maxLength":64,"minLength":1},"type":"object","title":"User Metadata"},"content_hash":{"type":"string","minLength":1,"title":"Content Hash"},"content_mime":{"type":"string","minLength":1,"title":"Content Mime"},"size":{"type":"integer","minimum":0,"title":"Size"},"status":{"$ref":"#/components/schemas/StackFileStatusEnum"}},"type":"object","required":["knowledge_base_id","created_at","modified_at","resource_id","resource_path","content_hash","content_mime","size","status"],"title":"KnowledgeBaseFileResponse","description":"API response model for a KB file (without signed download URL)."},"StackFileStatusEnum":{"type":"string","enum":["resource","parsed","indexed","pending","pending_delete","deleted","error"],"title":"StackFileStatusEnum","description":"Enumerates all the possible status of a file in the Stack Virtual File System."},"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":{"/v1/knowledge-bases/{knowledge_base_id}/resources/{resource_id}":{"get":{"tags":["Knowledge Bases"],"summary":"Get Resource By Id","description":"Get one file resource by ID from the knowledge base.","operationId":"get_resource_by_id_v1_knowledge_bases__knowledge_base_id__resources__resource_id__get","parameters":[{"name":"knowledge_base_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Knowledge Base Id"}},{"name":"resource_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Resource Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeBaseFileResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```

## Delete Resource By Id

> Delete a file resource by inode ID.

```json
{"openapi":"3.1.0","info":{"title":"StackAI API","version":"0.1.0"},"servers":[{"url":"https://api.stack-ai.com","description":"StackAI API Server"}],"security":[{"HTTPBearer":[]}],"components":{"securitySchemes":{},"schemas":{"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":{"/v1/knowledge-bases/{knowledge_base_id}/resources/{resource_id}":{"delete":{"tags":["Knowledge Bases"],"summary":"Delete Resource By Id","description":"Delete a file resource by inode ID.","operationId":"delete_resource_by_id_v1_knowledge_bases__knowledge_base_id__resources__resource_id__delete","parameters":[{"name":"knowledge_base_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Knowledge Base Id"}},{"name":"resource_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Resource Id"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```

## Synchronize Knowledge Base

> Synchronize the knowledge base.

```json
{"openapi":"3.1.0","info":{"title":"StackAI API","version":"0.1.0"},"servers":[{"url":"https://api.stack-ai.com","description":"StackAI API Server"}],"security":[{"HTTPBearer":[]}],"components":{"securitySchemes":{},"schemas":{"KnowledgeBaseSyncResponse":{"properties":{"message":{"type":"string","title":"Message","description":"Success message describing the task that was started"},"status":{"type":"string","const":"accepted","title":"Status","description":"The status of the task","default":"accepted"}},"type":"object","required":["message"],"title":"KnowledgeBaseSyncResponse","description":"Response model for knowledge base synchronization and reindexing."},"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":{"/v1/knowledge-bases/{knowledge_base_id}/sync":{"post":{"tags":["Knowledge Bases"],"summary":"Synchronize Knowledge Base","description":"Synchronize the knowledge base.","operationId":"synchronize_knowledge_base_v1_knowledge_bases__knowledge_base_id__sync_post","parameters":[{"name":"knowledge_base_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Knowledge Base Id"}}],"responses":{"202":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeBaseSyncResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}}}
```
