API Reference Overview
The Helpline Service provides a comprehensive REST API for case management, user management, communications, and reporting.
Base URL
http://localhost:8888/api/v1Authentication
All API requests require authentication headers:
bash
curl -H "Authorization: Bearer YOUR_TOKEN" \
http://localhost:8888/api/v1/casesResponse Format
All responses are JSON:
json
{
"status": "success|error",
"data": {},
"message": "Description",
"timestamp": "2024-01-20T15:35:00Z"
}Main Endpoints
Cases
GET /cases- List all casesPOST /cases- Create new caseGET /cases/{id}- Get case detailsPUT /cases/{id}- Update caseDELETE /cases/{id}- Delete case
Clients
GET /clients- List clientsPOST /clients- Create clientGET /clients/{id}- Get client detailsPUT /clients/{id}- Update client
Users
GET /users- List usersPOST /users- Create userPUT /users/{id}- Update userDELETE /users/{id}- Delete user
Communications
GET /communications- List messagesPOST /communications- Send messageGET /communications/{id}- Get message details
Dashboard
GET /dashboard/stats- Dashboard statisticsGET /dashboard/cases-by-type- Cases breakdownGET /dashboard/agent-performance- Agent metrics
Common Parameters
Pagination
bash
GET /cases?page=1&limit=20&sort=created_at&order=descFiltering
bash
GET /cases?status=open&type=abuse&created_after=2024-01-01Sorting
bash
GET /cases?sort=created_at&order=descError Handling
Errors return appropriate HTTP status codes:
json
{
"status": "error",
"message": "Case not found",
"code": 404
}Common Errors:
400Bad Request - Invalid parameters401Unauthorized - Missing or invalid token403Forbidden - Insufficient permissions404Not Found - Resource doesn't exist500Server Error - Internal error
Rate Limiting
- Rate limit: 1000 requests per hour
- Headers:
X-RateLimit-Remaining,X-RateLimit-Reset
API Documentation
Detailed endpoint documentation:
Getting Started
- Authenticate: Get API token from login
- Make Request: Include token in Authorization header
- Parse Response: Handle JSON response
- Handle Errors: Implement error handling
Code Examples
JavaScript/Node.js
javascript
const API_URL = 'http://localhost:8888/api/v1';
const TOKEN = 'your-api-token';
async function getCases() {
const response = await fetch(`${API_URL}/cases`, {
headers: {
'Authorization': `Bearer ${TOKEN}`,
'Content-Type': 'application/json'
}
});
const data = await response.json();
return data.data; // API wraps data in 'data' field
}Python
python
import requests
API_URL = 'http://localhost:8888/api/v1'
TOKEN = 'your-api-token'
headers = {
'Authorization': f'Bearer {TOKEN}',
'Content-Type': 'application/json'
}
response = requests.get(f'{API_URL}/cases', headers=headers)
data = response.json()
cases = data['data']cURL
bash
curl -H "Authorization: Bearer YOUR_TOKEN" \
http://localhost:8888/api/v1/casesWebhooks
Webhooks notify your system of important events:
bash
POST /webhooks/subscribe
{
"event": "case.created",
"url": "https://your-app.com/webhook"
}Events:
case.createdcase.updatedcase.closeduser.createdmessage.received
Rate Limits & Quotas
| Endpoint | Limit |
|---|---|
| Cases | 1000/hr |
| Users | 500/hr |
| Communications | 2000/hr |
| Dashboard | 500/hr |
Versioning
API follows semantic versioning:
v1- Current stable versionv2- Future version (planned)
Upgrade path provided for backward compatibility.
Support
For detailed endpoint documentation, see individual API sections or visit the interactive API documentation at:
http://localhost:8888/api/docs