Skip to content

Document Schema

A document schema defines the fields and structure that a Document Processor extracts from a business attachment. It gives downstream nodes a consistent contract for field names, data types, and repeating rows.

Use case Example fields
Validate invoice lines lineNumber, quantity, amount in a lineItems array.
Compare supplier quotations Quote number, currency, and unit price for each item.
Review delivery paperwork Shipment number, delivery date, and delivered quantities.

Create and publish a schema

  1. Open Resources → Document Schema and select Add.
  2. In Document Schema Builder, enter Name and Description and review Code.
  3. Under Generate Schema From File, select Choose file, choose a representative source document, and select Generate Schema. You can also enter a JSON Schema in Specification.
  4. Review the fields in Specification. Use an object for grouped attributes, an array of objects for repeating rows, and numeric types for amounts and counts. Mark a field required only when the document consistently provides it and downstream processing needs it.
  5. Select Publish, or select Save and Close to keep a draft.

Invoice line extraction example

Create an Invoice Lines schema. Use the following specification for an invoice table with a line number, quantity, and extended amount.

{
  "type": "object",
  "properties": {
    "lineItems": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "lineNumber": {"type": "integer", "description": "Line number printed on the invoice."},
          "quantity": {"type": "number", "description": "Quantity on the invoice line."},
          "amount": {"type": "number", "description": "Extended amount for the whole line."}
        },
        "required": ["lineNumber", "quantity", "amount"]
      }
    }
  },
  "required": ["lineItems"]
}

In the Document Processor node, select the attachment Business Object and Function, and map the record key. Enable Use LLM for data extraction and select the published Invoice Lines schema in Schema Template. Choose a node-specific model if required. For a line numbered 1 with a quantity of 2 and an extended amount of 120, the expected structured result contains {"lineItems":[{"lineNumber":1,"quantity":2,"amount":120}]}.

Check the output in Debug before mapping it to a loop. If lineItems is at the output root of EXTRACT_INVOICE, set the loop's collection to {{$context.$nodes.EXTRACT_INVOICE.$output.lineItems}}. Handle unreadable attachments or missing values before applying the invoice policy.

See Document Processor and Validate an invoice attachment.