Ocriva Logo

Documents

Upload

Upload a single file for AI-powered data extraction via the Open API.

apiopenapiupload

Published: 3/31/2026

Upload

The Upload endpoint lets you submit a single document file for AI-powered data extraction. The file is stored, queued for AI extraction, and a processing history record is created automatically. You can track progress via the Processing History endpoints.


Upload a File

POST /v1/openapi/upload

Upload a single file for AI-powered data extraction.

Headers:

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

Request Body (multipart/form-data):

FieldTypeRequiredDescription
fileFileYesThe document to upload (PDF or image)
fileNamestringYesOriginal file name (e.g., invoice-2026.pdf)
fileTypestringYesOne of: pdf, image, document
fileSizestringYesFile size in bytes as a string (e.g., "204800")
mimeTypestringYesMIME type of the file (e.g., application/pdf)
projectIdstringYesID of the target project
templateIdstringNoID of the template to use for extraction
uploadTypestringNoUpload type identifier (optional)
metadatastringNoAdditional metadata as a JSON string
batchIdstringNoAssociate this upload with an existing batch

Notes:

  • For project tokens, projectId must match the token's project. The field is still required.
  • For organization tokens, projectId must belong to the token's organization.

Example Request:

curl -X POST "https://api.ocriva.com/v1/openapi/upload" \
  -H "X-API-Key: ocr_your_api_key" \
  -F "file=@/path/to/invoice-2026.pdf" \
  -F "fileName=invoice-2026.pdf" \
  -F "fileType=pdf" \
  -F "fileSize=204800" \
  -F "mimeType=application/pdf" \
  -F "projectId=68db4aa2967d9c03fa9b5e74" \
  -F "templateId=68db4bb3a67e9c04fb0c6f85"

Example Response (201 Created):

{
  "id": "68dc1cc4b78f0d15ec2a7f91",
  "fileName": "invoice-2026.pdf",
  "fileUrl": "https://storage.ocriva.com/org-abc/invoice-2026.pdf",
  "publicUrl": "https://storage.ocriva.com/public/org-abc/invoice-2026.pdf",
  "filePath": "org-abc/projects/proj-xyz/invoice-2026.pdf",
  "fileSize": "204800",
  "mimeType": "application/pdf",
  "status": "uploaded",
  "templateId": "68db4bb3a67e9c04fb0c6f85",
  "projectId": "68db4aa2967d9c03fa9b5e74",
  "uploadedAt": "2026-03-31T10:00:00.000Z",
  "userId": "68da3991c56e8b02ea1b4d60",
  "organizationId": "68da2880b45d7a01d90a3c51"
}

Common Errors:

StatusCause
400No file included, or a required form field is missing
401Token is invalid, or projectId does not match the token scope
404Specified project not found