# Ai knowledge Sources

## Lists all knowledge sources for a chatbot

> \
> \
> \*\*Required Permission:\*\* \`chatbots.knowledge-source.list\`\
> \
> \*\*Resource:\*\* \`chatbots/:chatbotId\`

```json
{"openapi":"3.0.0","info":{"title":"ChatCaptain API","version":"1.0"},"tags":[{"name":"Ai knowledge-sources","description":""}],"servers":[{"url":"https://api.chatcaptain.com","description":"Production"}],"security":[{},{}],"paths":{"/v1/chatbots/{chatbotId}/ai/knowledge/sources":{"get":{"operationId":"AiKnowledgeSourceController_listKnowledgeSources[1]_v1","parameters":[{"name":"chatbotId","required":true,"in":"path","description":"The ID of the chatbot.","schema":{"type":"string"}},{"name":"pageToken","required":false,"in":"query","description":"The date after which to filter sources. Only sources created after this date will be fetched.","schema":{"type":"string"}},{"name":"limit","required":false,"in":"query","description":"The limit for how many sources should be fetched.","schema":{"type":"number"}}],"responses":{"200":{"description":"List of all knowledge sources.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListKnowledgeSourcesResponseDto"}}}},"403":{"description":"Insufficient permissions."}},"summary":"Lists all knowledge sources for a chatbot","tags":["Ai knowledge-sources"],"description":"\n\n**Required Permission:** `chatbots.knowledge-source.list`\n\n**Resource:** `chatbots/:chatbotId`"}}},"components":{"schemas":{"ListKnowledgeSourcesResponseDto":{"type":"object","properties":{"sources":{"description":"A list of retrieved knowledge sources.","type":"array","items":{"$ref":"#/components/schemas/KnowledgeSourceDto"}},"error":{"type":"string","description":"Optional error message"},"pageToken":{"type":"string","description":"The date of the latest fetched source."}},"required":["sources","pageToken"]},"KnowledgeSourceDto":{"type":"object","properties":{"id":{"type":"string","description":"The ID of the knowledge source."},"source":{"type":"string","description":"The url or filepath of the source."},"groupIds":{"description":"A list of group ID's that the source is used in.","type":"array","items":{"type":"string"}},"enabled":{"type":"boolean","description":"Indicates whether the knowledge source is enabled (true) or disabled (false)."},"isIndexing":{"type":"boolean","description":"Sets the indexing status of the source."},"created":{"type":"string","description":"Creation timestamp (ISO format)."},"type":{"description":"Sets the type of the source.\n\n- `0`: WEBSITE\n- `1`: PDF\n","allOf":[{"$ref":"#/components/schemas/KnowledgeSourceType"}]},"status":{"description":"Sets the status of the source.\n\n- `0`: PENDING\n- `1`: INDEXING\n- `2`: INDEXED\n- `3`: ERROR\n- `4`: DELETING","allOf":[{"$ref":"#/components/schemas/KnowledgeSourceStatus"}]},"name":{"type":"string","description":"Sets the name of the source."},"errorReason":{"type":"string","description":"The reason for the potential error."},"metadata":{"type":"object","description":"Additional custom metadata as key-value pairs.","additionalProperties":{"type":"string"}}},"required":["id","source","groupIds","enabled","isIndexing","created","type","status","name","metadata"]},"KnowledgeSourceType":{"type":"number","enum":[0,1,-1],"description":"Sets the type of the source.\n\n- `0`: WEBSITE\n- `1`: PDF\n"},"KnowledgeSourceStatus":{"type":"number","enum":[0,1,2,3,4,-1],"description":"Sets the status of the source.\n\n- `0`: PENDING\n- `1`: INDEXING\n- `2`: INDEXED\n- `3`: ERROR\n- `4`: DELETING"}}}}
```

## Deletes a batch of knowledge sources.

> \
> \
> \*\*Required Permission:\*\* \`chatbots.knowledge-source.delete\`\
> \
> \*\*Resource:\*\* \`chatbots/:chatbotId\`

```json
{"openapi":"3.0.0","info":{"title":"ChatCaptain API","version":"1.0"},"tags":[{"name":"Ai knowledge-sources","description":""}],"servers":[{"url":"https://api.chatcaptain.com","description":"Production"}],"security":[{},{}],"paths":{"/v1/chatbots/{chatbotId}/ai/knowledge/sources":{"delete":{"operationId":"AiKnowledgeSourceController_deleteKnowledgeSourceBatch[1]_v1","parameters":[{"name":"chatbotId","required":true,"in":"path","description":"The ID of the chatbot.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteKnowledgeSourceBatchRequestDto"}}}},"responses":{"200":{"description":"Deletion result.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteKnowledgeSourceResponseDto"}}}},"403":{"description":"Insufficient permissions."}},"summary":"Deletes a batch of knowledge sources.","tags":["Ai knowledge-sources"],"description":"\n\n**Required Permission:** `chatbots.knowledge-source.delete`\n\n**Resource:** `chatbots/:chatbotId`"}}},"components":{"schemas":{"DeleteKnowledgeSourceBatchRequestDto":{"type":"object","properties":{"sourceIds":{"description":"A list of deleted source Id's.","type":"array","items":{"type":"string"}}},"required":["sourceIds"]},"DeleteKnowledgeSourceResponseDto":{"type":"object","properties":{"error":{"type":"string","description":"Optional error message."},"deleted":{"type":"boolean","description":"Indicates whether the deletion succeeded."}},"required":["deleted"]}}}}
```

## Retrieves a specific knowledge source

> \
> \
> \*\*Required Permission:\*\* \`chatbots.knowledge-source.get\`\
> \
> \*\*Resource:\*\* \`chatbots/:chatbotId\`

```json
{"openapi":"3.0.0","info":{"title":"ChatCaptain API","version":"1.0"},"tags":[{"name":"Ai knowledge-sources","description":""}],"servers":[{"url":"https://api.chatcaptain.com","description":"Production"}],"security":[{},{}],"paths":{"/v1/chatbots/{chatbotId}/ai/knowledge/sources/{sourceId}":{"get":{"operationId":"AiKnowledgeSourceController_getKnowledgeSource[1]_v1","parameters":[{"name":"chatbotId","required":true,"in":"path","description":"The ID of the chatbot.","schema":{"type":"string"}},{"name":"sourceId","required":true,"in":"path","description":"The ID of the knowledge source to retrieve.","schema":{"type":"string"}}],"responses":{"200":{"description":"Knowledge source details.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetKnowledgeSourceResponseDto"}}}},"403":{"description":"Insufficient permissions."}},"summary":"Retrieves a specific knowledge source","tags":["Ai knowledge-sources"],"description":"\n\n**Required Permission:** `chatbots.knowledge-source.get`\n\n**Resource:** `chatbots/:chatbotId`"}}},"components":{"schemas":{"GetKnowledgeSourceResponseDto":{"type":"object","properties":{"source":{"description":"The retrieved knowledge source.","nullable":true,"allOf":[{"$ref":"#/components/schemas/KnowledgeSourceDto"}]},"error":{"type":"string","description":"Optional error message"},"chunksContent":{"description":"Content of the source split into chunks.","type":"array","items":{"type":"string"}}},"required":["source","chunksContent"]},"KnowledgeSourceDto":{"type":"object","properties":{"id":{"type":"string","description":"The ID of the knowledge source."},"source":{"type":"string","description":"The url or filepath of the source."},"groupIds":{"description":"A list of group ID's that the source is used in.","type":"array","items":{"type":"string"}},"enabled":{"type":"boolean","description":"Indicates whether the knowledge source is enabled (true) or disabled (false)."},"isIndexing":{"type":"boolean","description":"Sets the indexing status of the source."},"created":{"type":"string","description":"Creation timestamp (ISO format)."},"type":{"description":"Sets the type of the source.\n\n- `0`: WEBSITE\n- `1`: PDF\n","allOf":[{"$ref":"#/components/schemas/KnowledgeSourceType"}]},"status":{"description":"Sets the status of the source.\n\n- `0`: PENDING\n- `1`: INDEXING\n- `2`: INDEXED\n- `3`: ERROR\n- `4`: DELETING","allOf":[{"$ref":"#/components/schemas/KnowledgeSourceStatus"}]},"name":{"type":"string","description":"Sets the name of the source."},"errorReason":{"type":"string","description":"The reason for the potential error."},"metadata":{"type":"object","description":"Additional custom metadata as key-value pairs.","additionalProperties":{"type":"string"}}},"required":["id","source","groupIds","enabled","isIndexing","created","type","status","name","metadata"]},"KnowledgeSourceType":{"type":"number","enum":[0,1,-1],"description":"Sets the type of the source.\n\n- `0`: WEBSITE\n- `1`: PDF\n"},"KnowledgeSourceStatus":{"type":"number","enum":[0,1,2,3,4,-1],"description":"Sets the status of the source.\n\n- `0`: PENDING\n- `1`: INDEXING\n- `2`: INDEXED\n- `3`: ERROR\n- `4`: DELETING"}}}}
```

## Uploads knowledge source files.

> \
> \
> \*\*Required Permission:\*\* \`chatbots.knowledge-source.create\`\
> \
> \*\*Resource:\*\* \`chatbots/:chatbotId\`

```json
{"openapi":"3.0.0","info":{"title":"ChatCaptain API","version":"1.0"},"tags":[{"name":"Ai knowledge-sources","description":""}],"servers":[{"url":"https://api.chatcaptain.com","description":"Production"}],"security":[{},{}],"paths":{"/v1/chatbots/{chatbotId}/ai/knowledge/sources/upload":{"post":{"operationId":"AiKnowledgeSourceController_uploadKnowledgeSourceFile[1]_v1","parameters":[{"name":"chatbotId","required":true,"in":"path","description":"The ID of the chatbot.","schema":{"type":"string"}}],"requestBody":{"required":true,"description":"Files to be uploaded as knowledge sources.","content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/UploadFilesDto"}}}},"responses":{"200":{"description":"Upload result.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UploadKnowledgeSourceFilesResponseDto"}}}},"201":{"description":"","content":{"application/json":{"schema":{"type":"object"}}}},"403":{"description":"Insufficient permissions."}},"summary":"Uploads knowledge source files.","tags":["Ai knowledge-sources"],"description":"\n\n**Required Permission:** `chatbots.knowledge-source.create`\n\n**Resource:** `chatbots/:chatbotId`"}}},"components":{"schemas":{"UploadFilesDto":{"type":"object","properties":{"files":{"type":"array","description":"Files to be uploaded as knowledge sources.","items":{"type":"string","format":"binary"}}},"required":["files"]},"UploadKnowledgeSourceFilesResponseDto":{"type":"object","properties":{"success":{"type":"boolean","description":"Indicates whether the upload was successful."},"error":{"type":"string","description":"Optional error message."}}}}}}
```


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.chatcaptain.com/api/api-dokumentation/ai-knowledge-sources.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
