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.
Payload Structure
Successful Extraction
Response200
{
"eventId": "evt_success_456",
"eventType": "DOCUMENT_EXTRACTED",
"timestamp": "2024-01-15T10:30:45Z",
"organizationId": "org_xyz789",
"deploymentId": "dep_123abc",
"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",
"deploymentId": "dep_123abc",
"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 |
deploymentId | string | The deployment that processed this document |
extractionSchemaId | string | The extraction schema used |
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 |
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.