Limai Docs
API ReferenceWebhooks

Document Extracted Event

Webhook event fired when document processing completes, whether successful or failed.

The DOCUMENT_EXTRACTED event fires when document processing completes, whether the extraction was successful or failed. This provides immediate feedback on extraction job status.

When It Triggers

  • Successful extraction -- When a document is successfully processed and data is extracted
  • Failed extraction -- When document processing fails due to errors or timeouts

Typically fires within 30-120 seconds after calling the process-file or process-file-async endpoint, depending on document complexity.

On a model with at least one validation rule, the rules are evaluated before this event is published, so a read triggered by it sees the document's final rule results -- validations.rules and the per-cell RULE entries are already the verdict for this extraction. A model with no rules has nothing to evaluate, and the event is published as soon as the extraction completes.

When rule evaluation fails, this event is published first and DOCUMENT_VALIDATION_FAILED follows it; the document's validation status reads error from the moment this event goes out, so a read triggered by it is still conclusive.

Custom validations are not covered either way: scripts and validator agents are dispatched after the event and settle later, announced by DOCUMENT_VALIDATED.

Payload Structure

Successful Extraction

Response200
{
  "eventId": "evt_success_456",
  "eventType": "DOCUMENT_EXTRACTED",
  "timestamp": "2024-01-15T10:30:45Z",
  "organizationId": "org_xyz789",
  "projectId": "proj_abc123",
  "deploymentId": "dep_123abc",
  "viaDeploymentId": "dpl_prod01",
  "deploymentName": "production",
  "schemaVersionId": "sv_7",
  "extractionSchemaId": "schema_456def",
  "fileId": "file_789ghi",
  "jobId": "job_012jkl",
  "data": {
    "status": "success",
    "errorMessage": null
  }
}

Failed Extraction

Response200
{
  "eventId": "evt_failed_789",
  "eventType": "DOCUMENT_EXTRACTED",
  "timestamp": "2024-01-15T10:32:15Z",
  "organizationId": "org_xyz789",
  "projectId": "proj_abc123",
  "deploymentId": "dep_123abc",
  "viaDeploymentId": "dpl_prod01",
  "deploymentName": "production",
  "schemaVersionId": "sv_7",
  "extractionSchemaId": "schema_456def",
  "fileId": "file_bad123",
  "jobId": "job_error456",
  "data": {
    "status": "failed",
    "errorMessage": "Document format not supported"
  }
}

Payload Fields

FieldTypeDescription
eventIdstringUnique event identifier. Use for idempotency.
eventTypestringAlways "DOCUMENT_EXTRACTED"
timestampISO 8601When the extraction completed (UTC)
organizationIdstringYour organization identifier
projectIdstringThe project the document belongs to
deploymentIdstringThe ID of the model that processed this document
viaDeploymentIdstring | nullThe ID of the deployment the request arrived through. null when the request named the model directly
deploymentNamestring | nullThe name of that deployment, such as "production". null whenever viaDeploymentId is null
schemaVersionIdstring | nullThe ID of the frozen schema version the run resolved to. null when the deployment tracks the draft schema
extractionSchemaIdstringThe extraction schema ID of that model
fileIdstringThe processed file identifier
jobIdstringThe extraction job identifier
data.status"success" | "failed"Extraction result
data.errorMessagestring | nullError description if failed, otherwise null

When several deployments point at one model, viaDeploymentId tells you which of them served the traffic.

Handling the Event

function handleDocumentExtracted(event) {
const { eventId, fileId, jobId, data } = event

if (data.status === "success") {
  console.log(`Document ${fileId} extracted successfully (job: ${jobId})`)

  fetchFileData(fileId).then(fileData => {
    processExtractedData(fileData)
  })
} else {
  console.error(`Document ${fileId} extraction failed: ${data.errorMessage}`)
}
}

Retrieving Extracted Data

The webhook payload contains metadata only. To get the actual extracted data, call the get-file-data endpoint using the fileId from the payload.

On this page