Processor configs

Document Processor Configuration Guide

Document processors are the core components that analyze and manipulate information from your documents. This guide explains how to configure processors through our API, including detailed examples for each processor type.

Overview

We support three types of document processors:

  • Extraction Processors: Extract specific fields from documents.
  • Classification Processors: Categorize documents.
  • Splitter Processors: Divide documents into logical sub-documents.

Generally we recommend using our UI for configuration, but the API can be useful in programmatic workflows, when you need to configure a large number of processors, or when you need to keep your configurations in source control and versioned.

You can also use our webhook events to consume changes made to configurations in the Extend Dashboard and keep your saved configurations in sync.

Schema Definitions

Base Processor Schema

All processor configurations share these base properties:

1type BaseProcessorConfig = {
2 // Base properties inherited by all processor types
3 baseProcessor?: string;
4 baseVersion?: string;
5};

They will be set by default to latest available on processor creation unless otherwise specified - see Changelog for more details. Specify these if you need to pin your processor to a specific underlying model version for consistent behavior or to use features available only in certain versions.

Extraction Processor Configuration

Extraction processors extract specific fields from documents.

1// Either schema or fields must be provided, but not both
2type ExtractionConfig = {
3 type: "EXTRACT";
4 baseProcessor?: string;
5 baseVersion?: string;
6 extractionRules?: string;
7 schema: RootJSONSchema; // See the JSON Schema Structure section below
8 fields: ExtractionField[]; // (Deprecated) See the Fields Array section below
9 advancedOptions?: ExtractionAdvancedOptions;
10};
11
12type ExtractionAdvancedOptions = {
13 documentKind?: string;
14 keyDefinitions?: string;
15 modelReasoningInsightsEnabled?: boolean;
16 advancedMultimodalEnabled?: boolean;
17 citationsEnabled?: boolean;
18 autoReviewAssistantEnabled?: boolean;
19 advancedFigureParsingEnabled?: boolean;
20 chunkingOptions?: ExtractChunkingOptions;
21 fixedPageLimit?: number;
22};
23
24type ExtractChunkingOptions = {
25 chunkingStrategy?: "standard" | "semantic";
26 pageChunkSize?: number;
27 chunkSelectionStrategy?:
28 | "intelligent"
29 | "confidence"
30 | "take_first"
31 | "take_last";
32 customSemanticChunkingRules?: string;
33};

JSON Schema Structure (schema)

This section is relevant for processors using the JSON Schema config type. If you are using the legacy Fields Array config type, please see the Fields Array Structure documentation. If you aren’t sure which config type you are using, please see the Migrating to JSON Schema documentation.

We use JSON Schema to define the structure of the data we extract. Before you get started, we recommend familiarizing yourself with the JSON Schema documentation to understand how to define your schema.

The standard JSON Schema is extremely flexible. We’ve implemented a subset of the standard to support the needs of document extraction. Your schema must follow these rules:

  • The root must be an object type
  • Allowed types are string, number, integer, boolean, object, and array
  • All primitive fields (string, number, boolean, integer) must be nullable (use array type with “null” as an option e.g. "type": ["string", "null"]). If you do not provide a “null” option, it will be automatically added.
  • Maximum nesting level is 3 (each non-root object counts as 1 level)
  • Property keys and names can contain letters, numbers, underscores, and hyphens
  • Array items must be objects
  • Enums must only contain strings and must contain a null option. If you do not provide a null option, it will be automatically added.
  • Custom types are supported by adding a "extend:type": "currency", "extend:type": "signature", or "extend:type": "date" property to the appropriate field type with the required properties. See below for examples.
  • Property names can be added using the "extend:name" property. If supplied, this will override the name of the property as it will appear to the model, but not in the output returned to you. This is useful for providing more descriptive names or instructions to the model without altering the actual keys in your output data structure.
  • You can add descriptions to individual enum values using the "extend:descriptions" property.

Unsupported Features

While we support the JSON Schema structure, we do not support many of the additional features some of which include:

Schema Examples

Primitive Schema

All primitive types must be nullable.

