Document Analysis

Analyze documents with custom prompts. This is the core feature of the API.

Analyze Document(s)

POST /api/analyze

Request Body

FieldTypeRequiredDescription
projectIdstringYesProject containing the files
fileIdstringYes*Single file to analyze
fileIdsstring[]Yes*Multiple files to analyze
promptstringYesAnalysis instructions
modelstringNo"fast" (default) or "accurate"

*Either fileId or fileIds is required.

Example - Single File

curl -X POST "https://api.getneji.com/api/analyze" \
  -H "Authorization: Bearer sk_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "projectId": "proj_abc123",
    "fileId": "file_xyz789",
    "prompt": "Extract the date, document type, and any dollar amounts."
  }'

Example - Multiple Files

{
  "projectId": "proj_abc123",
  "fileIds": ["file_xyz789", "file_abc456"],
  "prompt": "Compare these two documents and list the differences.",
  "model": "accurate"
}

Example - Image Analysis

{
  "projectId": "proj_abc123",
  "fileId": "file_receipt_001",
  "prompt": "Extract all text from this receipt image."
}

Response - Sync

{
  "analysisId": "anlys_abc123",
  "status": "completed",
  "result": "Date: January 15, 2025\nDocument Type: Invoice\nAmounts: $15,000",
  "usage": {
    "inputTokens": 1500,
    "outputTokens": 200,
    "model": "claude-haiku-4-5-20251001"
  },
  "processingTime": 3500
}

Response - Async

{
  "analysisId": "anlys_abc123",
  "status": "processing",
  "pollUrl": "/api/analyze/anlys_abc123"
}

Get Analysis Result

GET /api/analyze/:analysisId

Batch Analysis

Process multiple documents efficiently.

POST /api/analyze/batch

Request Body

{
  "projectId": "proj_abc123",
  "operations": [
    {
      "id": "op_1",
      "fileId": "file_invoice_001",
      "prompt": "Extract invoice number and total"
    },
    {
      "id": "op_2",
      "fileId": "file_invoice_002",
      "prompt": "Extract invoice number and total"
    }
  ]
}

Model Selection

  • fast (default): Quick extractions, simple queries
  • accurate: Complex analysis, comparisons, nuanced understanding