Upload File
Uploads a file to an existing case. Files can be vehicle damage photos or EDR data.
Endpoint
POST /api/files/upload
Authentication
Requires API Key authentication.
Request
This endpoint uses multipart/form-data for file upload.
Form Fields
| Field | Type | Required | Description |
|---|---|---|---|
file | file | Yes | The file to upload |
case_id | string | Yes | Case ID to associate the file with |
file_category | string | No | File category (see below) |
vehicle_role | string | No | plaintiff (default) or defendant |
File Categories
| Value | Description | Accepted Types | Notes |
|---|---|---|---|
vehicle_photo | Vehicle damage photos | Images | Upload 4-8 photos for best results |
edr_document | Event Data Recorder (crash data) | PDF only | Replaces previous EDR if one exists |
tcr_document | Traffic Collision Report (police report) | Accident fields are extracted automatically during report generation |
Supported File Types
| Type | MIME type | Extensions | Use Case |
|---|---|---|---|
| JPEG | image/jpeg | .jpg, .jpeg | Vehicle damage photos |
| PNG | image/png | .png | Vehicle damage photos |
| GIF | image/gif | .gif | Vehicle damage photos |
| WebP | image/webp | .webp | Vehicle damage photos |
application/pdf | .pdf | EDR reports, medical records, other documents |
The server determines the file type by inspecting the file's bytes, not by trusting the Content-Type header your client sends. Uploads whose detected type is not in the table above are rejected with 400 Bad Request — the error message includes the detected type so you can tell what happened.
File Constraints
- Maximum file size: 50MB
- Empty files: Not allowed
- Supported types: see the table above. No other types (including HEIC, HEIF, DOC, DOCX, CSV, CDR, or ZIP) are accepted.
Response
Returns the uploaded file information.
{
"success": true,
"data": {
"file_id": "file_abc123def456",
"file_name": "front_damage.jpg",
"status": "ready",
"download_url": "https://api.silentwitness.ai/api/files/file_abc123/download",
"url": "https://storage.silentwitness.ai/..."
}
}
Example
curl -X POST "https://api.silentwitness.ai/api/files/upload" \
-H "X-API-Key: $API_KEY" \
-F "file=@/path/to/front_damage.jpg" \
-F "case_id=case_abc123def456" \
-F "file_category=vehicle_photo"
Upload Defendant Vehicle Photo
curl -X POST "https://api.silentwitness.ai/api/files/upload" \
-H "X-API-Key: $API_KEY" \
-F "file=@/path/to/defendant_damage.jpg" \
-F "case_id=case_abc123def456" \
-F "file_category=vehicle_photo" \
-F "vehicle_role=defendant"
Upload EDR File
curl -X POST "https://api.silentwitness.ai/api/files/upload" \
-H "X-API-Key: $API_KEY" \
-F "file=@/path/to/edr_report.pdf" \
-F "case_id=case_abc123def456" \
-F "file_category=edr_document"
Errors
| Code | Description |
|---|---|
| 400 | Missing case_id, no file provided, empty file, file too large, EDR not PDF, or vehicle_role passed with tcr_document |
| 401 | Unauthorized - Invalid or missing token |
| 404 | Case not found or access denied |
| 500 | Internal server error |
Example Error
{
"success": false,
"error": "case_id is required"
}
Notes
- Maximum file size: 50MB
- Files are automatically processed after upload
- Status changes from
processingtoreadywhen complete - Empty files are not allowed