Retrieve a knowledge base source
curl --request GET \
--url https://api.chatling.ai/v3/knowledge-base/sources/{source} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.chatling.ai/v3/knowledge-base/sources/{source}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.chatling.ai/v3/knowledge-base/sources/{source}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.chatling.ai/v3/knowledge-base/sources/{source}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.chatling.ai/v3/knowledge-base/sources/{source}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.chatling.ai/v3/knowledge-base/sources/{source}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.chatling.ai/v3/knowledge-base/sources/{source}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"object": "knowledge_base_source",
"id": "0d1f6a3e-5b2c-4e8f-9a7d-3c6b1e2f4a5d",
"agent": {
"id": "3132353852",
"type": "ai_agent",
"name": "Support agent"
},
"type": "link",
"status": "pending",
"error": "<string>",
"characters": 123,
"resync_pending": true,
"last_synced_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"link": {
"url": "https://example.com/pricing",
"title": "Pricing",
"auto_sync": "never",
"next_sync_at": "2023-11-07T05:31:56Z",
"exclude_classes": [
"<string>"
],
"exclude_ids": [
"<string>"
],
"content": "# Pricing\n\nThe Pro plan is $20 a month."
},
"text": {
"preview": "<string>",
"content": "<string>"
},
"faq": {
"question": "Do you ship internationally?",
"answer": "Yes, to over **40 countries**."
},
"document": {
"filename": "Handbook.pdf",
"size": 482133,
"content_type": "application/pdf",
"content": "Employee handbook\n\n1. Working hours\nOur office is open 9 to 5."
},
"zoho": {
"title": "Returns policy",
"url": "https://support.example.com/hc/articles/360001",
"auto_sync": "never",
"next_sync_at": "2023-11-07T05:31:56Z",
"content": "# Team handbook\n\nWelcome to the team."
},
"zendesk": {
"title": "Returns policy",
"url": "https://support.example.com/hc/articles/360001",
"auto_sync": "never",
"next_sync_at": "2023-11-07T05:31:56Z",
"content": "# Team handbook\n\nWelcome to the team."
},
"notion": {
"title": "Returns policy",
"url": "https://support.example.com/hc/articles/360001",
"auto_sync": "never",
"next_sync_at": "2023-11-07T05:31:56Z",
"content": "# Team handbook\n\nWelcome to the team."
},
"sharepoint": {
"filename": "Onboarding.docx",
"path": "/Shared Documents/HR",
"url": "https://example.sharepoint.com/sites/hr/Shared%20Documents/HR/Onboarding.docx",
"size": 58211,
"content_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"auto_sync": "never",
"next_sync_at": "2023-11-07T05:31:56Z",
"content": "Onboarding\n\nYour first week."
}
}{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "The API key is invalid or has been revoked.",
"param": null,
"request_id": "req_8Fq2kLm9TzX4vB7nC1dR5sYw"
}
}{
"error": {
"type": "permission_error",
"code": "insufficient_permission",
"message": "This API key doesn't have delete access to agents.",
"param": null,
"request_id": "req_8Fq2kLm9TzX4vB7nC1dR5sYw"
}
}{
"error": {
"type": "not_found_error",
"code": "resource_not_found",
"message": "No knowledge base source with this ID exists, or this API key can't access it.",
"param": null,
"request_id": "req_8Fq2kLm9TzX4vB7nC1dR5sYw"
}
}{
"error": {
"type": "authentication_error",
"code": "validation_failed",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"errors": [
{
"param": "<string>",
"message": "<string>"
}
]
}
}Knowledge base
Retrieve a knowledge base source
Retrieves a source with its full content. Text and FAQ sources return what was sent. Link, document, Notion, and SharePoint sources return the content training read in content, which is null until the source is trained. A document’s content can be up to 5 million characters.
GET
/
knowledge-base
/
sources
/
{source}
Retrieve a knowledge base source
curl --request GET \
--url https://api.chatling.ai/v3/knowledge-base/sources/{source} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.chatling.ai/v3/knowledge-base/sources/{source}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.chatling.ai/v3/knowledge-base/sources/{source}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.chatling.ai/v3/knowledge-base/sources/{source}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.chatling.ai/v3/knowledge-base/sources/{source}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.chatling.ai/v3/knowledge-base/sources/{source}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.chatling.ai/v3/knowledge-base/sources/{source}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"object": "knowledge_base_source",
"id": "0d1f6a3e-5b2c-4e8f-9a7d-3c6b1e2f4a5d",
"agent": {
"id": "3132353852",
"type": "ai_agent",
"name": "Support agent"
},
"type": "link",
"status": "pending",
"error": "<string>",
"characters": 123,
"resync_pending": true,
"last_synced_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"link": {
"url": "https://example.com/pricing",
"title": "Pricing",
"auto_sync": "never",
"next_sync_at": "2023-11-07T05:31:56Z",
"exclude_classes": [
"<string>"
],
"exclude_ids": [
"<string>"
],
"content": "# Pricing\n\nThe Pro plan is $20 a month."
},
"text": {
"preview": "<string>",
"content": "<string>"
},
"faq": {
"question": "Do you ship internationally?",
"answer": "Yes, to over **40 countries**."
},
"document": {
"filename": "Handbook.pdf",
"size": 482133,
"content_type": "application/pdf",
"content": "Employee handbook\n\n1. Working hours\nOur office is open 9 to 5."
},
"zoho": {
"title": "Returns policy",
"url": "https://support.example.com/hc/articles/360001",
"auto_sync": "never",
"next_sync_at": "2023-11-07T05:31:56Z",
"content": "# Team handbook\n\nWelcome to the team."
},
"zendesk": {
"title": "Returns policy",
"url": "https://support.example.com/hc/articles/360001",
"auto_sync": "never",
"next_sync_at": "2023-11-07T05:31:56Z",
"content": "# Team handbook\n\nWelcome to the team."
},
"notion": {
"title": "Returns policy",
"url": "https://support.example.com/hc/articles/360001",
"auto_sync": "never",
"next_sync_at": "2023-11-07T05:31:56Z",
"content": "# Team handbook\n\nWelcome to the team."
},
"sharepoint": {
"filename": "Onboarding.docx",
"path": "/Shared Documents/HR",
"url": "https://example.sharepoint.com/sites/hr/Shared%20Documents/HR/Onboarding.docx",
"size": 58211,
"content_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"auto_sync": "never",
"next_sync_at": "2023-11-07T05:31:56Z",
"content": "Onboarding\n\nYour first week."
}
}{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "The API key is invalid or has been revoked.",
"param": null,
"request_id": "req_8Fq2kLm9TzX4vB7nC1dR5sYw"
}
}{
"error": {
"type": "permission_error",
"code": "insufficient_permission",
"message": "This API key doesn't have delete access to agents.",
"param": null,
"request_id": "req_8Fq2kLm9TzX4vB7nC1dR5sYw"
}
}{
"error": {
"type": "not_found_error",
"code": "resource_not_found",
"message": "No knowledge base source with this ID exists, or this API key can't access it.",
"param": null,
"request_id": "req_8Fq2kLm9TzX4vB7nC1dR5sYw"
}
}{
"error": {
"type": "authentication_error",
"code": "validation_failed",
"message": "<string>",
"param": "<string>",
"request_id": "<string>",
"errors": [
{
"param": "<string>",
"message": "<string>"
}
]
}
}Response
The source.
link is a web page, fetched when the source trains. text and faq are content you send. document is a file you upload first with Create a document upload. zoho, zendesk, notion, and sharepoint are Zoho Desk articles, Zendesk articles, Notion pages, and SharePoint files, added in the dashboard through a connection. The API can list, resync, and delete them, and change their auto_sync, but can't add them or change their content.
Available options:
link, text, faq, document, zoho, zendesk, notion, sharepoint