SkyLight Chat
API Reference

Knowledge Base

Manage the AI knowledge base that powers automated responses across your channels.

Overview

The Knowledge Base stores information your AI agent uses when answering contact questions. The API supports all five content types - text, documents, voice transcriptions, product catalogs, and website scraping.

TypeDescriptionProcessing
textStructured text (FAQs, policies, instructions)Synchronous
documentPDF, Word, Excel, TXT, CSV - AI extracts contentSynchronous
voiceAudio file — transcribed automaticallySynchronous
product_catalogProducts via JSON array or CSVSynchronous
websiteWebsite crawl - async job, poll /statusAsync

How the AI uses this in chat

Active entries of all types help AI agent replies on WhatsApp, Telegram, Instagram, and web chat. Document and website entries contribute searchable text; voice entries store transcripts; product catalogs supply structured fields and can reference linked media.

Together with the Media library, agents can attach images, videos, and files to outbound messages when your setup calls for it (for example catalog-linked assets or items you uploaded under Media). On inbound messages, audio is typically transcribed to text for the model, and images are analyzed so the assistant can reason about what the customer sent (channel and configuration dependent).


The KnowledgeBase object

{
  "id": 88,
  "title": "Return Policy",
  "type": "text",
  "description": "Customer return and refund policy",
  "business_description": "Used by the sales AI to answer returns-related questions",
  "status": "active",
  "embedding_updated_at": "2026-03-07T10:00:00.000000Z",
  "created_at": "2026-02-15T08:00:00.000000Z",
  "updated_at": "2026-03-07T10:00:00.000000Z"
}
FieldTypeDescription
idintegerUnique entry ID
titlestringDisplay name
typestringtext, document, voice, product_catalog, website
descriptionstring|nullBrief summary of the entry
business_descriptionstring|nullContext for how the AI should use this entry
statusstringactive or inactive
embedding_updated_atstring|nullWhen this entry was last prepared for AI search

List knowledge base entries

GET /api/v1/knowledge-base
ParameterTypeDescription
typestringFilter by text, document, voice, product_catalog, website
statusstringactive, inactive
per_pageintegerMax 100 (default 25)

Create a text entry

POST /api/v1/knowledge-base
Content-Type: application/json
FieldTypeRequiredNotes
titlestring
contentstringThe knowledge text (the AI reads this)
descriptionstringNoBrief summary
business_descriptionstringNoContext for AI usage
statusstringNoactive or inactive (default: active)
curl -X POST https://dashboard.skylightchat.com/api/v1/knowledge-base \
  -H "X-Api-Key: ••••••••••••" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "30-Day Return Policy",
    "content": "We offer a full refund for any item returned within 30 days of purchase.",
    "description": "Customer return and refund policy",
    "business_description": "Used by the customer support AI to answer returns questions."
  }'

Returns 201 Created. Embeddings are generated asynchronously.


Upload a document

POST /api/v1/knowledge-base/document
Content-Type: multipart/form-data

Upload one or more files. The AI automatically extracts and structures the content. Supports PDF, DOCX, DOC, XLSX, CSV, and TXT up to 20 MB each.

FieldTypeRequiredNotes
titlestring
files[]fileOne or more files (PDF, DOCX, XLSX, CSV, TXT)
descriptionstringNo
business_descriptionstringNo
statusstringNoactive or inactive
curl -X POST https://dashboard.skylightchat.com/api/v1/knowledge-base/document \
  -H "X-Api-Key: ••••••••••••" \
  -F "title=Product Manual" \
  -F "files[]=@/path/to/manual.pdf" \
  -F "business_description=Used to answer product-specific questions."

Response (201 Created)

{
  "success": true,
  "data": {
    "knowledge_base": { "id": 91, "title": "Product Manual", "type": "document" },
    "documents": [
      {
        "id": 12,
        "original_name": "manual.pdf",
        "file_type": "pdf",
        "processing_status": "completed",
        "extracted_content": "Chapter 1: Getting Started..."
      }
    ]
  }
}

Document processing statuses

StatusMeaning
pendingQueued
processingAI is extracting content
completedContent extracted successfully
failedExtraction failed - see processing_error

Upload a voice note

POST /api/v1/knowledge-base/voice
Content-Type: multipart/form-data

Upload an audio file. Transcription is performed synchronously. Max 10 MB. Supports MP3, WAV, M4A, OGG, WEBM.

FieldTypeRequiredNotes
titlestring
audio_filefileMP3, WAV, M4A, OGG, WEBM
languagestringNoISO 639-1 code e.g. ar, en (default: auto-detect)
descriptionstringNo
business_descriptionstringNo
statusstringNoactive or inactive
curl -X POST https://dashboard.skylightchat.com/api/v1/knowledge-base/voice \
  -H "X-Api-Key: ••••••••••••" \
  -F "title=CEO Welcome Message" \
  -F "audio_file=@/path/to/welcome.mp3" \
  -F "language=en"

Response (201 Created)

