Ocriva Logo

Documents

Event Types & Payloads

Complete reference of all webhook event types and their payload structures.

webhookseventspayloadsreference

Published: 3/31/2026

Event Types & Payloads

This page is the complete reference for every webhook event Ocriva can emit. Each section describes the event, lists the fields in the payload object, and provides a realistic JSON example.


Common Payload Structure

Every webhook delivery — regardless of event type — shares the same outer envelope:

{
  "eventType": "document.processed",
  "eventId": "evt_1743418800000_abc123",
  "timestamp": "2026-03-31T12:00:00.000Z",
  "organizationId": "org_abc123",
  "projectId": "proj_xyz789",
  "payload": {
    // event-specific fields
  }
}
FieldTypeDescription
eventTypestringThe event that triggered this webhook (e.g. document.processed)
eventIdstringUnique identifier for this delivery attempt
timestampstringISO 8601 UTC timestamp of when the event occurred
organizationIdstringID of the organization that owns the resource
projectIdstringID of the project the resource belongs to
payloadobjectEvent-specific data (see each event section below)

NOTE

The eventId uses the format evt_{unixMs}_{random6chars} — for example evt_1743418800000_abc123. The unix timestamp component reflects when the event was created, not when the delivery was attempted.

TIP

Use eventId to implement idempotent event handling. Store processed event IDs and skip re-processing if you receive the same ID twice — this protects you from duplicate deliveries caused by retries.


Document Events

Document events fire when individual files move through the processing pipeline.

document.uploaded

Fires immediately when a file is successfully uploaded to Ocriva, before AI processing begins.

Payload fields:

FieldTypeDescription
idstringUpload record ID
fileNamestringOriginal file name
fileSizenumberFile size in bytes
mimeTypestringMIME type (e.g. application/pdf)
statusstringAlways uploaded at this stage
templateIdstringID of the template assigned for processing
uploadedBystringUser ID who initiated the upload
createdAtstringISO 8601 UTC timestamp

Example:

{
  "eventType": "document.uploaded",
  "eventId": "evt_1743418800000_upl001",
  "timestamp": "2026-03-31T11:59:00.000Z",
  "organizationId": "org_abc123",
  "projectId": "proj_xyz789",
  "payload": {
    "id": "doc_upl_001",
    "fileName": "invoice_march.pdf",
    "fileSize": 204800,
    "mimeType": "application/pdf",
    "status": "uploaded",
    "templateId": "tmpl_invoice_v2",
    "uploadedBy": "user_wicha01",
    "createdAt": "2026-03-31T11:59:00.000Z"
  }
}

document.processed

Fires when a document finishes AI processing successfully. This is the most commonly used event — it carries the extracted data your downstream systems need.

Payload fields:

FieldTypeDescription
idstringUpload record ID
fileNamestringOriginal file name
statusstringAlways completed
extractedDataobjectThe structured data extracted by the AI
confidencenumberExtraction confidence score (0–1)
processingTimenumberTime taken to process in milliseconds
processedAtstringISO 8601 UTC timestamp of completion

Example:

{
  "eventType": "document.processed",
  "eventId": "evt_1743418800000_prc002",
  "timestamp": "2026-03-31T12:00:03.241Z",
  "organizationId": "org_abc123",
  "projectId": "proj_xyz789",
  "payload": {
    "id": "doc_upl_001",
    "fileName": "invoice_march.pdf",
    "status": "completed",
    "extractedData": {
      "invoiceNumber": "INV-2026-0331",
      "vendor": "Acme Supplies Co.",
      "vendorTaxId": "0105560012345",
      "customer": "Beta Corp Ltd.",
      "issueDate": "2026-03-31",
      "dueDate": "2026-04-30",
      "subtotal": 14400.00,
      "vatAmount": 1008.00,
      "totalAmount": 15408.00,
      "currency": "THB",
      "lineItems": [
        {
          "description": "Cloud Storage (March)",
          "quantity": 12,
          "unitPrice": 1200.00,
          "amount": 14400.00
        }
      ]
    },
    "confidence": 0.97,
    "processingTime": 3241,
    "processedAt": "2026-03-31T12:00:03.241Z"
  }
}

document.failed

Fires when a document could not be processed successfully. Use this event to trigger error handling, alerting, or manual review workflows.

Payload fields:

FieldTypeDescription
idstringUpload record ID
fileNamestringOriginal file name
statusstringAlways failed
errorMessagestringHuman-readable description of what went wrong
processingTimenumberTime elapsed before failure in milliseconds

Example:

{
  "eventType": "document.failed",
  "eventId": "evt_1743418900000_fail003",
  "timestamp": "2026-03-31T12:01:40.000Z",
  "organizationId": "org_abc123",
  "projectId": "proj_xyz789",
  "payload": {
    "id": "doc_upl_002",
    "fileName": "corrupted_scan.pdf",
    "status": "failed",
    "errorMessage": "Unable to extract text: document appears to be a scanned image with insufficient resolution (below 150 DPI).",
    "processingTime": 1820
  }
}

Batch Events

Batch events fire when groups of documents are uploaded or finish processing together.

batch.uploaded

Fires when a batch upload operation completes — all files in the batch have been received by Ocriva and queued for processing.

Payload fields:

