Create Text Entry
curl --request POST \
--url https://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/knowledge-base/text \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"title": "Company Policy Document",
"text": "This document outlines the company policies and procedures for remote work, including communication guidelines, working hours expectations, and performance metrics."
}
'import requests
url = "https://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/knowledge-base/text"
payload = {
"title": "Company Policy Document",
"text": "This document outlines the company policies and procedures for remote work, including communication guidelines, working hours expectations, and performance metrics."
}
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({
title: 'Company Policy Document',
text: 'This document outlines the company policies and procedures for remote work, including communication guidelines, working hours expectations, and performance metrics.'
})
};
fetch('https://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/knowledge-base/text', 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/text",
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([
'title' => 'Company Policy Document',
'text' => 'This document outlines the company policies and procedures for remote work, including communication guidelines, working hours expectations, and performance metrics.'
]),
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/text"
payload := strings.NewReader("{\n \"title\": \"Company Policy Document\",\n \"text\": \"This document outlines the company policies and procedures for remote work, including communication guidelines, working hours expectations, and performance metrics.\"\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/text")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"Company Policy Document\",\n \"text\": \"This document outlines the company policies and procedures for remote work, including communication guidelines, working hours expectations, and performance metrics.\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/knowledge-base/text")
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 \"title\": \"Company Policy Document\",\n \"text\": \"This document outlines the company policies and procedures for remote work, including communication guidelines, working hours expectations, and performance metrics.\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Text detail created and uploaded successfully",
"data": {
"uniqueId": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"title": "Company Policy Document",
"fileName": "company-policy-document.md",
"s3Key": "my-app-id/text/f47ac10b/company-policy-document.md",
"status": "indexing"
}
}Knowledge Base
Create Text Entry
Creates a new text-based knowledge base entry. Use this endpoint to add custom text content that agents can reference during conversations. Processing: Accepts a title and text content, converts
POST
/
ai-agents
/
agent-builder
/
knowledge-base
/
text
Create Text Entry
curl --request POST \
--url https://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/knowledge-base/text \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"title": "Company Policy Document",
"text": "This document outlines the company policies and procedures for remote work, including communication guidelines, working hours expectations, and performance metrics."
}
'import requests
url = "https://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/knowledge-base/text"
payload = {
"title": "Company Policy Document",
"text": "This document outlines the company policies and procedures for remote work, including communication guidelines, working hours expectations, and performance metrics."
}
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({
title: 'Company Policy Document',
text: 'This document outlines the company policies and procedures for remote work, including communication guidelines, working hours expectations, and performance metrics.'
})
};
fetch('https://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/knowledge-base/text', 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/text",
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([
'title' => 'Company Policy Document',
'text' => 'This document outlines the company policies and procedures for remote work, including communication guidelines, working hours expectations, and performance metrics.'
]),
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/text"
payload := strings.NewReader("{\n \"title\": \"Company Policy Document\",\n \"text\": \"This document outlines the company policies and procedures for remote work, including communication guidelines, working hours expectations, and performance metrics.\"\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/text")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"Company Policy Document\",\n \"text\": \"This document outlines the company policies and procedures for remote work, including communication guidelines, working hours expectations, and performance metrics.\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/knowledge-base/text")
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 \"title\": \"Company Policy Document\",\n \"text\": \"This document outlines the company policies and procedures for remote work, including communication guidelines, working hours expectations, and performance metrics.\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Text detail created and uploaded successfully",
"data": {
"uniqueId": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"title": "Company Policy Document",
"fileName": "company-policy-document.md",
"s3Key": "my-app-id/text/f47ac10b/company-policy-document.md",
"status": "indexing"
}
}For the complete error reference, see Error Guide.
Authorizations
API Key (i.e. Rest API Key from the Dashboard).
Body
application/json
Title of the text content
Maximum string length:
500Example:
"Company Policy Document"
Text content to be processed
Maximum string length:
5000Example:
"This document outlines the company policies and procedures..."
Was this page helpful?
⌘I