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
| Field | Type | Required | Description |
|---|---|---|---|
file | file | Yes | The document file |
name | string | No | Display name |
accessLevel | string | No | public, authenticated, restricted |
tags | string | No | Comma-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
| Field | Type | Required | Description |
|---|---|---|---|
url | string | Yes | URL to fetch document from |
name | string | No | Display name |
accessLevel | string | No | Access 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
| Parameter | Type | Description |
|---|---|---|
page | number | Page number (default: 1) |
perPage | number | Items per page (default: 20) |
status | string | Filter by status |
type | string | Filter 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
| Status | Description |
|---|---|
pending | Waiting to process |
processing | Currently processing |
ready | Processing complete |
failed | Processing failed |