API Reference

Complete documentation for the Pravia API — integrate AI Employees, manage documents, and configure your bots programmatically.

Base URL: /api/chat (relative)

Authentication

Dashboard (Session Cookie)

Dashboard API calls use your session cookie for authentication. No API key required — just log in.

Widget (Public)

The widget chat endpoint is public and rate-limited. No authentication needed — just the bot ID.

Authorization Header Example

curl -X POST "/api/chat" \
  -H "Content-Type: application/json" \
  -d '{
    "botId": "your-bot-id",
    "query": "Hello!"
  }'

Chat Endpoints

POST/api/chat
ParameterTypeRequiredDescription
botIdstringYesThe unique identifier of your bot.
querystringYesThe user's message text (max 2000 characters).
conversationIdstringNoOptional conversation ID for maintaining context across multiple requests.
modelstringNoOverride the default model (optional).

Request Example

{
  "botId": "bot_abc123",
  "query": "What is your return policy?",
  "conversationId": "conv_xyz789"
}

Response Example

{
  "conversationId": "conv_xyz789",
  "answer": "Our return policy allows returns within 30 days of purchase.",
  "sources": [
    { "chunkId": "...", "documentId": "...", "content": "...", "score": 0.92 }
  ],
  "offline": false
}
POST/api/widget/chat

Public endpoint for client-side widget usage. Supports botId, query, conversationId, and visitorId. Rate-limited to 10 requests per minute per IP. No authentication required.

Bot Management

GET/api/bots

Retrieve a list of all your bots.

curl -X GET "/api/bots" \
  -H "Content-Type: application/json"
POST/api/bots

Create a new bot with the specified configuration.

ParameterTypeRequiredDescription
namestringYesBot name (1-64 characters).
descriptionstringNoOptional description of your bot's purpose.
modelstringNoDefault model for this bot.
{
  "name": "Support Bot",
  "description": "Answers customer questions based on our knowledge base",
  "model": "pravia"
}

Document Management

GET/api/documents

Retrieve all documents for a specific bot.

ParameterTypeRequiredDescription
botIdstringYesFilter documents by bot.
POST/api/documents

Add knowledge sources to a bot. Supports: file upload (PDF, Markdown, DOCX, TXT), URL extraction (Website), Sitemap XML import, or raw text. Use multipart/form-data for files, or JSON for URL/text/sitemap.

Rate Limits

EndpointRate Limit
Widget Chat (/api/widget/chat)10 req/min per IP
Dashboard API (/api/chat, /api/bots, /api/documents)30 req/min per user

Error Responses

CodeHTTP StatusDescription
400400Bad request. Returns a string error message like 'botId is required', 'query is required', or 'Query too long'.
401401Unauthorized. Session cookie missing or invalid.
403403Forbidden. Billing limit reached or access denied.
404404Not found. Bot not found or inactive.
503503Service temporarily unavailable. Billing limit exceeded.
500500Internal server error.

Endpoint Summary

MethodEndpointAuthDescription
POST/api/chatSessionSend a message to a bot and receive an AI-generated reply.
POST/api/widget/chatPublicSend a message from the widget with rate limiting.
GET/api/botsSessionList all bots in your account.
POST/api/botsSessionCreate a new bot.
GET/api/bots/:idSessionRetrieve a single bot by ID.
GET/api/documentsSessionList documents for a bot.
POST/api/documentsSessionUpload a document to a bot.

Ready to integrate?