Skip to main content

Chatbot API Endpoints

Query and manage chatbots via the API.

Base URL

https://api.wizchat.com/v1

Query a Chatbot

Send a message to a chatbot and get a response.

Endpoint

POST /chatbots/{chatbotId}/query

Request

curl -X POST https://api.wizchat.com/v1/chatbots/cb_123/query \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"message": "What is your return policy?"
}'

Request Body

FieldTypeRequiredDescription
messagestringYesThe user's question
conversationIdstringNoContinue existing conversation
userIdstringNoIdentify the user
metadataobjectNoAdditional context

Response

{
"response": "Our return policy allows returns within 30 days...",
"conversationId": "conv_abc123",
"sources": [
{
"documentId": "doc_xyz",
"title": "Return Policy",
"chunk": "Returns within 30 days...",
"relevance": 0.95
}
],
"usage": {
"inputTokens": 150,
"outputTokens": 200,
"cost": 0.0025
}
}

Response Fields

FieldTypeDescription
responsestringThe chatbot's response
conversationIdstringID to continue this conversation
sourcesarrayDocuments used for the response
usageobjectToken usage and cost

List Chatbots

Get all chatbots you have access to.

Endpoint

GET /chatbots

Request

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

Response

{
"chatbots": [
{
"id": "cb_123",
"name": "Support Bot",
"description": "Customer support assistant",
"status": "active",
"createdAt": "2024-01-15T10:00:00Z"
}
],
"pagination": {
"page": 1,
"perPage": 20,
"total": 1
}
}

Get Chatbot Details

Get details about a specific chatbot.

Endpoint

GET /chatbots/{chatbotId}

Request

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

Response

{
"id": "cb_123",
"name": "Support Bot",
"description": "Customer support assistant",
"status": "active",
"settings": {
"model": "gpt-4o",
"temperature": 0.7,
"systemPrompt": "You are a helpful assistant..."
},
"stats": {
"totalQueries": 1500,
"documentsCount": 25
},
"createdAt": "2024-01-15T10:00:00Z",
"updatedAt": "2024-02-01T15:30:00Z"
}

Get Conversation History

Retrieve messages from a conversation.

Endpoint

GET /chatbots/{chatbotId}/conversations/{conversationId}

Request

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

Response

{
"conversationId": "conv_abc123",
"messages": [
{
"role": "user",
"content": "What is your return policy?",
"timestamp": "2024-02-01T10:00:00Z"
},
{
"role": "assistant",
"content": "Our return policy allows...",
"timestamp": "2024-02-01T10:00:01Z"
}
],
"metadata": {
"userId": "user_123",
"startedAt": "2024-02-01T10:00:00Z"
}
}

Streaming Responses

Get streamed responses for real-time display.

Endpoint

POST /chatbots/{chatbotId}/query/stream

Request

curl -X POST https://api.wizchat.com/v1/chatbots/cb_123/query/stream \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: text/event-stream" \
-d '{"message": "Tell me about your products"}'

Response (Server-Sent Events)

data: {"type": "start", "conversationId": "conv_abc"}

data: {"type": "chunk", "content": "We offer "}

data: {"type": "chunk", "content": "a variety of "}

data: {"type": "chunk", "content": "products..."}

data: {"type": "done", "usage": {"inputTokens": 100, "outputTokens": 150}}