KrosAI Docs
DashboardGet Started
  • Getting Started
    • Introduction
    • Quickstart Guide
    • Authentication
  • OpenAI SDK Compatability
  • Endpoints
    • Completions API
      • Create Chat Completion
    • Translation API
    • Text Summarization API
    • Audio Transcription API
    • Sentiment Analysis API
  • AGENT
    • Agents API
      • Create Agent
      • List Agents
      • Get Agent
      • Update Agent
      • Delete Agent
      • Start Voice Session
    • Conversations API
      • Create Conversation
      • List Conversations
      • Get Conversation
      • Get Conversation Messages
    • Knowledge Base API
      • Create Knowledge Base
      • List Knowledge Base
      • Upload Document
      • List Document
  • Resources
    • AI Voice Agents
    • In-App Voice Assistants
    • Virtual Health Assistants
    • EdTech Language Tutors
  • SDKS
    • Node.JS SDK
    • React Native SDK
    • Flutter
Powered by GitBook
On this page
  • Endpoint
  • Parameters
  • Authentication
  • Request Body
  • Response
  • Example Request
  • Example Response
  • Error Responses
  • Notes
  • Processing States
  1. AGENT
  2. Knowledge Base API

Upload Document

Uploads a document to a specific knowledge base.

Endpoint

POST /v1/knowledge-bases/{kb_id}/documents

Parameters

Parameter
Type
Required
Description

kb_id

string

Yes

ID of the knowledge base to upload to

Authentication

Requires a valid API key or user authentication token.

Request Body

Multipart form data containing the file to upload.

Request Fields

Field
Type
Required
Description

file

file

Yes

The document file to upload

Response

Returns the uploaded document's metadata.

Response Format

{
  "id": "string",
  "knowledge_base_id": "string",
  "name": "string",
  "content_type": "string",
  "size": 0,
  "created_at": "datetime",
  "status": "string",
  "error": "string"
}

Response Fields

Field
Type
Description

id

string

Unique identifier for the document

knowledge_base_id

string

ID of the knowledge base containing the document

name

string

Original filename of the document

content_type

string

MIME type of the document

size

integer

Size of the document in bytes

created_at

datetime

When the document was uploaded

status

string

Processing status ("processing", "ready", "error")

error

string

Error message if processing failed (null if successful)

Example Request

curl -X POST "https://api.krosai.com/v1/knowledge-bases/kb-a1b2c3d4-e5f6-7890-abcd-ef1234567890/documents" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "file=@/path/to/document.pdf"

Example Response

{
  "id": "doc-c3d4e5f6-g7h8-9012-cdef-gh3456789012",
  "knowledge_base_id": "kb-a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "name": "product_manual.pdf",
  "content_type": "application/pdf",
  "size": 1048576,
  "created_at": "2023-07-10T15:30:00Z",
  "status": "processing",
  "error": null
}

Error Responses

Status Code
Description

400

Bad Request - Invalid file or file type

401

Unauthorized - Invalid or missing API key

403

Forbidden - Not authorized to access this knowledge base

404

Not Found - Knowledge base not found

413

Payload Too Large - File exceeds size limit

500

Internal Server Error

Notes

  • Supported file types: PDF, TXT, DOCX, MD

  • Maximum file size: 10MB

  • Documents are processed asynchronously

  • Initial status is "processing"

  • Check document status using the list documents endpoint

  • Processing time varies based on document size and complexity

  • Failed processing will set status to "error" with explanation

Processing States

  • processing: Document is being analyzed and indexed

  • ready: Document is processed and available for agent use

  • error: Processing failed, check error field for details

PreviousList Knowledge BaseNextList Document

Last updated 2 months ago