Skip to main content
POST
/
chatbots
/
{chatbotId}
/
knowledge-base
/
data-sources
/
links
Add link
curl --request POST \
  --url https://api.chatling.ai/v2/chatbots/{chatbotId}/knowledge-base/data-sources/links \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "links": [
    "<string>"
  ],
  "exclude_classes": [
    "<string>"
  ],
  "exclude_ids": [
    "<string>"
  ],
  "exclude_header": true,
  "exclude_footer": true,
  "exclude_nav": true
}
'
import requests

url = "https://api.chatling.ai/v2/chatbots/{chatbotId}/knowledge-base/data-sources/links"

payload = {
"links": ["<string>"],
"exclude_classes": ["<string>"],
"exclude_ids": ["<string>"],
"exclude_header": True,
"exclude_footer": True,
"exclude_nav": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
links: ['<string>'],
exclude_classes: ['<string>'],
exclude_ids: ['<string>'],
exclude_header: true,
exclude_footer: true,
exclude_nav: true
})
};

fetch('https://api.chatling.ai/v2/chatbots/{chatbotId}/knowledge-base/data-sources/links', 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/v2/chatbots/{chatbotId}/knowledge-base/data-sources/links",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'links' => [
'<string>'
],
'exclude_classes' => [
'<string>'
],
'exclude_ids' => [
'<string>'
],
'exclude_header' => true,
'exclude_footer' => true,
'exclude_nav' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.chatling.ai/v2/chatbots/{chatbotId}/knowledge-base/data-sources/links"

payload := strings.NewReader("{\n \"links\": [\n \"<string>\"\n ],\n \"exclude_classes\": [\n \"<string>\"\n ],\n \"exclude_ids\": [\n \"<string>\"\n ],\n \"exclude_header\": true,\n \"exclude_footer\": true,\n \"exclude_nav\": true\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.chatling.ai/v2/chatbots/{chatbotId}/knowledge-base/data-sources/links")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"links\": [\n \"<string>\"\n ],\n \"exclude_classes\": [\n \"<string>\"\n ],\n \"exclude_ids\": [\n \"<string>\"\n ],\n \"exclude_header\": true,\n \"exclude_footer\": true,\n \"exclude_nav\": true\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.chatling.ai/v2/chatbots/{chatbotId}/knowledge-base/data-sources/links")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"links\": [\n \"<string>\"\n ],\n \"exclude_classes\": [\n \"<string>\"\n ],\n \"exclude_ids\": [\n \"<string>\"\n ],\n \"exclude_header\": true,\n \"exclude_footer\": true,\n \"exclude_nav\": true\n}"

response = http.request(request)
puts response.read_body
{
    "status": "success",
    "data": {
        "links_added": 105,
        "duplicate_links_removed": []
    }
}

Request parameters

Path

chatbotId
string
required
The chatbot ID.

Body

Array of webpage links to add to the knowledge base.
exclude_classes
string[]
Exclude sections of webpages based on their HTML class names.
exclude_ids
string[]
Exclude sections of webpages based on their HTML IDs.
exclude_header
boolean
Exclude header tags.
Exclude footer tags.
exclude_nav
boolean
Exclude nav tags.

Response

status
string
The status of the request. Will be success if the request was successful, otherwise error.
data
object
{
    "status": "success",
    "data": {
        "links_added": 105,
        "duplicate_links_removed": []
    }
}