Schema (Legacy)
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.
1 type 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 21 type Enum = { 22 value: string; 23 description: string; 24 };
Configuration Examples
Basic Example
1 const 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 };
Example with Nested Fields
1 const 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 };
Example with nested arrays and objects
1 const 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 };