> ## Documentation Index
> Fetch the complete documentation index at: https://docs.extend.ai/llms.txt
> Use this file to discover all available pages before exploring further.
>
> ## API version
> The current API version is `2026-02-09`, served at the site root (no version prefix in URLs).
> If this page URL contains `/2025-04-21/` or `/2024-12-23/`, you are reading an older API version.
> Prefer the current docs at https://docs.extend.ai/llms.txt unless the user explicitly needs that older version.
> Do not treat older-version pages as the source of truth for new integrations.

# Extraction Schema

> Define your extractor’s output using JSON Schema, with examples and links to deeper docs.

### JSON Schema Structure (`schema`)

We use [JSON Schema](https://json-schema.org/) to define the structure of the data we extract. Before you get started, we recommend familiarizing yourself with the [JSON Schema](https://json-schema.org/) 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"]`). Non-nullable primitive types will be rejected with a `400` error.
* Maximum nesting level is 5 (each non-root object counts as 1 level)
* Property keys and names can contain letters, numbers, underscores, and hyphens
* Array items can be objects or primitive types (`string`, `number`, `integer`, `boolean`)
* Enums must only contain strings and must contain a `null` option. Enums without `null` will be rejected with a `400` error.
* 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 composition](https://json-schema.org/understanding-json-schema/reference/composition) like `anyOf`, `oneOf`, `allOf`, schema definitions, or recursive schemas
* [Regular expressions](https://json-schema.org/understanding-json-schema/reference/regular_expressions) and other [type-specific validation keywords](https://json-schema.org/understanding-json-schema/reference/type)
* [Conditional schema validation](https://json-schema.org/understanding-json-schema/reference/conditionals)
* [Constant values](https://json-schema.org/understanding-json-schema/reference/const)

### Schema Examples

#### Primitive Schema

All primitive types must be nullable.

```json
{
  "field_name": {
    "type": ["string", "null"],
    "description": "Field description"
  },
  "numeric_field": {
    "type": ["number", "null"],
    "description": "A numeric field"
  },
  "integer_field": {
    "type": ["integer", "null"],
    "description": "An integer field"
  },
  "boolean_field": {
    "type": ["boolean", "null"],
    "description": "A boolean field"
  }
}
```

#### 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.

```json
{
  "address": {
    "type": "object",
    "properties": {
      "street": {
        "type": ["string", "null"],
        "description": "Street address"
      },
      "city": {
        "type": ["string", "null"],
        "description": "City name"
      }
    },
    "required": ["street", "city"]
  }
}
```

#### Array Schema

Arrays can contain either objects or primitive types (`string`, `number`, `integer`, `boolean`). Primitive array items are not nullable.

##### Array of Objects

```json
{
  "line_items": {
    "type": "array",
    "items": {
      "type": "object",
      "properties": {
        "description": {
          "type": ["string", "null"],
          "description": "Item description"
        },
        "quantity": {
          "type": ["number", "null"],
          "description": "Item quantity"
        },
        "price": {
          "type": ["number", "null"],
          "description": "Item price"
        }
      },
      "required": ["description", "quantity", "price"]
    },
    "description": "List of items in the invoice"
  }
}
```

##### Array of Scalars

```json
{
  "product_tags": {
    "type": "array",
    "items": {
      "type": "string"
    },
    "description": "List of product tags or categories"
  }
}
```

#### 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.

```json
{
  "status": {
    "enum": ["pending", "approved", "rejected", null],
    "extend:descriptions": [
      "Invoice is pending approval",
      "Invoice has been approved",
      "Invoice has been rejected",
      ""
    ],
    "description": "Current status of the invoice"
  }
}
```

### 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).

```json
{
  "invoice_date": {
    "type": ["string", "null"],
    "extend:type": "date",
    "description": "The invoice date"
  }
}
```

#### Currency Schema

Currency fields must be objects with specific properties.

```json
{
  "price": {
    "type": "object",
    "extend:type": "currency",
    "properties": {
      "amount": {
        "type": ["number", "null"]
      },
      "iso_4217_currency_code": {
        "type": ["string", "null"]
      }
    },
    "required": ["amount", "iso_4217_currency_code"]
  }
}
```

#### 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.

```json
{
  "signature": {
    "type": "object",
    "extend:type": "signature",
    "properties": {
      "printed_name": {
        "type": ["string", "null"]
      },
      "signature_date": {
        "type": ["string", "null"],
        "extend:type": "date"
      },
      "is_signed": {
        "type": ["boolean", "null"]
      },
      "title_or_role": {
        "type": ["string", "null"]
      }
    },
    "required": ["printed_name", "signature_date", "is_signed", "title_or_role"]
  }
}
```

### Configuration Examples

#### Basic Example

```json
{
  "schema": {
    "type": "object",
    "properties": {
      "invoice_number": {
        "type": ["string", "null"],
        "description": "The unique identifier for this invoice"
      },
      "invoice_amount": {
        "type": "object",
        "extend:type": "currency",
        "description": "The total amount of the invoice",
        "properties": {
          "amount": {
            "type": ["number", "null"]
          },
          "iso_4217_currency_code": {
            "type": ["string", "null"]
          }
        },
        "required": ["amount", "iso_4217_currency_code"]
      }
    },
    "required": ["invoice_number", "invoice_amount"]
  }
}
```

#### Example with nested fields

```json
{
  "schema": {
    "type": "object",
    "properties": {
      "line_items": {
        "type": "array",
        "description": "Individual items in the invoice",
        "items": {
          "type": "object",
          "properties": {
            "item_name": {
              "type": ["string", "null"],
              "description": "Name of the item"
            },
            "quantity": {
              "type": ["number", "null"],
              "description": "Number of items"
            },
            "unit_price": {
              "type": "object",
              "properties": {
                "amount": {
                  "type": ["number", "null"],
                  "description": "Price per unit"
                },
                "iso_4217_currency_code": {
                  "type": ["string", "null"],
                  "description": "Currency code"
                }
              },
              "required": ["amount", "iso_4217_currency_code"]
            }
          },
          "required": ["item_name", "quantity", "unit_price"]
        }
      },
      "payment_status": {
        "description": "Current payment status",
        "enum": ["PAID", "PENDING", null],
        "extend:descriptions": [
          "Payment has been completed",
          "Payment is pending",
          ""
        ]
      }
    },
    "required": ["line_items", "payment_status"]
  }
}
```

#### Example with scalar arrays

```json
{
  "schema": {
    "type": "object",
    "properties": {
      "product_categories": {
        "type": "array",
        "description": "List of product categories",
        "items": {
          "type": "string"
        }
      }
    },
    "required": ["product_categories"]
  }
}
```

#### Example with nested arrays and objects

```json
{
  "schema": {
    "type": "object",
    "properties": {
      "orders": {
        "type": "array",
        "description": "List of customer orders",
        "items": {
          "type": "object",
          "properties": {
            "order_id": {
              "type": ["string", "null"],
              "description": "Unique identifier for the order"
            },
            "customer_name": {
              "type": ["string", "null"],
              "description": "Name of the customer"
            },
            "shipments": {
              "type": "array",
              "description": "List of shipments for this order",
              "items": {
                "type": "object",
                "properties": {
                  "tracking_number": {
                    "type": ["string", "null"],
                    "description": "Shipping tracking number"
                  },
                  "ship_date": {
                    "type": ["string", "null"],
                    "extend:type": "date",
                    "description": "Date the shipment was sent"
                  },
                  "carrier": {
                    "type": ["string", "null"],
                    "description": "Shipping carrier name"
                  }
                },
                "required": ["tracking_number", "ship_date", "carrier"]
              }
            }
          },
          "required": ["order_id", "customer_name", "shipments"]
        }
      }
    },
    "required": ["orders"]
  }
}
```

#### Example with signature, currency, and date fields

```json
{
  "schema": {
    "type": "object",
    "properties": {
      "invoice_signature": {
        "type": "object",
        "extend:type": "signature",
        "description": "Details of the invoice signature",
        "properties": {
          "printed_name": {
            "type": ["string", "null"],
            "description": "The printed name of the signer"
          },
          "signature_date": {
            "type": ["string", "null"],
            "extend:type": "date",
            "description": "The date the signature was applied"
          },
          "is_signed": {
            "type": ["boolean", "null"],
            "description": "Indicates if the document is signed"
          },
          "title_or_role": {
            "type": ["string", "null"],
            "description": "The title or role of the signer"
          }
        },
        "required": ["printed_name", "signature_date", "is_signed", "title_or_role"]
      },
      "invoice_amount": {
        "type": "object",
        "extend:type": "currency",
        "description": "The amount of the invoice",
        "properties": {
          "amount": {
            "type": ["number", "null"],
            "description": "The numerical value of the amount"
          },
          "iso_4217_currency_code": {
            "type": ["string", "null"],
            "description": "The ISO 4217 currency code (e.g., USD, EUR)"
          }
        },
        "required": ["amount", "iso_4217_currency_code"]
      },
      "invoice_date": {
        "type": ["string", "null"],
        "extend:type": "date",
        "description": "The date of the invoice"
      }
    },
    "required": ["invoice_signature", "invoice_amount", "invoice_date"]
  }
}
```