Spaces:
Sleeping
Sleeping
File size: 4,475 Bytes
36a486d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# vBot API Documentation
## Overview
The vBot API provides endpoints for call processing and customer management. All API requests require authentication using an API key.
## Authentication
All API requests must include your API key in the `X-API-Key` header:
```bash
curl -X POST https://vbot-server.com/api/process-call \
-H "X-API-Key: your_api_key" \
-H "Content-Type: multipart/form-data" \
-F "file=@/path/to/call.wav"
```
## Endpoints
### Call Processing
#### Process Call
```http
POST /api/process-call
```
Process a call recording and receive analysis results via webhook.
**Headers:**
- `X-API-Key`: Your API key
- `Content-Type`: multipart/form-data
**Parameters:**
- `file`: Call recording file (WAV format)
- `caller_number`: Caller's phone number
- `called_number`: Called phone number
**Response:**
```json
{
"status": "success",
"message": "Call processing started",
"call_id": "uuid"
}
```
**Webhook Payload:**
```json
{
"call_id": "uuid",
"caller_number": "+1234567890",
"called_number": "+0987654321",
"transcription": "Call transcript...",
"summary": "Call summary...",
"sentiment": "positive",
"keywords": "keyword1, keyword2",
"timestamp": "2024-03-14T12:00:00Z",
"customer_id": 123
}
```
### Customer Management
#### List Customers (Admin Only)
```http
GET /api/customers
```
List all customers.
**Headers:**
- `Authorization`: Bearer token (admin only)
**Response:**
```json
{
"customers": [
{
"id": 1,
"name": "Customer Name",
"company_name": "Company Name",
"email": "customer@example.com",
"api_key": "api_key_here",
"is_active": true,
"created_at": "2024-03-14T12:00:00Z",
"updated_at": "2024-03-14T12:00:00Z"
}
]
}
```
#### Create Customer (Admin Only)
```http
POST /api/customers
```
Create a new customer.
**Headers:**
- `Authorization`: Bearer token (admin only)
- `Content-Type`: application/json
**Request Body:**
```json
{
"name": "Customer Name",
"company_name": "Company Name",
"email": "customer@example.com"
}
```
**Response:**
```json
{
"id": 1,
"name": "Customer Name",
"company_name": "Company Name",
"email": "customer@example.com",
"api_key": "generated_api_key",
"is_active": true,
"created_at": "2024-03-14T12:00:00Z",
"updated_at": "2024-03-14T12:00:00Z"
}
```
#### Update Customer (Admin Only)
```http
PUT /api/customers/{customer_id}
```
Update customer details.
**Headers:**
- `Authorization`: Bearer token (admin only)
- `Content-Type`: application/json
**Request Body:**
```json
{
"name": "Updated Name",
"company_name": "Updated Company",
"email": "updated@example.com",
"is_active": true
}
```
**Response:**
```json
{
"id": 1,
"name": "Updated Name",
"company_name": "Updated Company",
"email": "updated@example.com",
"api_key": "existing_api_key",
"is_active": true,
"created_at": "2024-03-14T12:00:00Z",
"updated_at": "2024-03-14T12:00:00Z"
}
```
#### Delete Customer (Admin Only)
```http
DELETE /api/customers/{customer_id}
```
Delete a customer.
**Headers:**
- `Authorization`: Bearer token (admin only)
**Response:**
```json
{
"status": "success",
"message": "Customer deleted successfully"
}
```
### Health Check
#### Check API Health
```http
GET /health
```
Check API health status.
**Response:**
```json
{
"status": "healthy",
"version": "1.0.0",
"timestamp": "2024-03-14T12:00:00Z"
}
```
## Error Responses
All endpoints may return the following error responses:
### 401 Unauthorized
```json
{
"status": "error",
"message": "Invalid API key"
}
```
### 403 Forbidden
```json
{
"status": "error",
"message": "Insufficient permissions"
}
```
### 404 Not Found
```json
{
"status": "error",
"message": "Resource not found"
}
```
### 400 Bad Request
```json
{
"status": "error",
"message": "Invalid request parameters"
}
```
### 500 Internal Server Error
```json
{
"status": "error",
"message": "Internal server error"
}
```
## Rate Limits
- API requests are limited to 100 requests per minute per API key
- Webhook delivery attempts are limited to 3 retries
- Call processing is limited to 10 concurrent calls per customer
## Best Practices
1. Always use HTTPS for API requests
2. Store API keys securely
3. Implement webhook retry logic
4. Monitor API usage and rate limits
5. Keep API keys confidential
6. Use appropriate error handling
7. Implement request timeouts
8. Monitor webhook delivery status |