Guides
Output types
When running workflows, the webhook payload output will conform to the shape described in the webhook documentation,
however the sub list of workflow_run.outputs
is dynamic based on the type of document processor.
The output shapes for each document processor are described below.
Extract
Example Extract Output
{
"object": "document_processor_run",
"id": "dpr_1234",
"edited": true,
"type": "EXTRACT",
// see ExtractConfig type below
"config": {
"fieldsToExtract": [
{
"id": "field1",
"type": "boolean",
"fieldName": "is_invoice",
"description": "Is this an invoice?"
}
]
},
// see ExtractOutput type below
"initialOutput": {
"is_invoice": {
"id": "field1",
"type": "boolean",
"value": true,
"confidence": 1,
"references": []
}
},
// see ExtractOutput type below
"reviewedOutput": {
"is_invoice": {
"id": "field1",
"type": "boolean",
"value": false,
"confidence": 1,
"references": []
}
},
// see ExtractOutput type below
"output": {
"is_invoice": {
"id": "field1",
"type": "boolean",
"value": false,
"confidence": 1,
"references": []
}
}
}
Extract output and config subfield types
/**
* The output subfield type when type=EXTRACT
* Applies to "initialOutput", "reviewedOutput", and "output" subfields of the document_processor_run object.
*/
type ExtractOutput = {
[key: string]: ExtractFieldResult;
}
type ExtractFieldResult = {
id: string;
value: string | number | Currency | Signature | boolean | ExtractValueArray | ExtractValueObject | null;
confidence: number;
type: "string" | "number" | "currency" | "enum" | "boolean" | "date" | "enum" |"array" | "object" | "signature";
/* Includes the field schema of nested fields (e.g. array fields, object fields, signature fields etc) */
schema: ExtractFieldSchemaValue[];
/* Insights the reasoning and other insights outputs of the model (when reasoning is enabled) */
insights: Insight[];
/* References to the bounding boxes of the model's output when available. Also includes the page number for all fields with or without bounding boxes. */
references: ExtractFieldResultReference[];
/* The enum options for enum fields, only set when type=enum */
enum: EnumOption[];
}
type Currency = {
amount: number;
iso_4217_currency_code: string;
};
type Signature = {
is_signed: boolean;
printed_name: string;
title_or_role: string;
signature_date: string;
};
type EnumOption = {
value: string; // The enum value (e.g. "ANNUAL", "MONTHLY", etc.)
description: string; // The description of the enum value
}
type ExtractValueArray = Array<ExtractValueObject>;
type ExtractValueObject = {
[key: string]: string | number | Currency | boolean | null;
};
type ExtractFieldResultReference = {
/* The field id. When nested for arrays, this is the index of the row number */
id: string;
/* The field name */
fieldName: string;
/* The page number (starting at 1) that this bounding box is from */
page: number;
/**
* Array of bounding box references for this field.
* There can be multiple is the extraction result was drawn from multiple distinct sources on the page.
*/
boundingBoxes: BoundingBox[];
};
/* See the Bounding boxes guide for information on how to use/interpret this data */
type BoundingBox = {
/* The left most position of the bounding box */
left: number;
/* The top most position of the bounding box */
top: number;
/* The right most position of the bounding box */
right: number;
/* The bottom most position of the bounding box */
bottom: number;
};
type Insight = {
type: "reasoning"; // Currently only reasoning is supported
content: string;
}
/**
* The config subfield type when type=EXTRACT
* Applies to "config" subfield of the document_processor_run object.
*/
type ExtractConfig = {
fieldsToExtract: Array<ExtractFieldConfig>;
};
type ExtractFieldConfig = {
id: string;
fieldName: string;
description: string;
type: "string" | "number" | "currency" | "signature" | "boolean" | "date" | "any[]" | "object" | "null";
schema?: ExtractFieldSchemaValue[];
}
type ExtractFieldSchemaValue = {
id: string;
fieldName: string;
description: string;
type: "string" | "number" | "currency" | "boolean" | "date" | "null";
}
Classify
Example Classify Output
{
"object": "document_processor_run",
"id": "dpr_1234",
"edited": true,
"type": "CLASSIFY",
// see ClassifyConfig type below
"config": {
"classifications": [
{
"id": "classification1",
"type": "other",
"description": "Use the `other` document type when the provided document can not clearly be classified into one of the described classifications."
},
{
"id": "classification2",
"type": "invoice",
"description": "an invoice"
}
]
},
// see ClassifyOutput type below
"initialOutput": {
"id": "classification2",
"type": "invoice",
"confidence": 0.95,
},
// see ClassifyOutput type below
"output": {
"id": "classification2",
"type": "invoice",
"confidence": 0.95,
}
}
CLASSIFY output and config subfield types
/**
* The output subfield type when type=CLASSIFY
* Applies to "initialOutput" and "output" subfields of the document_processor_run object.
*/
type ClassifyOutput = {
id: string;
type: string;
confidence: number;
insights: Insight[];
};
/**
* The config subfield type when type=CLASSIFY
* Applies to "config" subfield of the document_processor_run object.
*/
type ClassifyConfig = {
classifications: Classification[];
}
type Classification = {
id: string;
type: string;
description: string;
};
Splitter
export type SplitterOutput = {
subDocuments: SubDocument[];
};
type SubDocument = {
type: string; // The type of the subdocument, (e.g. "invoice", "addendum", etc.)
identifier: string; // The identifier of the subdocument, (e.g. "invoice_48")
startPage: number; // The starting page number of the subdocument
endPage: number; // The ending page number of the subdocument
}
Shared types
Shared types
/**
* Insights are the reasoning and other insights outputs of the model (when reasoning is enabled)
*/
type Insight = {
type: "reasoning"; // Currently only reasoning is supported
content: string;
}