> ## Documentation Index
> Fetch the complete documentation index at: https://docs.landing.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# JSON Response for Extraction

export const adePythonLibrary = 'ade-python';

export const dpt2mini = 'DPT-2 mini';

export const dpt2 = 'DPT-2';

export const dpt1 = 'DPT-1';

export const dpt = 'Document Pre-Trained Transformer';

export const companyName = 'LandingAI';

export const extract = 'ADE Extract';

export const parse = 'ADE Parse';

export const ade = 'Agentic Document Extraction';

When you extract structured data with the [{extract} API](https://docs.landing.ai/api-reference/tools/ade-extract), the extracted data and metadata are returned in a structured JSON format.

## Response Structure

The response contains the following top-level fields:

* [`extraction`](#extracted-data-extraction): The extracted key-value pairs as defined by your schema.
* [`extraction_metadata`](#extraction-metadata-extraction_metadata): Metadata showing which chunks were referenced for each extracted field.
* [`metadata`](#processing-metadata-metadata): Processing information including credit usage, duration, filename, job ID, version, schema validation errors, and warnings.

## Extracted Data (`extraction`)

The `extraction` field contains the structured data extracted from your document, formatted according to your JSON schema. The structure matches your input schema exactly.

For a simple schema:

```json theme={null}
{
  "type": "object",
  "properties": {
    "employee_name": {
      "type": "string",
      "description": "The employee's full name"
    },
    "employee_ssn": {
      "type": "string",
      "description": "The employee's Social Security Number"
    },
    "gross_pay": {
      "type": "number",
      "description": "The gross pay amount"
    }
  }
}
```

The `extraction` field returns:

```json theme={null}
{
  "employee_name": "MICHAEL D BRYAN",
  "employee_ssn": "555-50-1234",
  "gross_pay": 6000.00
}
```

## Extraction Metadata (`extraction_metadata`)

The `extraction_metadata` field has the same structure as your extraction schema, but each field contains a dictionary with `references` that lists the HTML element IDs where the data was found.

The `references` field can contain:

* **Chunk IDs**: UUID-format IDs (e.g., `72ba3cca-01e5-407b-9fc4-81f54f9f0c51`) that reference entire chunks like text blocks or figures
* **Table cell IDs**: Format `{page_number}-{base62_sequential_number}` (e.g., `0-u`) when extracted data comes from table cells
* **Other HTML element IDs**: Any ID attribute from HTML elements within the [`markdown` fields](./ade-markdown-response) from the parsed output

This metadata is useful for:

* Tracing which parts of the document contributed to each extracted field
* Debugging extraction issues
* Building confidence scores or validation logic
* Creating audit trails for extracted data

### Simple Schema Metadata

For a simple extraction schema, the metadata includes the value and references for each field.

When data is extracted from text chunks, references contain chunk IDs (UUIDs):

```json theme={null}
{
  "employee_name": {
    "value": "MICHAEL D BRYAN",
    "references": [
      "72ba3cca-01e5-407b-9fc4-81f54f9f0c51"
    ]
  },
  "employee_ssn": {
    "value": "555-50-1234",
    "references": [
      "a3f5d8c9-2b4e-4a1c-8f7e-9d6c5b4a3e2f"
    ]
  }
}
```

When data is extracted from table cells, references contain table cell IDs:

```json theme={null}
{
  "employee_name": {
    "value": "JANE HARPER",
    "references": [
      "75a62de4-5120-44bf-a6dd-b2aa63db18c6"
    ]
  },
  "gross_pay": {
    "value": 452.43,
    "references": [
      "0-u"
    ]
  }
}
```

In this example, `"0-u"` is a table cell ID where `0` indicates page 0 and `u` is the base62-encoded sequential number for that cell.

### Nested Schema Metadata

For nested extraction schemas, the metadata preserves the same nested structure:

```json theme={null}
{
  "patient_details": {
    "patient_name": {
      "value": "John Smith",
      "references": [
        "72ba3cca-01e5-407b-9fc4-81f54f9f0c51"
      ]
    },
    "date": {
      "value": "2024-01-15",
      "references": [
        "72ba3cca-01e5-407b-9fc4-81f54f9f0c51"
      ]
    }
  },
  "emergency_contact_information": {
    "emergency_contact_name": {
      "value": "Jane Smith",
      "references": [
        "5b8865b9-1a81-46df-bcf7-0bdbed9130dc"
      ]
    },
    "relationship_to_patient": {
      "value": "Spouse",
      "references": [
        "5b8865b9-1a81-46df-bcf7-0bdbed9130dc"
      ]
    }
  }
}
```

## Processing Metadata (`metadata`)

The `metadata` field provides information about the extraction process:

| Field                    | Type           | Description                                                                                                                                                                                                                               |
| ------------------------ | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `filename`               | string         | The name of the input file.                                                                                                                                                                                                               |
| `org_id`                 | string         | Organization identifier.                                                                                                                                                                                                                  |
| `duration_ms`            | number         | Processing time in milliseconds.                                                                                                                                                                                                          |
| `credit_usage`           | number         | Number of credits consumed.                                                                                                                                                                                                               |
| `job_id`                 | string         | Unique job identifier.                                                                                                                                                                                                                    |
| `version`                | string         | Model version used for extraction. For more information, go to [Extraction Model Versions](./ade-extract-models).                                                                                                                         |
| `fallback_model_version` | string \| null | The extract model that was actually used when the initial extraction attempt failed with the requested version. `null` if no fallback occurred.                                                                                           |
| `schema_violation_error` | string \| null | Error message if extracted data doesn't conform to the input schema. `null` if the schema is valid. For more information, go to [Troubleshoot Extraction](./ade-extract-troubleshoot).                                                    |
| `warnings`               | array          | Structured warning objects generated during extraction. Each warning has a `code` that identifies the warning type and a `msg` (human-readable description). For more information, go to [Warnings](./ade-extract-troubleshoot#warnings). |

## Example Response

Here is a complete example showing the extraction response structure:

```json theme={null}
{
  "extraction": {
    "account_holder_name": "SUSAN SAMPLE",
    "account_number": "02782-5094431",
    "closing_balance": 3664.79
  },
  "extraction_metadata": {
    "account_holder_name": {
      "references": [
        "55d1b275-b539-4af7-ac85-3396f62c216e"
      ],
      "value": "SUSAN SAMPLE"
    },
    "account_number": {
      "references": [
        "dd784487-910c-4cb7-8bb2-d4a7ef3d952b",
        "0-3"
      ],
      "value": "02782-5094431"
    },
    "closing_balance": {
      "references": [
        "0-e"
      ],
      "value": 3664.79
    }
  },
  "metadata": {
    "credit_usage": 0.8583999999999999,
    "duration_ms": 9893,
    "filename": "upload.md",
    "job_id": "1c08692d839c4c33bd85aebfafeab5e9",
    "org_id": "lgy5xucm9xnq",
    "version": "extract-20260314",
    "fallback_model_version": null,
    "schema_violation_error": null,
    "warnings": []
  }
}
```