1{
2 "field_name": {
3 "type": ["string", "null"],
4 "description": "Field description"
5 },
6 "numeric_field": {
7 "type": ["number", "null"],
8 "description": "A numeric field"
9 },
10 "integer_field": {
11 "type": ["integer", "null"],
12 "description": "An integer field"
13 },
14 "boolean_field": {
15 "type": ["boolean", "null"],
16 "description": "A boolean field"
17 }
18}

Object Schema

Objects must have properties. If you set a required array of the properties, we will respect that order when extracting. If you do not set required array, we will generate it and enforce order.

1{
2 "address": {
3 "type": "object",
4 "properties": {
5 "street": {
6 "type": ["string", "null"],
7 "description": "Street address"
8 },
9 "city": {
10 "type": ["string", "null"],
11 "description": "City name"
12 }
13 },
14 "required": ["street", "city"]
15 }
16}

Array Schema

Arrays items must be objects.

1{
2 "line_items": {
3 "type": "array",
4 "items": {
5 "type": "object",
6 "properties": {
7 "description": {
8 "type": ["string", "null"],
9 "description": "Item description"
10 },
11 "quantity": {
12 "type": ["number", "null"],
13 "description": "Item quantity"
14 },
15 "price": {
16 "type": ["number", "null"],
17 "description": "Item price"
18 }
19 },
20 "required": ["description", "quantity", "price"]
21 },
22 "description": "List of items in the invoice"
23 }
24}

Enum Schema

Enums must include null as an option. Only strings are supported for enums. The extend:descriptions is an optional array of strings. It is recommended to give more context for each enum option for more accurate extraction.

1{
2 "status": {
3 "enum": ["pending", "approved", "rejected", null],
4 "extend:descriptions": [
5 "Invoice is pending approval",
6 "Invoice has been approved",
7 "Invoice has been rejected",
8 ""
9 ],
10 "description": "Current status of the invoice"
11 }
12}

Custom Field Types

The extend:type keyword enables custom pre-processing and post-processing of fields which bake in best practices and heuristics for the field type.

Date Schema

Date fields must be strings and use the extend:type keyword with the value date. This will guarantee the date format is always an ISO compliant date (yyyy-mm-dd).

1{
2 "invoice_date": {
3 "type": ["string", "null"],
4 "extend:type": "date",
5 "description": "The invoice date"
6 }
7}

Currency Schema

Currency fields must be objects with specific properties.

1{
2 "price": {
3 "type": "object",
4 "extend:type": "currency",
5 "properties": {
6 "amount": {
7 "type": ["number", "null"],
8 },
9 "iso_4217_currency_code": {
10 "type": ["string", "null"],
11 }
12 },
13 "required": ["amount", "iso_4217_currency_code"]
14 }
15}

Signature Schema

Signature fields must be objects with specific properties. This will auto-enable our advanced signature detection in the parsing step prior to extraction, and apply a number of prompt and post-processing heuristics to improve accuracy, particularly on reduction of false positives for signature blocks that are not actually signed.

1{
2 "signature": {
3 "type": "object",
4 "extend:type": "signature",
5 "properties": {
6 "printed_name": {
7 "type": ["string", "null"],
8 },
9 "signature_date": {
10 "type": ["string", "null"],
11 "extend:type": "date",
12 },
13 "is_signed": {
14 "type": ["boolean", "null"],
15 },
16 "title_or_role": {
17 "type": ["string", "null"],
18 }
19 },
20 "required": ["printed_name", "signature_date", "is_signed", "title_or_role"]
21 }
22}

Configuration Examples

