Extract Data from Document Action
Extracts structured data from a document by using Intelligent Document Processing (IDP). Send a Base64-encoded file directly for processing without uploading it to Salesforce first.
This action is available in API version 62.0 and later.
Use the extractDataFromDocument action to extract field values from documents, such as invoices, receipts, and forms. The action processes the document against an IDP configuration that defines which fields to extract. It returns structured data with confidence scores for each extracted field.
This action is part of MuleSoft for Flow and requires the Automation 2.0 SKU. Your org must have Data Cloud and Einstein provisioned with the Document Processing org permission enabled.
When any extracted field has a confidence score less than its configured threshold, the response sets needsManualReview to True.
URI: /services/data/vXX.0/actions/standard/extractDataFromDocument
Formats: JSON
HTTP Methods: POST
Authentication: Authorization: Bearer token
The authenticated user must have the Document Processing permission.
| Input | Type | Description |
|---|---|---|
documentProcessingConfiguration | string | Required. Name of the IDP configuration that defines which fields to extract. |
fileContent | string | Required. Base64-encoded content of the file to process. Provide together with mimeType. |
mimeType | string | Required. MIME type of the file. Provide together with fileContent. Supported values: application/pdf, image/png, image/jpeg, image/jpg. |
fileContent and mimeType are runtime-only fields available through REST API and Apex. They don’t appear in Flow Builder, where you use contentDocumentId instead.
| Output | Type | Description |
|---|---|---|
contentDocumentId | string | The Salesforce content document ID. Null when the file was sent via fileContent. |
documentProcessingConfigurationId | string | The ID of the IDP configuration used for extraction. |
extractedData | object | Structured extraction results. Each field defined in the IDP configuration appears as a property with value, confidence_score, and confidence_threshold sub-properties. See Extracted Data Structure. |
extractedDataJson | string | JSON string representation of the extracted data. Each field includes type, value, confidence_score, and confidence_threshold. |
needsManualReview | boolean | True when any extracted field has a confidence score less than its configured threshold. See Extracted Data Structure. |
Each field defined in the IDP configuration appears in extractedData with two entries:
- A top-level
fieldName_setboolean flag indicating whether the field found in the document. - A
fieldNameobject containing the extraction details.
Field names use hex encoding for special characters: x20 represents a space and x5f represents an underscore. For example, phonex20number corresponds to the phone number field in your IDP configuration.
Each field object contains:
| Property | Type | Description |
|---|---|---|
value_set | boolean | True if a value extracted for this field. |
value | string or boolean | The extracted value. |
confidencex5fthreshold_set | boolean or null | True if a confidence threshold configured. Null for the needsManualReview field. |
confidencex5fthreshold | integer or null | The minimum confidence score configured for this field. Null for needsManualReview. |
confidencex5fscore_set | boolean or null | True if a confidence score computed. Null for needsManualReview. |
confidencex5fscore | integer or null | The model’s confidence in the extraction (0–100). Null for needsManualReview. |
The needsManualReview field is a special output. Its value is true when any extracted field has a confidence score (rounded) less than its configured threshold. Its confidence properties are always null.
Confidence scores in
Confidence scores in extractedData are integers from 0 to 100. In extractedDataJson, the same scores are represented as decimals from 0 to 1.0. For example, a score of 99 in extractedData appears as 0.99 in extractedDataJson.
Sample Input
This sample extracts data from a Base64-encoded PDF by using the Extract Data from Document action.
Sample Output
The response returns extracted field values with confidence scores.
When extraction fails, isSuccess is false and the errors array contains details. Common causes include:
- Invalid or nonexistent
documentProcessingConfigurationname. - Unsupported
mimeTypevalue. - Malformed or empty
fileContent(not valid Base64). - The file exceeds the org’s REST API request body size limit.
- The caller lacks the Document Processing permission.
- The
fileContentandmimeTypeare always provided together. You can’t send one without the other. - Use
fileContentto process a file directly without uploading it to Salesforce first. This approach avoids creating a ContentDocument record. - The maximum file size depends on your org’s REST API request body limits.
- The
needsManualReviewflag is true when any field’s rounded confidence score falls less than its configured threshold.
See Also