Skip to main content

Cases - Document Collections

Cases are a powerful feature that allows you to organize related documents into collections for better management and processing. Think of a case as a folder that can contain multiple documents that belong together - like all documents for a specific customer, project, or business process.

What are Cases?

A Case is a logical container for grouping related documents. Each case has:

  • Name: A descriptive identifier for the case
  • Description: Optional detailed information about the case purpose
  • Organization Scope: Cases belong to your organization
  • User Scope: Cases can be user-specific or organization-wide
  • Documents: Multiple documents can be uploaded to each case
  • Metadata: Rich metadata and processing status for each document

When to Use Cases

Cases are ideal for scenarios where you need to:

  • Process multiple documents together (invoices from the same vendor, contract amendments, etc.)
  • Organize documents by project (real estate transaction, insurance claim, etc.)
  • Track processing status across multiple related documents
  • Maintain document relationships and context
  • Batch process documents that share similar characteristics

Common Use Cases

  • Invoice Processing: Group all invoices from a specific vendor or time period
  • Contract Management: Organize contract, amendments, and related documents
  • Insurance Claims: Collect all documents related to a single claim
  • Real Estate Transactions: Group property documents, inspections, and contracts
  • Compliance Audits: Organize documents required for regulatory compliance

Case Management

Creating Cases

curl -X POST https://api.docudevs.ai/cases \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Q4 2024 Vendor Invoices",
"description": "All invoices from vendors for Q4 2024 processing"
}'

Listing Cases

curl -X GET https://api.docudevs.ai/cases \
-H "Authorization: Bearer $API_KEY"

Getting Case Details

curl -X GET https://api.docudevs.ai/cases/{case_id} \
-H "Authorization: Bearer $API_KEY"

Updating Cases

curl -X PUT https://api.docudevs.ai/cases/{case_id} \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Q4 2024 Vendor Invoices - Updated",
"description": "Updated description with additional context"
}'

Deleting Cases

curl -X DELETE https://api.docudevs.ai/cases/{case_id} \
-H "Authorization: Bearer $API_KEY"
warning

Deleting a case will also delete all documents associated with that case. This action cannot be undone.

Document Management within Cases

Uploading Documents to Cases

curl -X POST https://api.docudevs.ai/cases/{case_id}/documents \
-H "Authorization: Bearer $API_KEY" \
-F "document=@invoice_001.pdf"

Listing Documents in a Case

# List documents with pagination
curl -X GET "https://api.docudevs.ai/cases/{case_id}/documents?page=0&size=20" \
-H "Authorization: Bearer $API_KEY"

Getting Document Details

curl -X GET https://api.docudevs.ai/cases/{case_id}/documents/{document_id} \
-H "Authorization: Bearer $API_KEY"

Deleting Documents from Cases

curl -X DELETE https://api.docudevs.ai/cases/{case_id}/documents/{document_id} \
-H "Authorization: Bearer $API_KEY"

User vs Organization Scope

Cases support two levels of scope:

Organization-wide Cases

  • Created by: Any user in the organization
  • Visible to: All users in the organization
  • Use case: Shared projects, company-wide document processing

User-specific Cases

  • Created by: A specific user
  • Visible to: Only the creating user (and organization admins)
  • Use case: Personal projects, user-specific workflows

The scope is automatically determined based on your API key and user context when creating cases.

Processing Status Tracking

Each document in a case tracks its processing status:

  • PENDING: Document uploaded, waiting to be processed
  • PROCESSING: Document is currently being processed
  • COMPLETED: Processing completed successfully
  • FAILED: Processing failed due to an error

You can monitor processing progress by checking the processing_status field when listing documents.

Integration with Document Processing

Documents uploaded to cases can be processed just like standalone documents:

# Upload document to case
case_id = 123
response = await client.upload_case_document(case_id, document_data, "contract.pdf")
document = response.parsed

# Process the document with instructions
document_id = document.document_id
processing_instructions = {
"instruction": "Extract all key contract terms, dates, and parties",
"schema": {
"contract_date": "Date of the contract",
"parties": "List of all parties involved",
"key_terms": "Important contract terms and conditions"
}
}

# Process using the standard document processing API
result = await client.process_document(document_id, processing_instructions)

Best Practices

Case Organization

  • Use descriptive names that clearly indicate the case purpose
  • Include relevant dates in case names (e.g., "Q4 2024 Invoices")
  • Add detailed descriptions for complex cases
  • Use consistent naming conventions across your organization

Document Management

  • Upload documents immediately when they become available
  • Check processing status regularly for large batches
  • Use meaningful filenames that help identify document contents
  • Include metadata in document uploads when relevant

Performance Optimization

  • Batch upload multiple documents to the same case when possible
  • Monitor processing status to avoid overwhelming the system
  • Use pagination when listing large numbers of documents
  • Delete unnecessary cases to keep your workspace organized

Error Handling

Always implement proper error handling when working with cases:

try:
response = await client.create_case(case_data)
case = response.parsed
print(f"Created case: {case.id}")
except Exception as e:
print(f"Error creating case: {e}")
# Handle error appropriately

try:
response = await client.upload_case_document(case_id, document_data, filename)
document = response.parsed
print(f"Uploaded document: {document.document_id}")
except Exception as e:
print(f"Error uploading document: {e}")
# Handle error appropriately

What's Next?