1const basicExtractionConfig = {
2 type: "EXTRACT",
3 schema: {
4 type: "object",
5 properties: {
6 invoice_number: {
7 type: ["string", "null"],
8 description: "The unique identifier for this invoice",
9 },
10 invoice_amount: {
11 type: "object",
12 "extend:type": "currency",
13 description: "The total amount of the invoice",
14 properties: {
15 amount: {
16 type: ["number", "null"],
17 },
18 iso_4217_currency_code: {
19 type: ["string", "null"],
20 },
21 },
22 required: ["amount", "iso_4217_currency_code"],
23 },
24 },
25 required: ["invoice_number", "invoice_amount"],
26 },
27};
1const complexExtractionConfig = {
2 type: "EXTRACT",
3 schema: {
4 type: "object",
5 properties: {
6 line_items: {
7 type: "array",
8 description: "Individual items in the invoice",
9 items: {
10 type: "object",
11 properties: {
12 item_name: {
13 type: ["string", "null"],
14 description: "Name of the item",
15 },
16 quantity: {
17 type: ["number", "null"],
18 description: "Number of items",
19 },
20 unit_price: {
21 type: "object",
22 properties: {
23 amount: {
24 type: ["number", "null"],
25 description: "Price per unit",
26 },
27 iso_4217_currency_code: {
28 type: ["string", "null"],
29 description: "Currency code",
30 },
31 },
32 required: ["amount", "iso_4217_currency_code"],
33 },
34 },
35 required: ["item_name", "quantity", "unit_price"],
36 },
37 },
38 payment_status: {
39 description: "Current payment status",
40 enum: ["PAID", "PENDING", null],
41 "extend:descriptions": [
42 "Payment has been completed",
43 "Payment is pending",
44 "",
45 ],
46 },
47 },
48 required: ["line_items", "payment_status"],
49 },
50 customExtractionRules: "- If ...", // Optional custom rules
51 customDocumentKind: "invoice", // Optionally specify a document kind
52 includeBoundingBoxCitations: true, // Turns on llm-powered citations and bounding box references
53 includeModelReasoning: true, // Exposes the model's chain of thought reasoning for each field result
54};
1const nestedArrayConfig = {
2 type: "EXTRACT",
3 schema: {
4 type: "object",
5 properties: {
6 orders: {
7 type: "array",
8 description: "List of customer orders",
9 items: {
10 type: "object",
11 properties: {
12 order_id: {
13 type: ["string", "null"],
14 description: "Unique identifier for the order",
15 },
16 customer_name: {
17 type: ["string", "null"],
18 description: "Name of the customer",
19 },
20 shipments: {
21 type: "array",
22 description: "List of shipments for this order",
23 items: {
24 type: "object",
25 properties: {
26 tracking_number: {
27 type: ["string", "null"],
28 description: "Shipping tracking number",
29 },
30 ship_date: {
31 type: ["string", "null"],
32 "extend:type": "date",
33 description: "Date the shipment was sent",
34 },
35 carrier: {
36 type: ["string", "null"],
37 description: "Shipping carrier name",
38 },
39 },
40 required: ["tracking_number", "ship_date", "carrier"],
41 },
42 },
43 },
44 required: ["order_id", "customer_name", "shipments"],
45 },
46 },
47 },
48 required: ["orders"],
49 },
50};
1const customFieldConfig = {
2 type: "EXTRACT",
3 schema: {
4 type: "object",
5 properties: {
6 invoice_signature: {
7 type: "object",
8 description: "Details of the invoice signature",
9 properties: {
10 printed_name: {
11 type: ["string", "null"],
12 description: "The printed name of the signer",
13 },
14 signature_date: {
15 type: ["string", "null"],
16 "extend:type": "date",
17 description: "The date the signature was applied",
18 },
19 is_signed: {
20 type: ["boolean", "null"],
21 description: "Indicates if the document is signed",
22 },
23 title_or_role: {
24 type: ["string", "null"],
25 description: "The title or role of the signer",
26 },
27 },
28 required: [
29 "printed_name",
30 "signature_date",
31 "is_signed",
32 "title_or_role",
33 ],
34 },
35 invoice_amount: {
36 type: "object",
37 "extend:type": "currency",
38 description: "The amount of the invoice",
39 properties: {
40 amount: {
41 type: ["number", "null"],
42 description: "The numerical value of the amount",
43 },
44 iso_4217_currency_code: {
45 type: ["string", "null"],
46 description: "The ISO 4217 currency code (e.g., USD, EUR)",
47 },
48 },
49 required: ["amount", "iso_4217_currency_code"],
50 },
51 invoice_date: {
52 type: "date",
53 description: "The date of the invoice",
54 },
55 },
56 required: ["signature", "invoice_amount", "invoice_date"],
57 },
58};

Type Definitions

