API Documentation
Complete reference for all available endpoints and payloads
🔍 Quick Navigation
Core Endpoints
Health Check
GET/health
Check if the API is running and healthy.
Host: localhost:5001
response = requests.get('http://localhost:5001/health')
print(response.json())
File Upload
POST/upload
Upload a document file for data transformation and processing.
Parameters
| Parameter | Type | Description |
|---|---|---|
| file Required | file | Document file (PDF, Excel, CSV, etc.) |
| lob Required | string | Line of Business (GeneralLiability, Property, etc.) |
Host: localhost:5001
Content-Type: multipart/form-data
file=@document.pdf
lob=GeneralLiability
-F "file=@document.pdf" \
-F "lob=GeneralLiability"
files = {'file': open('document.pdf', 'rb')}
data = {'lob': 'GeneralLiability'}
response = requests.post('http://localhost:5001/upload', files=files, data=data)
Job Management
Get Job Status
GET/api/jobs/<job_id>
Retrieve the status and results of a specific job.
Parameters
| Parameter | Type | Description |
|---|---|---|
| job_id Required | string (UUID) | The unique job identifier |
Host: localhost:5001
response = requests.get('http://localhost:5001/api/jobs/f47ac10b-58cc-4372-a567-0e02b2c3d479')
print(response.json())
Submit Correction
POST/api/jobs/<job_id>/submit_correction
Submit corrected JSON to improve RAG system training data.
Parameters
| Parameter | Type | Description |
|---|---|---|
| job_id Required | string (UUID) | The unique job identifier |
| corrected_json Required | string | Corrected JSON output as string |
Host: localhost:5001
Content-Type: application/json
{ "corrected_json": "{...}" }
-H "Content-Type: application/json" \
-d '{"corrected_json": "{...}"}'
corrected_data = {"policyNumber": "POL-001", "coverage": []}
response = requests.post(
f'http://localhost:5001/api/jobs/{job_id}/submit_correction',
json={'corrected_json': json.dumps(corrected_data)}
)
File Downloads
Download Original File
GET/download/file/<job_id>
Download the original uploaded file for a specific job.
Parameters
| Parameter | Type | Description |
|---|---|---|
| job_id Required | string (UUID) | The unique job identifier |
Host: localhost:5001
Content-Type: application/pdf
Content-Disposition: attachment; filename="document.pdf"
(binary file data)
-o original_document.pdf
response = requests.get('http://localhost:5001/download/file/f47ac10b-58cc-4372-a567-0e02b2c3d479')
with open('document.pdf', 'wb') as f:
f.write(response.content)
Download Result JSON
GET/download/result/<job_id>
Download the JSON result for a specific job.
Parameters
| Parameter | Type | Description |
|---|---|---|
| job_id Required | string (UUID) | The unique job identifier |
Host: localhost:5001
Content-Type: application/json
Content-Disposition: attachment; filename="result.json"
{ "policyNumber": "...", "coverage": [...], ... }
-o result.json
response = requests.get('http://localhost:5001/download/result/f47ac10b-58cc-4372-a567-0e02b2c3d479')
result = response.json()
print(json.dumps(result, indent=2))
Download Schema
GET/download/schema/<lob>
Download the JSON schema for a specific line of business.
Parameters
| Parameter | Type | Description |
|---|---|---|
| lob Required | string | Line of Business (AccidentHealth, CyberLiability, FreightLiability, GeneralLiability, ManagementLiability, MarineCargo, PollutionLiability, ProfessionalIndemnity, Property) |
Host: localhost:5001
Content-Type: application/json
Content-Disposition: attachment; filename="general_liability_schema.json"
{ "type": "object", "properties": {...}, "required": [...] }
-o general_liability_schema.json
response = requests.get('http://localhost:5001/download/schema/GeneralLiability')
schema = response.json()
print(json.dumps(schema, indent=2))
Training Examples
Get Training Examples
GET/api/training_examples
Retrieve all training examples collected from user corrections. Useful for monitoring RAG system learning progress.
Host: localhost:5001
response = requests.get('http://localhost:5001/api/training_examples')
data = response.json()
print(f"Total examples: {data['count']}")
print(f"RAG enabled: {data['rag_enabled']}")
HTTP Status Codes & Errors
Successful request
Redirect (form-based upload)
Invalid parameters or missing required fields
Resource (job, file, schema) not found
Server error during processing
Complete Workflow Example
Here's a complete workflow demonstrating all key operations:
BASE_URL = "http://localhost:5001"
# 1. Health check
response = requests.get(f'{BASE_URL}/health')
print(f"✓ API Status: {response.json()['status']}")
# 2. Upload file
with open('policy.pdf', 'rb') as f:
files = {'file': f}
data = {'lob': 'GeneralLiability'}
response = requests.post(f'{BASE_URL}/upload', files=files, data=data)
job_id = response.json()['job_id']
print(f"✓ Job created: {job_id}")
# 3. Poll job status
for attempt in range(30):
response = requests.get(f'{BASE_URL}/api/jobs/{job_id}')
status = response.json()['status']
print(f" Attempt {attempt+1}: {status}")
if status in ['completed', 'failed']:
break
time.sleep(2)
# 4. Download result
response = requests.get(f'{BASE_URL}/download/result/{job_id}')
result = response.json()
print(f"✓ Result: {json.dumps(result, indent=2)[:100]}...")
# 5. Submit correction (optional)
corrected = {"policyNumber": "POL-001", "coverage": []}
response = requests.post(
f'{BASE_URL}/api/jobs/{job_id}/submit_correction',
json={'corrected_json': json.dumps(corrected)}
)
print(f"✓ Correction submitted: {response.json()['example_id']}")
# 6. Get training examples
response = requests.get(f'{BASE_URL}/api/training_examples')
count = response.json()['count']
print(f"✓ Total training examples: {count}")
📚 Additional Resources
- 📋 View Jobs - See all processing jobs
- 📖 Training Examples - View RAG training data
- 🏗️ System Architecture - Learn system design
- 🔗 Postman Collection: Available at
/docs/postman_collection.json - 📝 Full Documentation: Available at
/docs/API_ENDPOINTS_DOCUMENTATION.md