Documents
The Documents API lets you programmatically manage documents -- upload files, download content, assign documents to cases and parties, and extract text.
Endpoints
| Method | Path | Description |
|---|---|---|
GET | /api/v1/documents | List documents |
POST | /api/v1/documents | Upload a document |
GET | /api/v1/documents/{id} | Get document metadata |
GET | /api/v1/documents/{id}/download | Download file content |
DELETE | /api/v1/documents/{id} | Delete a document |
POST | /api/v1/documents/{id}/assign | Assign to case/party |
GET | /api/v1/documents/{id}/parties | List assigned parties |
POST | /api/v1/documents/{id}/extract | Extract text content |
POST | /api/v1/documents/bulk-assign | Bulk assign documents |
Required scope: documents:read for GET endpoints, documents:write for POST/PUT, documents:delete for DELETE.
The Document Object
{
"id": "doc_01ABCDEFG",
"filename": "contract_v2.pdf",
"mime_type": "application/pdf",
"size_bytes": 245760,
"status": "processed",
"case_id": "550e8400-e29b-41d4-a716-446655440000",
"folder_id": "fld_01ABCDEF",
"parties": [
{ "id": "pty_01ABCDEF", "name": "John Smith", "is_primary": true }
],
"extracted_text_length": 12543,
"created_at": "2026-03-10T08:30:00Z",
"updated_at": "2026-03-10T08:31:00Z"
}
Upload a Document
POST /api/v1/documents
Content-Type: multipart/form-data
Form Fields
| Field | Type | Required | Description |
|---|---|---|---|
file | File | Yes | The file to upload (PDF, DOCX, DOC, PNG, JPG, TIFF) |
case_id | UUID | No | Assign to a case immediately |
folder_id | UUID | No | Place in a specific folder |
party_ids | string[] | No | Assign to parties |
Example
curl -X POST https://api.optimaite.eu/api/v1/documents \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@contract.pdf" \
-F "case_id=550e8400-e29b-41d4-a716-446655440000"
Response
Returns 201 Created with the document metadata.
Download a Document
GET /api/v1/documents/{id}/download
Returns the raw file content as a streaming response with the appropriate Content-Type and Content-Disposition headers.
Extract Text
POST /api/v1/documents/{id}/extract
Returns the extracted text content of a document:
{
"text": "This Employment Agreement (\"Agreement\") is entered into...",
"page_count": 5,
"word_count": 3241
}
Supported file types: PDF, DOCX, DOC, images (via OCR), and plain text.
List Documents
GET /api/v1/documents?case_id=...&status=processed&limit=50
Query Parameters
| Parameter | Type | Description |
|---|---|---|
cursor | string | Pagination cursor |
limit | integer | Results per page (1-100, default 50) |
case_id | UUID | Filter by case |
folder_id | UUID | Filter by folder |
status | string | Filter: pending, processed, failed |
search | string | Search by filename |
Next Steps
Was this helpful?