Skip to content

Create Knowledge Source ​

POSThttps://api.repliz.com/public/knowledge/{knowledgeId}/source

Add a source to a knowledge: a text, questions and answers, one page of a website, or a file from Repliz Storage. The source is read in the background, so it comes back with status process. Check it with Get One Knowledge Source until it is ready, or error with an errorMessage. Reading takes a few seconds; a big file can take a minute.

Endpoint Details ​

  • Authentication: Basic Auth (Authorization: Basic Base64(AccessKey:SecretKey)) or Bearer token from Login with Repliz
  • Scope (Bearer only): knowledge:write
  • Access Tier: Standard+

Parameters ​

ParameterTypeRequiredDescription
knowledgeIdstringYesID of the knowledge, the _id from Get Knowledge.

Request Body ​

FieldTypeRequiredDescription
typestringYestext, faq, url, or file.
namestringNoName of the source, cut to 60 characters. When left out: the first line of the text, FAQ, the page title, or the file name.
textstringFor textThe text, up to 200,000 characters.
faqsarrayFor faq1 to 300 { "question", "answer" } pairs. Questions up to 500 characters, answers up to 5,000.
urlstringFor urlA public http or https page. Only this page is read, not the pages it links to.
fileIdstringFor fileID of a file in Repliz Storage, the id from Init File after Complete File. A PDF, DOCX, TXT, or MD of up to 10 MB.

Source Types ​

TypeWhat is read
textThe text as you send it. Good for product details, policies, and prices.
faqEach question with its answer, kept together. Good for questions customers often ask.
urlThe main text of one page, without its menu, header, and footer. Up to 2 MB of HTML or plain text. Pages that need a login or are built only by JavaScript can come back empty. Read it again later with Refresh Knowledge Source.
fileThe text of a PDF, DOCX, TXT, or MD file. Scanned PDFs without a text layer give no text found. The file stays in Repliz Storage; you can remove it with Remove File once the source is ready.

Limits ​

  • Up to 100 sources per knowledge.
  • All knowledge together hold up to 5,000,000 characters. A source that would go over it ends in error with how many characters are left.
  • Pages on private or reserved addresses, such as localhost or 192.168.x.x, are refused.

Example Request ​

bash
curl -X POST "https://api.repliz.com/public/knowledge/680affa5ce12f2f72916f67e/source" \
  -H "Authorization: Basic $(echo -n 'YOUR_ACCESS_KEY:YOUR_SECRET_KEY' | base64)" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "url",
    "url": "https://example.com/shipping"
  }'
javascript
import axios from 'axios';

const knowledgeId = '680affa5ce12f2f72916f67e';

const response = await axios.post(
  `https://api.repliz.com/public/knowledge/${knowledgeId}/source`,
  {
    type: 'url',
    url: 'https://example.com/shipping',
  },
  {
    auth: {
      username: 'YOUR_ACCESS_KEY',
      password: 'YOUR_SECRET_KEY',
    },
  },
);

console.log(response.data);
javascript
const credentials = btoa('YOUR_ACCESS_KEY:YOUR_SECRET_KEY');

const knowledgeId = '680affa5ce12f2f72916f67e';

const response = await fetch(`https://api.repliz.com/public/knowledge/${knowledgeId}/source`, {
  method: 'POST',
  headers: {
    Authorization: `Basic ${credentials}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    type: 'url',
    url: 'https://example.com/shipping',
  }),
});

const data = await response.json();
console.log(data);

Other Types ​

json
// text
{ "type": "text", "name": "Shipping", "text": "We ship every weekday. Orders before 2 PM go out the same day." }

// faq
{ "type": "faq", "faqs": [{ "question": "Do you ship abroad?", "answer": "Yes, to most countries." }] }

// file, uploaded with Init File and Complete File first
{ "type": "file", "fileId": "680affa5ce12f2f72916f680" }

Response ​

json
{
  "_id": "680affa5ce12f2f72916f67f",
  "type": "url",
  "name": "",
  "url": "https://example.com/shipping",
  "status": "process",
  "chars": 0,
  "knowledgeId": "680affa5ce12f2f72916f67e",
  "userId": "680affa5ce12f2f72916f600",
  "createdAt": "2026-11-14T03:04:00.000Z",
  "updatedAt": "2026-11-14T03:04:00.000Z",
  "__v": 0
}
json
{
  "code": 400,
  "message": "url points to a private or reserved address"
}

{
  "code": 400,
  "message": "file must be a PDF, DOCX, TXT, or MD"
}

{
  "code": 400,
  "message": "file upload is not complete"
}
json
{
  "code": 403,
  "message": "a knowledge can hold up to 100 sources"
}

{
  "code": 403,
  "message": "all knowledge together can hold up to 5000000 characters"
}
json
{
  "code": 404,
  "message": "knowledge not found"
}

{
  "code": 404,
  "message": "file not found"
}
json
{
  "code": 401,
  "message": "unauthorized"
}