Getting Started with the Chat Aid API
Learn how to authenticate, make your first request, and understand error handling.
Overview
The Chat Aid API provides programmatic access to your organization's knowledge base. Query your connected data sources and receive AI-generated answers with source citations.
Base URL: https://api.chataid.com
Content Type: application/json
Quick Start
1. Get an API Key
- Navigate to Settings → Custom APIs
- Click + New API Key
- Configure:
- Name: Descriptive identifier
- Teams: Select accessible data sources
- Search Settings: Configure behavior (Quick/Deep)
- Persona: Optional AI personality
- Click Create and copy your key immediately
API keys are shown only once. Never expose them in client-side code or commit to version control.
2. Make Your First Request
curl -X POST https://api.chataid.com/chat/completions/custom \
-H "Authorization: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt": "What is our refund policy?"}'
Response:
{
"ok": true,
"promptId": "65e1c08202791119fbe1d476",
"pollEndpoint": "https://api.chataid.com/chat/completions/custom/65e1c08202791119fbe1d476",
"timeInterval": 5000
}
3. Poll for the Answer
curl https://api.chataid.com/chat/completions/custom/65e1c08202791119fbe1d476 \
-H "Authorization: YOUR_API_KEY"
When ready (canPoll: false):
{
"ok": true,
"data": {
"canPoll": false,
"response": "Our refund policy allows...",
"sources": {
"formatted": "**Sources:**\n- [Refund Policy](https://...)",
"raw": [{"name": "Refund Policy", "provider": "confluence", "url": "https://..."}]
}
}
}
See Asking Questions for full implementations in JavaScript, Python, and cURL including polling logic.
Authentication
Include your API key in the Authorization header:
Authorization: YOUR_API_KEY
Chat Aid does not use a "Bearer " prefix. Include only the API key.
Authentication Errors
| Error Message | Solution |
|---|---|
Unauthorized: No Authorization Token Provided | Add Authorization: YOUR_API_KEY header |
Unauthorized: Invalid Access Token | Generate a new API key in Settings → Custom APIs |
Error Handling
All errors return a consistent format:
{
"ok": false,
"message": "Human-readable error description"
}
Common Errors
| Status | Error | Solution |
|---|---|---|
| 401 | Unauthorized: No Authorization Token Provided | Add Authorization header |
| 401 | Unauthorized: Invalid Access Token | Generate new API key |
| 403 | You are forbidden from accessing this resource | Check API key permissions |
| 426 | You have reached your limit for this billing cycle | Upgrade plan or wait for reset |
Basic Error Handling
const response = await fetch('https://api.chataid.com/chat/completions/custom', {
method: 'POST',
headers: {
'Authorization': API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({ prompt: 'What is our refund policy?' })
});
const data = await response.json();
if (!data.ok) {
throw new Error(`API Error: ${data.message}`);
}
Best Practices
Security
- Never expose API keys in client-side code
- Store keys in environment variables
- Rotate keys every 90 days
- Create separate keys per application
Performance
- Cache responses for 30-60 minutes
- Respect the
timeIntervalwhen polling - Stop polling when
canPollisfalse - Set reasonable timeouts (60-300 seconds)
Error Handling
- Implement exponential backoff for 5xx errors
- Log errors with context (prompt ID, timestamp)
- Handle all error codes gracefully
Data Access
- Assign appropriate teams to each API key
- Use
wikiFiltersto restrict search scope - Test with sample data before production
Next Steps
Core Endpoints
-
Asking Questions - Query your knowledge base
- Complete request/response documentation
- Polling implementation examples
- Wiki filters and conversation threading
-
Training Sources - Manage file uploads
- Upload, list, retrieve, and delete files
- Bulk operations and filtering
Configuration
- Custom APIs Settings - Configure API keys and permissions
- Data Sources - Understand accessible data
Support
- Documentation: Complete docs
- Support: In-app chat or email
- Settings: Manage API keys