Examples

Real-World Examples

Example 1: Scanned Deposition

curl -X POST https://api.case.dev/ocr/v1/process \
  -H "Authorization: Bearer sk_case_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "document_url": "https://case-files.s3.amazonaws.com/deposition-smith-2024.pdf",
    "document_id": "smith-depo-2024-11-04",
    "org_id": "case-2024-1234",
    "engine": "doctr",
    "features": {
      "embed": {}
    }
  }'

Example 2: Medical Records with Tables

curl -X POST https://api.case.dev/ocr/v1/process \
  -H "Authorization: Bearer sk_case_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "document_url": "https://medical-records.s3.amazonaws.com/patient-123.pdf",
    "document_id": "medrecord-patient-123",
    "engine": "paddle",
    "features": {
      "tables": {
        "format": "csv",
        "include_headers": true
      },
      "embed": {}
    },
    "callback_url": "https://your-app.com/api/ocr-complete"
  }'

Example 3: Discovery Document from S3

curl -X POST https://api.case.dev/ocr/v1/process \
  -H "Authorization: Bearer sk_case_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "document_url": "s3://case-discovery/case-2024-5678/exhibit-a.pdf",
    "document_id": "exhibit-a-discovery",
    "engine": "doctr",
    "features": {
      "embed": {}
    }
  }'

Example 4: Handwritten Notes

curl -X POST https://api.case.dev/ocr/v1/process \
  -H "Authorization: Bearer sk_case_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "document_url": "https://storage.com/witness-notes-handwritten.jpg",
    "document_id": "witness-notes-handwritten",
    "engine": "tesseract",
    "features": {}
  }'

Workflow Example: Full Discovery Document Processing

#!/bin/bash

# 1. Submit OCR job for a large discovery PDF
echo "Submitting 300-page discovery document..."
RESPONSE=$(curl -s -X POST https://api.case.dev/ocr/v1/process \
  -H "Authorization: Bearer sk_case_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "document_url": "s3://discovery-docs/case-2024-5678/exhibit-b.pdf",
    "document_id": "exhibit-b-300pg",
    "engine": "doctr",
    "features": {
      "embed": {},
      "tables": {"format": "csv"}
    },
    "callback_url": "https://your-app.com/api/ocr-webhook"
  }')

JOB_ID=$(echo $RESPONSE | jq -r '.id')
echo "Job ID: $JOB_ID"
echo "Processing 300 pages... this will take ~12 minutes"

# 2. Monitor progress
while true; do
  RESULT=$(curl -s https://api.case.dev/ocr/v1/$JOB_ID \
    -H "Authorization: Bearer sk_case_...")

  STATUS=$(echo $RESULT | jq -r '.status')
  COMPLETED=$(echo $RESULT | jq -r '.chunks_completed')
  TOTAL=$(echo $RESULT | jq -r '.chunk_count')

  if [ "$STATUS" = "completed" ]; then
    echo "✓ OCR complete!"
    break
  elif [ "$STATUS" = "error" ] || [ "$STATUS" = "failed" ]; then
    echo "✗ OCR failed"
    exit 1
  fi

  PERCENT=$((COMPLETED * 100 / TOTAL))
  echo "Progress: $COMPLETED/$TOTAL chunks ($PERCENT%)"

  sleep 60
done

# 3. Download results
echo "Downloading results..."

# Get plain text
curl -s https://api.case.dev/ocr/v1/$JOB_ID \
  -H "Authorization: Bearer sk_case_..." \
  | jq -r '.text' > exhibit-b-text.txt

# Get searchable PDF
PDF_URL=$(curl -s https://api.case.dev/ocr/v1/$JOB_ID \
  -H "Authorization: Bearer sk_case_..." \
  | jq -r '.links.searchable_pdf')

curl -o exhibit-b-searchable.pdf "$PDF_URL"

# Get structured data
JSON_URL=$(curl -s https://api.case.dev/ocr/v1/$JOB_ID \
  -H "Authorization: Bearer sk_case_..." \
  | jq -r '.links.json')

curl -o exhibit-b-data.json "$JSON_URL"

echo "Complete! Files created:"
echo "  - exhibit-b-text.txt (plain text)"
echo "  - exhibit-b-searchable.pdf (searchable PDF)"
echo "  - exhibit-b-data.json (structured data with coordinates)"