{
  "success": true,
  "data": {
    "knowledge_base": { "id": 92, "title": "CEO Welcome Message", "type": "voice" },
    "voice_note": {
      "id": 5,
      "transcription_status": "completed",
      "transcription": "مرحباً بك في نخيل. We are committed to delivering..."
    }
  }
}

Create a product catalog

POST /api/v1/knowledge-base/product-catalog
Content-Type: application/json  (or multipart/form-data for CSV)

Create a product catalog with products via a JSON array, a CSV file upload, or both.

FieldTypeRequiredNotes
titlestring
productsarray*JSON array of product objects
csv_filefile*CSV file (see columns below)
descriptionstringNo
business_descriptionstringNo
statusstringNoactive or inactive

* At least one of products or csv_file is required.

Product object fields

FieldTypeRequiredNotes
product_namestring
product_descriptionstringNo
skustringNo
pricenumberNo
currencystringNoDefault: USD
categorystringNo
stock_quantityintegerNo
image_urlstringNo
is_availablebooleanNoDefault: true
product_attributesobjectNoExtra metadata (source, purchase link, integration fields)

CSV column names: product_name (or name), description, sku, price, currency, category, stock (or stock_quantity), image_url

Product response fields

When you list or get a product_catalog entry, each product includes the create fields above plus:

FieldTypeDescription
idintegerProduct ID
media_filesarrayLinked media library items (when present)
product_attributesobjectSource metadata (e.g. source, purchase_url, integration IDs)
purchase_urlstring|nullConvenience field — checkout/product page URL from product_attributes.purchase_url when set

purchase_url is populated for products synced from Salla, website crawls (when a product page URL was extracted), and any catalog that stores a purchase link in product_attributes.

# JSON array
curl -X POST https://dashboard.skylightchat.com/api/v1/knowledge-base/product-catalog \
  -H "X-Api-Key: ••••••••••••" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Summer 2026 Collection",
    "products": [
      {
        "product_name": "Linen Shirt",
        "product_description": "Breathable linen shirt for warm weather",
        "sku": "LS-001",
        "price": 49.99,
        "currency": "USD",
        "category": "Shirts",
        "stock_quantity": 120,
        "is_available": true
      }
    ]
  }'
# CSV upload
curl -X POST https://dashboard.skylightchat.com/api/v1/knowledge-base/product-catalog \
  -H "X-Api-Key: ••••••••••••" \
  -F "title=Summer 2026 Collection" \
  -F "csv_file=@/path/to/products.csv"

Response (201 Created)

{
  "success": true,
  "data": {
    "knowledge_base": { "id": 93, "title": "Summer 2026 Collection", "type": "product_catalog" },
    "products_created": 1,
    "products": [
      {
        "id": 41,
        "product_name": "Linen Shirt",
        "sku": "LS-001",
        "price": 49.99,
        "currency": "USD",
        "stock_quantity": 120,
        "is_available": true,
        "product_attributes": {},
        "purchase_url": null
      }
    ]
  }
}

Example product from a synced store or website crawl:

{
  "id": 912,
  "product_name": "فستان صيفي",
  "sku": "DRS-42",
  "price": 199,
  "currency": "SAR",
  "is_available": true,
  "product_attributes": {
    "source": "salla",
    "purchase_url": "https://store.salla.sa/product/912"
  },
  "purchase_url": "https://store.salla.sa/product/912"
}

Add products to an existing catalog

POST /api/v1/knowledge-base/{id}/products

Accepts the same products array and/or csv_file as above. Appends to the existing catalog.

Remove a product

DELETE /api/v1/knowledge-base/{id}/products/{product_id}

Returns 204 No Content.


Crawl a website

POST /api/v1/knowledge-base/website
Content-Type: application/json

Submit a website URL for crawling. The job is dispatched asynchronously - you receive a 202 Accepted immediately, then poll GET /knowledge-base/{id}/status to track progress.

Products found while crawling are synced into a dedicated product_catalog knowledge base (titled like Website Products — example.com), not left only as website prose. Each product can include price, SKU, image, and purchase_url when available. Company/help content stays on the website entry. List catalogs with GET /api/v1/knowledge-base?type=product_catalog.
FieldTypeRequiredNotes
titlestring
website_urlstringValid URL
sitemap_urlstringNoProvide sitemap for faster discovery
crawl_entire_sitebooleanNoDefault: false
max_pagesintegerNo1-100, default 10
max_depthintegerNo1-5, default 2
allowed_pathsstringNoComma-separated path prefixes to include e.g. /docs,/help
excluded_pathsstringNoComma-separated path prefixes to skip e.g. /blog,/careers
descriptionstringNo
business_descriptionstringNo
statusstringNoactive or inactive
curl -X POST https://dashboard.skylightchat.com/api/v1/knowledge-base/website \
  -H "X-Api-Key: ••••••••••••" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "مركز مساعدة نخيل",
    "website_url": "https://help.nakheel.sa",
    "crawl_entire_site": true,
    "max_pages": 50,
    "excluded_paths": "/status,/login"
  }'

Response (202 Accepted)

