> ## Documentation Index
> Fetch the complete documentation index at: https://docs.turrisfi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Document Extraction Completed

> Webhook event triggered when Turris finishes reading an E&O, cyber, W-9 or crime/fidelity document

> [!NOTE]
>
> **Webhooks belong to the Carrier & MGA API.** This event fires about an agency you appoint, and only a credential on that surface
> (carrier, MGA or wholesaler) can subscribe to it.

## Overview

The `DOCUMENT_EXTRACTION_COMPLETED` webhook is triggered when Turris finishes reading an agency's **E\&O**, **cyber**, **W-9** or **crime/fidelity** document, whether it succeeded or failed. Subscribe to it instead of polling for the extraction status.

**Webhook type:** `DOCUMENT_EXTRACTION_COMPLETED`

### Triggers

This webhook fires when:

* Extraction on a document you uploaded (for example with [Upload a Document](https://docs.turrisfi.com/api-reference/v2/file-documents/upload-document.md)) finishes
* Extraction on a document the agency uploaded itself, and that you can see, finishes
* A W-9's status changes after the agency corrects its details in Turris

It fires once per outcome. If a document is read again and finishes again, you receive another delivery.

### Who receives it

You receive it when the extracted version is the one you currently see for that agency: the same version [Get E\&O/Cyber Compliance](https://docs.turrisfi.com/api-reference/v2/eo-cyber-compliance/get-policy-compliance.md) would return to you. A document the agency shares with several carriers notifies each of them. A version you uploaded yourself notifies only you. If you have since uploaded a newer version, you are not notified about the older one.

> [!NOTE]
>
> This webhook is sent **immediately**. No debouncing is applied, since each extraction is a discrete event.

## Payload Example

```json theme={null}
{
  "webhookType": "DOCUMENT_EXTRACTION_COMPLETED",
  "upstreamEntityId": "507f1f77bcf86cd799439010",
  "payload": {
    "downstreamEntityAssociationId": "507f1f77bcf86cd799439011",
    "downstreamEntityId": "507f1f77bcf86cd799439012",
    "fileDocumentId": "6a1710bcc80172422211a421",
    "metadataId": "6a1710bcc80172422211a41f",
    "category": "E&O",
    "extractionStatus": "success",
    "failureReason": null
  }
}
```

## Field Reference

### Payload Fields

| Field | Type | Description |
| - | - | - |
| `downstreamEntityAssociationId` | string | The ID of the association between the agency and your upstream entity |
| `downstreamEntityId` | string | The ID of the agency (downstream entity) the document belongs to |
| `fileDocumentId` | string | The ID of the document. Use with [List File Documents](https://docs.turrisfi.com/api-reference/v2/file-documents/list-documents.md) and [Get a Download URL for a Document](https://docs.turrisfi.com/api-reference/v2/file-documents/get-download-url.md) |
| `metadataId` | string | The ID of the extraction record. The same value as `versions[].metadataId` on the file document, and as `eAndO._id` / `cyber._id` on Get E\&O/Cyber Compliance |
| `category` | string | `E&O`, `Cyber`, `W9` or `Crime & Fidelity`. The same values the file-documents endpoints use |
| `extractionStatus` | string | `success` or `error` |
| `failureReason` | string \| null | Why extraction failed, when Turris can tell: `wrong document type` when the file is not the kind of document its category says. `null` on success and when the reason is unknown |

## Reading the extracted data

The payload tells you that extraction finished, not what it found. After a delivery:

* **E\&O and cyber:** call [Get E\&O/Cyber Compliance](https://docs.turrisfi.com/api-reference/v2/eo-cyber-compliance/get-policy-compliance.md) with `downstreamEntityAssociationId` to read the policy details.
* **W-9 and crime/fidelity:** the extracted details are not available through the API yet. The status in the payload tells you whether the document was read, and you can download the file with `fileDocumentId`.


## Related topics

- [Changelog](https://docs.turrisfi.com/changelog.md)
- [Webhooks Overview](https://docs.turrisfi.com/guides/webhooks.md)
- [Send Test Event](https://docs.turrisfi.com/api-reference/v2/webhooks/test-webhook.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.