1// Root schema
2type RootJSONSchema = {
3 type: "object";
4 properties: {
5 [key: string]: JSONSchema;
6 };
7 required: string[];
8 additionalProperties?: boolean;
9};
10
11// Common schema properties that all types can have
12type BaseJSONSchema = {
13 "extend:name"?: string;
14 description?: string;
15};
16
17// Enum schema
18type EnumJSONSchema = BaseJSONSchema & {
19 enum: (string | null)[]; // null will be automatically added if not provided
20 "extend:descriptions"?: string[];
21};
22
23// String schema
24type StringJSONSchema = BaseJSONSchema & {
25 type: ["string", "null"];
26 "extend:type"?: "date";
27};
28
29// Structure for a date field
30type DateStringSchema = BaseJSONSchema & {
31 type: ["string", "null"];
32 "extend:type": "date";
33};
34
35// Number schema
36type NumberJSONSchema = BaseJSONSchema & {
37 type: ["number", "null"];
38};
39
40// Integer schema
41type IntegerJSONSchema = BaseJSONSchema & {
42 type: ["integer", "null"];
43};
44
45// Boolean schema
46type BooleanJSONSchema = BaseJSONSchema & {
47 type: ["boolean", "null"];
48};
49
50// Array schema
51type ArrayJSONSchema = BaseJSONSchema & {
52 type: "array";
53 items: ObjectJSONSchema; // we only support objects in arrays for now
54};
55
56// Object schema
57type ObjectJSONSchema = BaseJSONSchema & {
58 type: "object";
59 properties: {
60 [key: string]: JSONSchema;
61 };
62 required: string[];
63 additionalProperties?: boolean;
64};
65
66// Required structure for a currency field
67type CurrencyObjectSchema = BaseJSONSchema & {
68 type: "object";
69 "extend:type": "currency";
70 properties: {
71 amount: {
72 type: ["number", "null"];
73 };
74 iso_4217_currency_code: {
75 type: ["string", "null"];
76 };
77 };
78 required: ["amount", "iso_4217_currency_code"];
79};
80
81// Required structure for a signature field
82type SignatureObjectSchema = BaseJSONSchema & {
83 type: "object";
84 "extend:type": "signature";
85 properties: {
86 printed_name: {
87 type: ["string", "null"];
88 };
89 signature_date: {
90 type: ["string", "null"];
91 "extend:type": "date"; // Note: The date itself also uses extend:type
92 };
93 is_signed: {
94 type: ["boolean", "null"];
95 };
96 title_or_role: {
97 type: ["string", "null"];
98 };
99 };
100 required: ["printed_name", "signature_date", "is_signed", "title_or_role"];
101};
102
103// Union of all schema types
104type JSONSchema =
105 | EnumJSONSchema
106 | StringJSONSchema
107 | NumberJSONSchema
108 | IntegerJSONSchema
109 | BooleanJSONSchema
110 | ArrayJSONSchema
111 | ObjectJSONSchema
112 | DateStringSchema
113 | CurrencyObjectSchema
114 | SignatureObjectSchema;

Fields Array Structure (fields)

This section is relevant for the Fields Array config type. If you are using the JSON Schema config type, please see the JSON Schema Structure documentation. If you aren’t sure which config type you are using, please see the Migrating to JSON Schema documentation.

1type ExtractionField = {
2 id: string;
3 name: string;
4 type:
5 | "string"
6 | "number"
7 | "currency"
8 | "boolean"
9 | "date"
10 | "array"
11 | "enum"
12 | "object"
13 | "signature";
14 description: string;
15 // Required for nested fields (arrays, objects, signatures)
16 schema?: ExtractionField[];
17 // Required for enums
18 enum?: Enum[];
19};
20
21type Enum = {
22 value: string;
23 description: string;
24};

Configuration Examples

