Limai Docs
API ReferenceWebhooks

Document Validation Failed Event

Webhook event fired when a validation attempt cannot complete.

The DOCUMENT_VALIDATION_FAILED event fires when a validation attempt cannot complete -- the job was dropped, the validator agent run died, or the attempt was abandoned. It closes the hole where a document that was never validated simply stayed silent.

This event reports that validation did not run to a verdict. It is not a failing validation result: a validation that ran and found problems settles normally and reports through DOCUMENT_VALIDATED with status: "failed".

When It Triggers

data.reasonMeaning
DLQThe static validation job exhausted its retries and landed in the dead-letter queue
ABORTEDThe attempt could not be dispatched, or was abandoned before running
AGENT_RUN_FAILEDThe validator agent run terminated without submitting a verdict
TIMEOUTThe attempt exceeded the validation watchdog's hard cap
NOT_DISPATCHEDValidation was expected for the document but no attempt was ever dispatched

This is a document event, routed to subscriptions by deployment route.

Payload Structure

Response200
{
  "eventId": "evt_valfail_202",
  "eventType": "DOCUMENT_VALIDATION_FAILED",
  "timestamp": "2024-01-15T10:52:00Z",
  "organizationId": "org_xyz789",
  "projectId": "proj_abc123",
  "deploymentId": "dep_123abc",
  "extractionSchemaId": "schema_456def",
  "fileId": "file_789ghi",
  "data": {
    "reason": "AGENT_RUN_FAILED",
    "errorMessage": "Validation agent run failed",
    "source": "AGENT",
    "validationAttemptId": "cm5attempt001"
  }
}

Payload Fields

FieldTypeDescription
eventIdstringUnique event identifier. Use for idempotency.
eventTypestringAlways "DOCUMENT_VALIDATION_FAILED"
timestampISO 8601When the attempt was written off (UTC)
organizationIdstringYour organization identifier
projectIdstringThe project the document belongs to
deploymentIdstringThe model or deployment that processed this document
extractionSchemaIdstringThe extraction schema ID of that model or deployment
fileIdstringThe document whose validation failed
data.reasonstringOne of the reasons in the table above
data.errorMessagestringHuman-readable detail, truncated
data.source"STATIC" | "AGENT"Which validation path failed
data.validationAttemptIdstring | nullCorrelates with the attempt's other events. null for attempts started before attempt ids existed.

A Later Verdict Supersedes This Event

A validation that submits late -- an agent that recovers after its run was written off, for example -- still settles the document and emits DOCUMENT_VALIDATED. The event with the later timestamp wins: a DOCUMENT_VALIDATED supersedes an earlier DOCUMENT_VALIDATION_FAILED for the same document.

Delivery is queued, retried and processed concurrently, so receipt order is not state order. Compare timestamp per fileId before overwriting stored state, or re-read the document rather than applying an event blind. Note that this event is attempt-scoped while DOCUMENT_VALIDATED is document-scoped, so the two do not always carry the same validationAttemptId.

Handling the Event

function handleValidationFailed(event) {
const { fileId, data } = event

console.warn(`Validation for ${fileId} did not complete: ${data.reason} (${data.errorMessage})`)

if (data.reason === "AGENT_RUN_FAILED" || data.reason === "TIMEOUT") {
  routeToManualReview(fileId)
} else {
  scheduleRevalidation(fileId)
}
}

On this page