Ocriva Logo

Documents

Batch

Upload multiple files at once and track batch processing progress via the Open API.

apiopenapibatchupload

Published: 3/31/2026

Batch

The Batch endpoints let you upload multiple files in a single request and track their combined processing status. Each batch groups up to 50 files and provides a unified progress view — how many files have completed, failed, or are still processing.

Project ID requirement: For organization tokens, provide projectId as a form field (upload) or query parameter (list). For project tokens, projectId is inferred from the token automatically.


Batch Upload

POST /v1/openapi/batch/upload

Uploads multiple files at once and creates a batch record to track their processing. All files in the batch are queued for OCR using the same template (if provided).

Headers:

HeaderValueRequired
X-API-Keyocr_your_api_keyYes
Content-Typemultipart/form-dataYes

Request Body (multipart/form-data):

FieldTypeRequiredDescription
filesFile[]YesFiles to upload. Maximum 50 files per request
projectIdstringYesTarget project ID
templateIdstringNoTemplate to apply to all files in the batch
namestringNoBatch name. Auto-generated (e.g., Batch 2026-03-31) if omitted
metadatastringNoAdditional metadata as a JSON string

Example Request:

curl -X POST "https://api.ocriva.com/v1/openapi/batch/upload" \
  -H "X-API-Key: ocr_your_api_key" \
  -F "files=@/path/to/invoice-001.pdf" \
  -F "files=@/path/to/invoice-002.pdf" \
  -F "files=@/path/to/invoice-003.pdf" \
  -F "projectId=68db4aa2967d9c03fa9b5e74" \
  -F "templateId=68db4bb3a67e9c04fb0c6f85" \
  -F "name=March 2026 Invoices"

Example Response (201 Created):

{
  "id": "68dd2ee6d89g1f27ge4c9h96",
  "name": "March 2026 Invoices",
  "projectId": "68db4aa2967d9c03fa9b5e74",
  "organizationId": "68da2880b45d7a01d90a3c51",
  "userId": "68da3991c56e8b02ea1b4d60",
  "templateId": "68db4bb3a67e9c04fb0c6f85",
  "templateName": "Invoice Template",
  "totalFiles": 3,
  "completedFiles": 0,
  "failedFiles": 0,
  "status": "processing",
  "uploadIds": [
    "68dd2ee6d89g1f27ge4c9h01",
    "68dd2ee6d89g1f27ge4c9h02",
    "68dd2ee6d89g1f27ge4c9h03"
  ],
  "processingHistoryIds": [
    "68dd2ff7e90h2g38hf5d0i07",
    "68dd2ff7e90h2g38hf5d0i08",
    "68dd2ff7e90h2g38hf5d0i09"
  ],
  "progress": 0,
  "createdAt": "2026-03-31T10:00:00.000Z",
  "updatedAt": "2026-03-31T10:00:00.000Z"
}

Common Errors:

StatusCause
400No files included, or projectId is missing
401Token is invalid or projectId does not match the token scope

List Batches

GET /v1/openapi/batch

Returns a paginated list of batches for the specified project.

Headers:

HeaderValueRequired
X-API-Keyocr_your_api_keyYes

Query Parameters:

ParameterTypeRequiredDescription
projectIdstringOrg token: YesTarget project ID
pagenumberNoPage number (default: 1)
limitnumberNoItems per page (default: 20)
statusstringNoFilter by status: uploading, processing, completed, partially_failed, failed

Example Request:

curl "https://api.ocriva.com/v1/openapi/batch?projectId=68db4aa2967d9c03fa9b5e74&status=completed&page=1&limit=20" \
  -H "X-API-Key: ocr_your_api_key"

Example Response (200 OK):

