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

# Structured Output

> Extract JSON from a document using a JSON Schema.

## Overview

Extracts data from a processed document and validates the result against a JSON Schema.

<ParamField path="id" type="string" required>
  Document ID.
</ParamField>

<ParamField body="prompt" type="string" required>
  Natural-language extraction instruction.
</ParamField>

<ParamField body="schema" type="object" required>
  JSON Schema for the desired output.
</ParamField>

<RequestExample>
  ```bash theme={null}
  curl -X POST https://api.okrapdf.com/v1/documents/doc-abc123/structured-output \
    -H "Authorization: Bearer $OKRA_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "prompt": "Extract invoice fields.",
      "schema": {
        "type": "object",
        "properties": {
          "vendor": { "type": "string" },
          "total": { "type": "number" }
        },
        "required": ["vendor", "total"]
      }
    }'
  ```
</RequestExample>
