Skip to main content

End-to-End Example

This guide walks through the complete workflow of creating a case, uploading evidence, and generating a technical report using the Silent Witness REST API.

Overview

1. POST /api/organizations → Create organization (optional)
2. POST /api/cases → Create case with all data
3. POST /api/files/upload → Upload damage photos (auto-linked via vehicle_role)
4. POST /api/reports → Create report (starts async processing)
5. GET /api/reports/:id → Poll until status is "completed"
6. Download PDF/DOCX → Use signed URLs from output

Prerequisites

  • An API key from the Silent Witness dashboard
  • Vehicle damage photos (JPEG or PNG)
  • Case information (accident details, vehicle info)

Step 1: Create an Organization

Organizations help you group cases by law firm or client.

curl -X POST "https://api.silentwitness.ai/api/organizations" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Smith & Associates Law Firm",
"phone_number": "555-123-4567",
"street_address": "123 Main Street, Suite 400",
"city": "San Francisco",
"state": "CA",
"zip_code": "94102",
"country": "United States"
}'

Response:

{
"success": true,
"data": {
"id": "org_abc123def456",
"name": "Smith & Associates Law Firm"
}
}

Step 2: Create a Case

Create a case with vehicles, accident information, and occupants in a single request. This example uses accident_injury which includes both crash analysis and biomechanics. For crash-only analysis, use accident_only and omit the occupants array.

curl -X POST "https://api.silentwitness.ai/api/cases" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"plaintiff_name": "John Smith",
"defendant_name": "Bob Johnson",
"attorney_name": "Jane Attorney, Esq.",
"organization_id": "org_abc123def456",
"analysis_type": "accident_injury",
"accident": {
"description": "Rear-end collision at red light",
"date": "2024-01-10",
"time": "14:30",
"location": "123 Main St at Oak Ave, Los Angeles, CA"
},
"vehicles": [
{
"role": "plaintiff",
"vehicle_maker": "Toyota",
"vehicle_model": "Camry",
"vehicle_year": "2020"
},
{
"role": "defendant",
"vehicle_maker": "Ford",
"vehicle_model": "F-150",
"vehicle_year": "2019"
}
],
"occupants": [
{
"name": "John Smith",
"age": 42,
"gender": "male",
"height_inches": 70,
"weight_lbs": 180,
"position": "driver",
"seatbelt_worn": true,
"alleged_injuries": ["cervical_spine", "lumbar_spine", "shoulder"],
"injury_severity": "moderate"
}
]
}'

Response — note the case ID is at data.case.id:

{
"success": true,
"data": {
"case": {
"id": "case_xyz789abc123",
"name": "Smith v. Johnson",
"plaintiff_name": "John Smith"
}
}
}

Step 3: Upload Vehicle Damage Photos

Upload each damage photo as multipart form-data. The API supports JPEG, PNG, GIF, and WebP images up to 50MB. Set file_category to vehicle_photo and vehicle_role to plaintiff or defendant. Files are automatically linked to the correct vehicle.

# Upload front damage photo
curl -X POST "https://api.silentwitness.ai/api/files/upload" \
-H "X-API-Key: $API_KEY" \
-F "file=@front_damage.jpg" \
-F "case_id=case_xyz789abc123" \
-F "file_category=vehicle_photo" \
-F "vehicle_role=plaintiff"

# Upload rear damage photo
curl -X POST "https://api.silentwitness.ai/api/files/upload" \
-H "X-API-Key: $API_KEY" \
-F "file=@rear_damage.jpg" \
-F "case_id=case_xyz789abc123" \
-F "file_category=vehicle_photo" \
-F "vehicle_role=plaintiff"

Response — note the file ID is at data.file_id:

{
"success": true,
"data": {
"file_id": "file_img001",
"file_name": "front_damage.jpg",
"status": "ready"
}
}

Optional: Upload a Traffic Collision Report

If you have a police Traffic Collision Report, upload it with file_category=tcr_document. TCR is case-level — do not pass vehicle_role.

curl -X POST "https://api.silentwitness.ai/api/files/upload" \
-H "X-API-Key: $API_KEY" \
-F "file=@traffic_collision_report.pdf" \
-F "case_id=case_xyz789abc123" \
-F "file_category=tcr_document"

When you later call POST /api/reports, the server automatically extracts accident details (date, time, location, description) from the TCR and populates the case before generating the report. No extra steps required.

Step 4: Create a Report

Report generation is asynchronous — this call returns immediately with status: "pending". You must poll for completion in the next step.

curl -X POST "https://api.silentwitness.ai/api/reports" \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"case_id": "case_xyz789abc123",
"type": "technical_report"
}'
Testing without ML

Add "options": {"use_demo_data": true} to use synthetic crash data. Reports complete in seconds instead of minutes.

Step 5: Poll for Completion and Download

Poll GET /api/reports/:id every 5 seconds until status is completed, then download the PDF and DOCX from the output URLs.

# Poll until completed (repeat every 5 seconds)
curl "https://api.silentwitness.ai/api/reports/rpt_abc789xyz" \
-H "X-API-Key: $API_KEY"

# Once status is "completed", download the files:
curl -o report.pdf "$PDF_URL"
curl -o report.docx "$DOCX_URL"

Completed response:

{
"success": true,
"data": {
"id": "rpt_abc789xyz",
"status": "completed",
"progress": {
"steps_completed": ["delta_v_calculation", "biomechanics_analysis", "report_generation"],
"message": "Report generation complete"
},
"output": {
"pdf_url": "https://storage.silentwitness.ai/reports/rpt_abc789xyz.pdf",
"docx_url": "https://storage.silentwitness.ai/reports/rpt_abc789xyz.docx"
}
}
}
note

Download URLs expire after 1 hour. Call GET /api/reports/:id again for fresh URLs.

Complete Working Scripts

Each language has a complete, self-contained script you can copy and run:

LanguageLocationRun command
Pythonexamples/rest-api/python/main.pyAPI_KEY=sk-... python main.py
Goexamples/rest-api/technical-report/main.goAPI_KEY=sk-... go run main.go

Next Steps