Processing History
Processing History Record แทน OCR Job ของเอกสารแต่ละชิ้น — การอัปโหลดแต่ละครั้งจะสร้าง Record ที่ติดตามสถานะ, ผลลัพธ์ที่ดึงได้, เวลาประมวลผล และ Error ต่างๆ ใช้ Endpoint เหล่านี้เพื่อตรวจสอบสถานะ Completion, ดึงผลลัพธ์ หรือ Export ข้อมูลในรูปแบบที่ต้องการ
ข้อกำหนด Project ID: สำหรับ Organization Token ทุก Endpoint ต้องการ Query Parameter projectId สำหรับ Project Token ระบบอ่าน projectId จาก Token อัตโนมัติ ไม่บังคับต้องส่ง
รายการ Processing History
GET /v1/openapi/processing-historyคืนรายการ Processing History Record แบบ Paginated สำหรับ Project ที่ระบุ รองรับการกรองตามสถานะ, Template, ช่วงวันที่ และคำค้นหา
Headers:
| Header | Value | Required |
|---|---|---|
X-API-Key | ocr_your_api_key | Yes |
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
projectId | string | Org token: Yes | ID ของ Project เป้าหมาย |
page | number | No | หมายเลขหน้า (default: 1) |
limit | number | No | จำนวน Item ต่อหน้า (default: 10) |
status | string | No | กรองตามสถานะ: pending, queued, in_progress, completed, failed |
templateId | string | No | กรองตาม Template ID |
fromDate | string | No | วันเริ่มต้นช่วงวันที่ (YYYY-MM-DD) |
toDate | string | No | วันสิ้นสุดช่วงวันที่ (YYYY-MM-DD) |
search | string | No | ค้นหาตามชื่อไฟล์หรือชื่อ Template |
batchId | string | No | กรองตาม Batch ID |
Example Request:
curl "https://api.ocriva.com/v1/openapi/processing-history?projectId=68db4aa2967d9c03fa9b5e74&status=completed&page=1&limit=10" \
-H "X-API-Key: ocr_your_api_key"Example Response (200 OK):
{
"data": [
{
"id": "68dc1cc4b78f0d15ec2a7f91",
"uploadId": "68dc1bb3a67e0c14eb1b6e80",
"projectId": "68db4aa2967d9c03fa9b5e74",
"userId": "68da3991c56e8b02ea1b4d60",
"fileName": "invoice-2026.pdf",
"fileUrl": "https://storage.ocriva.com/org-abc/invoice-2026.pdf",
"filePath": "org-abc/projects/proj-xyz/invoice-2026.pdf",
"fileSize": "204800",
"mimeType": "application/pdf",
"status": "completed",
"templateId": "68db4bb3a67e9c04fb0c6f85",
"templateName": "Invoice Template",
"resultFormat": "json",
"priority": "medium",
"processingResult": {
"invoiceNumber": "INV-2026-0042",
"totalAmount": 1250.00,
"vendor": "Acme Corp"
},
"startedAt": "2026-03-31T10:01:00.000Z",
"completedAt": "2026-03-31T10:01:15.000Z",
"createdAt": "2026-03-31T10:00:00.000Z",
"updatedAt": "2026-03-31T10:01:15.000Z"
}
],
"pagination": {
"page": 1,
"limit": 10,
"total": 42,
"pages": 5
}
}ดูสถิติการประมวลผล
GET /v1/openapi/processing-history/statsคืนจำนวน Processing Record รวมแยกตามสถานะสำหรับ Project ที่ระบุ มีประโยชน์สำหรับสร้าง Dashboard หรือ Monitor Pipeline
Headers:
| Header | Value | Required |
|---|---|---|
X-API-Key | ocr_your_api_key | Yes |
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
projectId | string | Org token: Yes | ID ของ Project เป้าหมาย |
Example Request:
curl "https://api.ocriva.com/v1/openapi/processing-history/stats?projectId=68db4aa2967d9c03fa9b5e74" \
-H "X-API-Key: ocr_your_api_key"Example Response (200 OK):
{
"total": 150,
"pending": 5,
"processing": 3,
"completed": 138,
"failed": 4
}ดู Processing History Record
GET /v1/openapi/processing-history/:idคืน Processing History Record เดียวตาม ID พร้อมผลลัพธ์ที่ดึงได้ครบถ้วนและรายละเอียดเวลาประมวลผล
Path Parameters:
| Parameter | Description |
|---|---|
id | ID ของ Processing History Record |
Headers:
| Header | Value | Required |
|---|---|---|
X-API-Key | ocr_your_api_key | Yes |
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
projectId | string | Org token: Yes | ID ของ Project เป้าหมาย |
Example Request:
curl "https://api.ocriva.com/v1/openapi/processing-history/68dc1cc4b78f0d15ec2a7f91?projectId=68db4aa2967d9c03fa9b5e74" \
-H "X-API-Key: ocr_your_api_key"Example Response (200 OK):
{
"id": "68dc1cc4b78f0d15ec2a7f91",
"uploadId": "68dc1bb3a67e0c14eb1b6e80",
"projectId": "68db4aa2967d9c03fa9b5e74",
"userId": "68da3991c56e8b02ea1b4d60",
"fileName": "invoice-2026.pdf",
"fileUrl": "https://storage.ocriva.com/org-abc/invoice-2026.pdf",
"filePath": "org-abc/projects/proj-xyz/invoice-2026.pdf",
"fileSize": "204800",
"mimeType": "application/pdf",
"status": "completed",
"templateId": "68db4bb3a67e9c04fb0c6f85",
"templateName": "Invoice Template",
"resultFormat": "json",
"priority": "medium",
"processingResult": {
"invoiceNumber": "INV-2026-0042",
"totalAmount": 1250.00,
"vendor": "Acme Corp",
"lineItems": [
{ "description": "Consulting Services", "quantity": 1, "unitPrice": 1250.00 }
]
},
"startedAt": "2026-03-31T10:01:00.000Z",
"completedAt": "2026-03-31T10:01:15.000Z",
"createdAt": "2026-03-31T10:00:00.000Z",
"updatedAt": "2026-03-31T10:01:15.000Z"
}Common Errors:
| Status | Cause |
|---|---|
401 | Record ไม่ได้อยู่ใน Scope ของ Token |
404 | ไม่พบ Record |
Export ผลลัพธ์การประมวลผล
GET /v1/openapi/processing-history/:id/resultดาวน์โหลดผลลัพธ์การประมวลผลเป็นไฟล์ในรูปแบบที่กำหนด Response จะ Stream ไฟล์โดยตรงพร้อม Header Content-Type และ Content-Disposition ที่เหมาะสมสำหรับการดาวน์โหลด
หากไม่ระบุ format ระบบจะใช้ resultFormat ที่กำหนดใน Template หรือ json หากไม่มี Template
Path Parameters:
| Parameter | Description |
|---|---|
id | ID ของ Processing History Record |
Headers:
| Header | Value | Required |
|---|---|---|
X-API-Key | ocr_your_api_key | Yes |
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
projectId | string | Org token: Yes | ID ของ Project เป้าหมาย |
format | string | No | รูปแบบ Output: json, text, xml, html, csv, pdf, docx |
Example Request:
# Download result as CSV
curl "https://api.ocriva.com/v1/openapi/processing-history/68dc1cc4b78f0d15ec2a7f91/result?projectId=68db4aa2967d9c03fa9b5e74&format=csv" \
-H "X-API-Key: ocr_your_api_key" \
-o "invoice-result.csv"Response เป็นการดาวน์โหลดไฟล์ สำหรับรูปแบบ json Body จะเป็น JSON Object สำหรับรูปแบบอื่นจะคืน Binary หรือ Text Content พร้อม MIME Type ที่เหมาะสม
รูปแบบที่รองรับ:
| Format | Content-Type |
|---|---|
json | application/json |
text | text/plain |
xml | application/xml |
html | text/html |
csv | text/csv |
pdf | application/pdf |
docx | application/vnd.openxmlformats-officedocument.wordprocessingml.document |
Common Errors:
| Status | Cause |
|---|---|
401 | Record ไม่ได้อยู่ใน Scope ของ Token |
404 | ไม่พบ Record |