{
  "data": [
    {
      "id": "68dd2ee6d89g1f27ge4c9h96",
      "name": "March 2026 Invoices",
      "projectId": "68db4aa2967d9c03fa9b5e74",
      "organizationId": "68da2880b45d7a01d90a3c51",
      "userId": "68da3991c56e8b02ea1b4d60",
      "templateId": "68db4bb3a67e9c04fb0c6f85",
      "templateName": "Invoice Template",
      "totalFiles": 3,
      "completedFiles": 3,
      "failedFiles": 0,
      "status": "completed",
      "progress": 100,
      "createdAt": "2026-03-31T10:00:00.000Z",
      "updatedAt": "2026-03-31T10:02:30.000Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 8,
    "pages": 1
  }
}

Get Batch Details

GET /v1/openapi/batch/:batchId

Returns the full details for a single batch, including file counts and current progress percentage. Poll this endpoint to monitor batch completion.

The progress field is calculated as (completedFiles + failedFiles) / totalFiles * 100.

Path Parameters:

ParameterDescription
batchIdBatch ID

Headers:

HeaderValueRequired
X-API-Keyocr_your_api_keyYes

Example Request:

curl "https://api.ocriva.com/v1/openapi/batch/68dd2ee6d89g1f27ge4c9h96" \
  -H "X-API-Key: ocr_your_api_key"

Example Response (200 OK):

{
  "id": "68dd2ee6d89g1f27ge4c9h96",
  "name": "March 2026 Invoices",
  "projectId": "68db4aa2967d9c03fa9b5e74",
  "organizationId": "68da2880b45d7a01d90a3c51",
  "userId": "68da3991c56e8b02ea1b4d60",
  "templateId": "68db4bb3a67e9c04fb0c6f85",
  "templateName": "Invoice Template",
  "totalFiles": 3,
  "completedFiles": 2,
  "failedFiles": 0,
  "status": "processing",
  "uploadIds": [
    "68dd2ee6d89g1f27ge4c9h01",
    "68dd2ee6d89g1f27ge4c9h02",
    "68dd2ee6d89g1f27ge4c9h03"
  ],
  "processingHistoryIds": [
    "68dd2ff7e90h2g38hf5d0i07",
    "68dd2ff7e90h2g38hf5d0i08",
    "68dd2ff7e90h2g38hf5d0i09"
  ],
  "progress": 66.67,
  "createdAt": "2026-03-31T10:00:00.000Z",
  "updatedAt": "2026-03-31T10:01:45.000Z"
}

Batch Status Values:

StatusDescription
uploadingFiles are still being uploaded
processingFiles are queued or being processed
completedAll files processed successfully
partially_failedSome files completed, some failed
failedAll files failed to process

Common Errors:

StatusCause
401Batch does not belong to the token's organization
404Batch not found

Export Batch Results

GET /v1/openapi/batch/:batchId/export

Downloads the combined processing results of all completed files in the batch as a single file. Only files with completed status are included in the export.

Path Parameters:

ParameterDescription
batchIdBatch ID

Headers:

HeaderValueRequired
X-API-Keyocr_your_api_keyYes

Query Parameters:

ParameterTypeRequiredDescription
formatstringYesExport format: json, csv, text, xml, pdf, docx

Example Request:

# Export all results as a single CSV file
curl "https://api.ocriva.com/v1/openapi/batch/68dd2ee6d89g1f27ge4c9h96/export?format=csv" \
  -H "X-API-Key: ocr_your_api_key" \
  -o "march-2026-invoices.csv"

The response is a file download. The filename is set automatically to batch-{batchId}-export.{extension} via the Content-Disposition header.

Supported Export Formats:

FormatContent-TypeFile Extension
jsonapplication/json.json
csvtext/csv.csv
texttext/plain.txt
xmlapplication/xml.xml
pdfapplication/pdf.pdf
docxapplication/vnd.openxmlformats-officedocument.wordprocessingml.document.docx

Common Errors:

StatusCause
400format parameter missing, or no completed results to export
401Batch does not belong to the token's organization
404Batch not found