{
  "success": true,
  "data": {
    "knowledge_base": { "id": 94, "title": "مركز مساعدة نخيل", "type": "website" },
    "website": {
      "id": 8,
      "website_url": "https://help.nakheel.sa",
      "crawl_status": "pending",
      "pages_crawled": 0,
      "total_pages_found": 0
    }
  }
}

Crawl status values

StatusMeaning
pendingJob is queued
crawlingActively crawling pages
completedAll pages extracted
partialSome pages extracted, some failed
failedCrawl failed entirely - see crawl_error

After completed, if the crawl extracted sellable products, a related product_catalog entry is created or updated automatically. Poll until the website status is complete, then fetch GET /api/v1/knowledge-base?type=product_catalog (or open the catalog in the dashboard) to read structured products with purchase_url / product_attributes.


Poll processing status

GET /api/v1/knowledge-base/{id}/status

Returns real-time progress for any entry type. Especially useful for website (async) and to verify document/voice processing completed.

Website status example

{
  "success": true,
  "data": {
    "id": 94,
    "title": "مركز مساعدة نخيل",
    "type": "website",
    "crawl_status": "crawling",
    "pages_crawled": 12,
    "total_pages": 50,
    "progress_pct": 24,
    "crawl_error": null,
    "last_crawled_at": null,
    "completed": false
  }
}

Document status example

{
  "success": true,
  "data": {
    "id": 91,
    "type": "document",
    "completed": true,
    "total": 2,
    "pending_count": 0,
    "failed_count": 0,
    "documents": [
      { "id": 12, "original_name": "manual.pdf", "processing_status": "completed" },
      { "id": 13, "original_name": "warranty.pdf", "processing_status": "completed" }
    ]
  }
}

Get an entry

GET /api/v1/knowledge-base/{id}

Returns the full entry with all associated content (documents, voice notes, products, or website details) depending on the type.

For product_catalog, the products array includes product_attributes and purchase_url (see Product response fields).


Update an entry

PUT /api/v1/knowledge-base/{id}
FieldTypeNotes
titlestring
contentstringOnly for text type. Changing content refreshes how the entry is used for AI answers
descriptionstring
business_descriptionstring
statusstringactive or inactive

Delete an entry

DELETE /api/v1/knowledge-base/{id}

Permanently removes the entry and all associated files. Returns 204 No Content.

Deleting an active knowledge base entry may affect AI response quality immediately.

Chunks

Chunks are text segments the AI can use when answering questions. Entries are usually split automatically when content is processed; you can also list, create, update, or delete individual chunks via the API.

Create and update require the chunk to be ready for AI search before they succeed. Delete permanently removes the chunk from the knowledge base.

The Chunk object

{
  "id": 412,
  "knowledge_base_id": 88,
  "content": "We offer a full refund for any item returned within 30 days of purchase.",
  "char_count": 72,
  "chunk_index": 0,
  "total_chunks": 3,
  "context_header": null,
  "keywords": null,
  "has_embedding": true,
  "created_at": "2026-03-07T10:00:00+00:00",
  "updated_at": "2026-03-07T10:00:00+00:00"
}
FieldTypeDescription
idintegerUnique chunk ID
knowledge_base_idintegerParent knowledge base entry
contentstringChunk text available to the AI
char_countintegerLength of content
chunk_indexintegerZero-based order within the entry
total_chunksintegerTotal chunks on this entry
context_headerstring|nullOptional context prefix
keywordsarray|nullOptional keywords
has_embeddingbooleanWhether the chunk is ready for AI search

List chunks

GET /api/v1/knowledge-base/{id}/chunks

Returns chunks ordered by chunk_index.

{
  "success": true,
  "data": {
    "knowledge_base_id": 88,
    "chunks": [ { "id": 412, "chunk_index": 0, "content": "..." } ],
    "count": 1
  }
}

Get a chunk

GET /api/v1/knowledge-base/{id}/chunks/{chunk_id}

Create a chunk

POST /api/v1/knowledge-base/{id}/chunks
Content-Type: application/json
FieldTypeRequiredNotes
contentstringMax 65,000 characters. Must be processable for AI search — if processing fails, the chunk is not created.

Returns 201 Created with the chunk object.

curl -X POST https://dashboard.skylightchat.com/api/v1/knowledge-base/88/chunks \
  -H "X-Api-Key: ••••••••••••" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Refunds are issued to the original payment method within 5–7 business days."
  }'

Update a chunk

PUT /api/v1/knowledge-base/{id}/chunks/{chunk_id}
FieldTypeRequiredNotes
contentstringMax 65,000 characters. Updates this chunk and refreshes it for AI search.

Delete a chunk

DELETE /api/v1/knowledge-base/{id}/chunks/{chunk_id}

Permanently removes the chunk from the knowledge base. Returns 204 No Content.

curl -X DELETE https://dashboard.skylightchat.com/api/v1/knowledge-base/88/chunks/412 \
  -H "X-Api-Key: ••••••••••••"
Deleting a chunk immediately removes it from AI retrieval for that entry.