1const extractionConfig = {
2 type: "EXTRACT",
3 fields: [
4 {
5 id: "invoice_number",
6 name: "Invoice Number",
7 type: "string",
8 description: "The unique identifier for this invoice",
9 },
10 {
11 id: "amount",
12 name: "Total Amount",
13 type: "currency",
14 description: "The total amount of the invoice",
15 },
16 ],
17};
1const complexExtractionConfig = {
2 type: "EXTRACT",
3 fields: [
4 {
5 id: "line_items",
6 name: "Line Items",
7 type: "array",
8 description: "Individual items in the invoice",
9 schema: [
10 {
11 id: "item_name",
12 name: "Item Name",
13 type: "string",
14 description: "Name of the item",
15 },
16 {
17 id: "quantity",
18 name: "Quantity",
19 type: "number",
20 description: "Number of items",
21 },
22 {
23 id: "unit_price",
24 name: "Unit Price",
25 type: "currency",
26 description: "Price per unit",
27 },
28 ],
29 },
30 {
31 id: "payment_status",
32 name: "Payment Status",
33 type: "enum",
34 description: "Current payment status",
35 enum: [
36 {
37 value: "PAID",
38 description: "Payment has been completed",
39 },
40 {
41 value: "PENDING",
42 description: "Payment is pending",
43 },
44 ],
45 },
46 ],
47 extractionRules: "- If ...", // Optional extraction rules
48 advancedOptions: {
49 modelReasoningInsightsEnabled: true,
50 },
51};
1const nestedArrayConfig = {
2 type: "EXTRACT",
3 fields: [
4 {
5 id: "orders",
6 name: "Orders",
7 type: "array",
8 description: "List of customer orders",
9 schema: [
10 {
11 id: "order_id",
12 name: "Order ID",
13 type: "string",
14 description: "Unique identifier for the order",
15 },
16 {
17 id: "customer_name",
18 name: "Customer Name",
19 type: "string",
20 description: "Name of the customer",
21 },
22 {
23 id: "shipments",
24 name: "Shipments",
25 type: "array",
26 description: "List of shipments for this order",
27 schema: [
28 {
29 id: "tracking_number",
30 name: "Tracking Number",
31 type: "string",
32 description: "Shipping tracking number",
33 },
34 {
35 id: "ship_date",
36 name: "Ship Date",
37 type: "date",
38 description: "Date the shipment was sent",
39 },
40 {
41 id: "carrier",
42 name: "Carrier",
43 type: "string",
44 description: "Shipping carrier name",
45 },
46 ],
47 },
48 ],
49 },
50 ],
51};

Classification Processor Configuration

Classification processors categorize documents into predefined types.

1type ClassificationConfig = {
2 type: "CLASSIFY";
3 baseProcessor?: string;
4 baseVersion?: string;
5 classifications: Classification[];
6 classificationRules?: string;
7 advancedOptions?: ClassificationAdvancedOptions;
8};
9
10type Classification = {
11 id: string;
12 type: string;
13 description: string;
14};
15
16type ClassificationAdvancedOptions = {
17 context?: "default" | "max";
18 advancedMultimodalEnabled?: boolean;
19 fixedPageLimit?: number;
20};

Configuration Example

1const classificationConfig = {
2 type: "CLASSIFY",
3 classifications: [
4 {
5 id: "invoice",
6 type: "INVOICE",
7 description: "Standard invoice document ...",
8 },
9 {
10 id: "bill_of_lading",
11 type: "BILL_OF_LADING",
12 description: "Bill of Lading document ...",
13 },
14 ],
15 classificationRules: "- If ...", // Optional custom rules
16};

Splitter Processor Configuration

Splitter processors divide documents into logical sub-documents based on defined classifications.

1type SplitterConfig = {
2 type: "SPLITTER";
3 baseProcessor?: string;
4 baseVersion?: string;
5 splitClassifications: Classification[];
6 splitRules?: string;
7 advancedOptions?: SplitterAdvancedOptions;
8};
9
10type SplitterAdvancedOptions = {
11 splitIdentifierRules?: string;
12 splitMethod?: "high_precision" | "low_latency";
13 splitExcelDocumentsBySheetEnabled?: boolean;
14 fixedPageLimit?: number;
15};

Configuration Example

1const splitterConfig = {
2 type: "SPLITTER",
3 splitClassifications: [
4 {
5 id: "purchase_contract",
6 type: "PURCHASE_CONTRACT",
7 description: "Purchase contract section",
8 },
9 {
10 id: "addendum",
11 type: "ADDENDUM",
12 description: "Addendum section",
13 },
14 ],
15 splitRules: "- If ...", // Optional custom rules
16 advancedOptions: {
17 splitMethod: "high_precision",
18 },
19};