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
{
"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
{
"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
| Field | Type | Description |
|---|---|---|
eventId | string | Unique event identifier. Use for idempotency. |
eventType | string | Always "DOCUMENT_EXTRACTED" |
timestamp | ISO 8601 | When the extraction completed (UTC) |
organizationId | string | Your organization identifier |
projectId | string | The project the document belongs to |
deploymentId | string | The ID of the model that processed this document |
viaDeploymentId | string | null | The ID of the deployment the request arrived through. null when the request named the model directly |
deploymentName | string | null | The name of that deployment, such as "production". null whenever viaDeploymentId is null |
schemaVersionId | string | null | The ID of the frozen schema version the run resolved to. null when the deployment tracks the draft schema |
extractionSchemaId | string | The extraction schema ID of that model |
fileId | string | The processed file identifier |
jobId | string | The extraction job identifier |
data.status | "success" | "failed" | Extraction result |
data.errorMessage | string | null | Error 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.