Crawl Website
curl --request POST \
--url https://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/knowledge-base/website/scrape \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"url": "https://example.com",
"maxDepth": 3,
"maxPages": 5
}
'import requests
url = "https://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/knowledge-base/website/scrape"
payload = {
"url": "https://example.com",
"maxDepth": 3,
"maxPages": 5
}
headers = {
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({url: 'https://example.com', maxDepth: 3, maxPages: 5})
};
fetch('https://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/knowledge-base/website/scrape', 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://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/knowledge-base/website/scrape",
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([
'url' => 'https://example.com',
'maxDepth' => 3,
'maxPages' => 5
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apikey: <api-key>"
],
]);
$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://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/knowledge-base/website/scrape"
payload := strings.NewReader("{\n \"url\": \"https://example.com\",\n \"maxDepth\": 3,\n \"maxPages\": 5\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "<api-key>")
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://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/knowledge-base/website/scrape")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://example.com\",\n \"maxDepth\": 3,\n \"maxPages\": 5\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/knowledge-base/website/scrape")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://example.com\",\n \"maxDepth\": 3,\n \"maxPages\": 5\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Website scrape completed successfully",
"data": {
"crawlId": "crawl-1701789123456",
"crawlDuration": 120000,
"status": "completed",
"sitemap": {
"found": true,
"url": "https://docs.example.com/sitemap.xml",
"totalUrls": 245,
"urls": [
"https://docs.example.com/page1",
"https://docs.example.com/page2"
],
"lastModified": "2025-12-05T10:30:00Z"
}
}
}Knowledge Base
Crawl Website
Scrapes a website to discover and crawl its pages for the knowledge base. Use this endpoint to add website content as a knowledge source for agents. Configuration: Supports options for URL filter
POST
/
ai-agents
/
agent-builder
/
knowledge-base
/
website
/
scrape
Crawl Website
curl --request POST \
--url https://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/knowledge-base/website/scrape \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"url": "https://example.com",
"maxDepth": 3,
"maxPages": 5
}
'import requests
url = "https://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/knowledge-base/website/scrape"
payload = {
"url": "https://example.com",
"maxDepth": 3,
"maxPages": 5
}
headers = {
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({url: 'https://example.com', maxDepth: 3, maxPages: 5})
};
fetch('https://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/knowledge-base/website/scrape', 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://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/knowledge-base/website/scrape",
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([
'url' => 'https://example.com',
'maxDepth' => 3,
'maxPages' => 5
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apikey: <api-key>"
],
]);
$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://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/knowledge-base/website/scrape"
payload := strings.NewReader("{\n \"url\": \"https://example.com\",\n \"maxDepth\": 3,\n \"maxPages\": 5\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "<api-key>")
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://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/knowledge-base/website/scrape")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://example.com\",\n \"maxDepth\": 3,\n \"maxPages\": 5\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/knowledge-base/website/scrape")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://example.com\",\n \"maxDepth\": 3,\n \"maxPages\": 5\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Website scrape completed successfully",
"data": {
"crawlId": "crawl-1701789123456",
"crawlDuration": 120000,
"status": "completed",
"sitemap": {
"found": true,
"url": "https://docs.example.com/sitemap.xml",
"totalUrls": 245,
"urls": [
"https://docs.example.com/page1",
"https://docs.example.com/page2"
],
"lastModified": "2025-12-05T10:30:00Z"
}
}
}For the complete error reference, see Error Guide.
Authorizations
API Key (i.e. Rest API Key from the Dashboard).
Body
application/json
Website crawling configuration
Target website URL to crawl
Example:
"https://docs.example.com"
Maximum depth to crawl from the starting URL
Required range:
1 <= x <= 10Example:
5
Maximum number of pages to crawl
Required range:
1 <= x <= 10000Example:
500
URL patterns to include in crawling (substring matching)
Example:
["docs/", "api/", "guides/"]
URL patterns to exclude from crawling (substring matching)
Example:
["login", "signup", "admin", "privacy"]
Fetch and return sitemap URLs from the website
Example:
true
Was this page helpful?
⌘I