FieldTypeDescription
batchIdstringUnique batch identifier
namestringBatch name as provided at upload time
totalFilesnumberTotal number of files in the batch
templateIdstringTemplate applied to all files in this batch
uploadedBystringUser ID who initiated the batch upload
createdAtstringISO 8601 UTC timestamp
uploadIdsstring[]Array of individual upload record IDs

Example:

{
  "eventType": "batch.uploaded",
  "eventId": "evt_1743418800000_bat004",
  "timestamp": "2026-03-31T12:00:00.000Z",
  "organizationId": "org_abc123",
  "projectId": "proj_xyz789",
  "payload": {
    "batchId": "batch_march_invoices",
    "name": "March 2026 Invoices",
    "totalFiles": 47,
    "templateId": "tmpl_invoice_v2",
    "uploadedBy": "user_wicha01",
    "createdAt": "2026-03-31T12:00:00.000Z",
    "uploadIds": [
      "doc_upl_101",
      "doc_upl_102",
      "doc_upl_103"
    ]
  }
}

batch.completed

Fires when every file in a batch has finished processing (either successfully or with failures). Use this event to trigger batch-level reporting or aggregation.

Payload fields:

FieldTypeDescription
batchIdstringUnique batch identifier
namestringBatch name
totalFilesnumberTotal number of files submitted
completedFilesnumberNumber of files that processed successfully
failedFilesnumberNumber of files that failed
statusstringcompleted if all succeeded, partial if some failed
completedAtstringISO 8601 UTC timestamp of when the last file finished

Example:

{
  "eventType": "batch.completed",
  "eventId": "evt_1743422400000_bat005",
  "timestamp": "2026-03-31T13:00:00.000Z",
  "organizationId": "org_abc123",
  "projectId": "proj_xyz789",
  "payload": {
    "batchId": "batch_march_invoices",
    "name": "March 2026 Invoices",
    "totalFiles": 47,
    "completedFiles": 45,
    "failedFiles": 2,
    "status": "partial",
    "completedAt": "2026-03-31T13:00:00.000Z"
  }
}

Template Events

Template events fire when templates in your organization are created, modified, or removed. These are useful for syncing template metadata to external systems or audit logging.

template.created

Fires when a new template is created in the organization. Use this event to sync template metadata to external systems or initialize downstream configuration.

Payload fields:

FieldTypeDescription
idstringUnique template identifier
namestringTemplate display name
descriptionstringHuman-readable description of what the template extracts
projectIdstringID of the project this template belongs to
resultFormatstringOutput format configured for this template (e.g. json, csv)
createdBystringUser ID who created the template
createdAtstringISO 8601 UTC timestamp of creation

Example:

{
  "eventType": "template.created",
  "eventId": "evt_1743418800000_tpl006",
  "timestamp": "2026-03-31T12:00:00.000Z",
  "organizationId": "org_abc123",
  "projectId": "proj_xyz789",
  "payload": {
    "id": "tmpl_invoice_v2",
    "name": "Invoice Extractor v2",
    "description": "Extracts vendor, line items, totals, and tax details from Thai-language invoices.",
    "projectId": "proj_xyz789",
    "resultFormat": "json",
    "createdBy": "user_wicha01",
    "createdAt": "2026-03-31T12:00:00.000Z"
  }
}

template.updated

Fires when any field on a template is updated — including schema changes, model configuration changes, or name/description edits.

Payload fields:

FieldTypeDescription
idstringUnique template identifier
namestringTemplate display name (after update)
descriptionstringTemplate description (after update)
projectIdstringID of the project this template belongs to
resultFormatstringOutput format configured for this template
updatedBystringUser ID who made the update
updatedAtstringISO 8601 UTC timestamp of the update
changesstring[]Array of field names that were modified in this update

Example:

{
  "eventType": "template.updated",
  "eventId": "evt_1743422400000_tpl007",
  "timestamp": "2026-03-31T13:00:00.000Z",
  "organizationId": "org_abc123",
  "projectId": "proj_xyz789",
  "payload": {
    "id": "tmpl_invoice_v2",
    "name": "Invoice Extractor v2",
    "description": "Extracts vendor, line items, totals, tax details, and payment terms from Thai-language invoices.",
    "projectId": "proj_xyz789",
    "resultFormat": "json",
    "updatedBy": "user_wicha01",
    "updatedAt": "2026-03-31T13:00:00.000Z",
    "changes": ["description", "resultFormat"]
  }
}

template.deleted

Fires when a template is deleted. The payload retains enough information to reference the removed template even after it no longer exists in the system — useful for audit logging and cleaning up external references.

Payload fields:

FieldTypeDescription
idstringUnique identifier of the deleted template
namestringDisplay name of the deleted template
projectIdstringID of the project this template belonged to
deletedBystringUser ID who deleted the template
deletedAtstringISO 8601 UTC timestamp of deletion

Example:

{
  "eventType": "template.deleted",
  "eventId": "evt_1743426000000_tpl008",
  "timestamp": "2026-03-31T14:00:00.000Z",
  "organizationId": "org_abc123",
  "projectId": "proj_xyz789",
  "payload": {
    "id": "tmpl_invoice_v1",
    "name": "Invoice Extractor v1",
    "projectId": "proj_xyz789",
    "deletedBy": "user_wicha01",
    "deletedAt": "2026-03-31T14:00:00.000Z"
  }
}