Skip to main content

Document API Endpoints

Upload and manage documents via the API.

Base URL

https://api.wizchat.com/v1

Upload a Document

Upload a file to a chatbot's knowledge base.

Endpoint

POST /chatbots/{chatbotId}/documents

Request (Multipart Form)

curl -X POST https://api.wizchat.com/v1/chatbots/cb_123/documents \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@document.pdf" \
-F "name=Product Guide" \
-F "accessLevel=public"

Form Fields

FieldTypeRequiredDescription
filefileYesThe document file
namestringNoDisplay name
accessLevelstringNopublic, authenticated, restricted
tagsstringNoComma-separated tags

Response

{
"id": "doc_xyz",
"name": "Product Guide",
"status": "processing",
"size": 1024000,
"mimeType": "application/pdf",
"createdAt": "2024-02-01T10:00:00Z"
}

Upload via URL

Import a document from a URL.

Endpoint

POST /chatbots/{chatbotId}/documents/url

Request

curl -X POST https://api.wizchat.com/v1/chatbots/cb_123/documents/url \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/document.pdf",
"name": "External Document"
}'

Request Body

FieldTypeRequiredDescription
urlstringYesURL to fetch document from
namestringNoDisplay name
accessLevelstringNoAccess level

List Documents

Get all documents in a chatbot's knowledge base.

Endpoint

GET /chatbots/{chatbotId}/documents

Request

curl https://api.wizchat.com/v1/chatbots/cb_123/documents \
-H "Authorization: Bearer YOUR_API_KEY"

Query Parameters

ParameterTypeDescription
pagenumberPage number (default: 1)
perPagenumberItems per page (default: 20)
statusstringFilter by status
typestringFilter by document type

Response

{
"documents": [
{
"id": "doc_xyz",
"name": "Product Guide",
"status": "ready",
"type": "pdf",
"size": 1024000,
"chunks": 45,
"createdAt": "2024-02-01T10:00:00Z"
}
],
"pagination": {
"page": 1,
"perPage": 20,
"total": 1
}
}

Get Document Details

Get details about a specific document.

Endpoint

GET /chatbots/{chatbotId}/documents/{documentId}

Request

curl https://api.wizchat.com/v1/chatbots/cb_123/documents/doc_xyz \
-H "Authorization: Bearer YOUR_API_KEY"

Response

{
"id": "doc_xyz",
"name": "Product Guide",
"status": "ready",
"type": "pdf",
"size": 1024000,
"mimeType": "application/pdf",
"chunks": 45,
"accessLevel": "public",
"tags": ["product", "guide"],
"metadata": {
"pageCount": 20,
"author": "Marketing Team"
},
"createdAt": "2024-02-01T10:00:00Z",
"processedAt": "2024-02-01T10:01:00Z"
}

Delete a Document

Remove a document from the knowledge base.

Endpoint

DELETE /chatbots/{chatbotId}/documents/{documentId}

Request

curl -X DELETE https://api.wizchat.com/v1/chatbots/cb_123/documents/doc_xyz \
-H "Authorization: Bearer YOUR_API_KEY"

Response

{
"success": true,
"message": "Document deleted"
}

Check Processing Status

Check if a document has finished processing.

Endpoint

GET /chatbots/{chatbotId}/documents/{documentId}/status

Response

{
"id": "doc_xyz",
"status": "ready",
"progress": 100,
"chunks": 45,
"error": null
}

Status Values

StatusDescription
pendingWaiting to process
processingCurrently processing
readyProcessing complete
failedProcessing failed