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

# Fill a schema from an uploaded document

> Schema extraction from a ``multipart/form-data`` upload (PHI-capable).



## OpenAPI

````yaml /openapi.json post /v1/extract/schema/file
openapi: 3.1.0
info:
  title: Hanji
  summary: Parse documents into structured data. Text, tables, and figures in one call.
  version: 0.1.0
servers:
  - url: https://api.hanji.dev
    description: production
security:
  - APIKeyHeader: []
paths:
  /v1/extract/schema/file:
    post:
      tags:
        - v1
      summary: Fill a schema from an uploaded document
      description: Schema extraction from a ``multipart/form-data`` upload (PHI-capable).
      operationId: extract_schema_file_v1
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/Body_extract_schema_file_v1'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SchemaExtractResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    Body_extract_schema_file_v1:
      properties:
        file:
          type: string
          contentMediaType: application/octet-stream
          title: File
          description: >-
            PDF, PPTX, DOCX, or image (PNG, JPEG, WebP, TIFF, HEIC/HEIF, BMP)
            document.
        schema:
          anyOf:
            - type: string
            - type: 'null'
          title: Schema
          description: User JSON schema as a JSON string; omit when auto_schema=true.
        strict:
          type: boolean
          title: Strict
          description: >-
            What happens to a value whose citation cannot be verified against
            the document. true (default): the value is nulled out and its path
            listed in ungrounded_fields, so a fabricated value never reaches
            you. false: the value is kept but still flagged in
            ungrounded_fields.
          default: true
        extract_images:
          type: boolean
          title: Extract Images
          description: >-
            Include figures from the parse stage in the extraction context. Set
            false to extract from text and tables only.
          default: true
        auto_schema:
          type: boolean
          title: Auto Schema
          description: >-
            Set true (and omit schema) to have a schema designed from the
            document first, then filled with the same grounded extraction. The
            schema used is returned in generated_schema.
          default: false
        include_ocr_text:
          type: boolean
          title: Include Ocr Text
          description: >-
            false (default): response unchanged. true: additionally return
            `ocr_text` — the whole parsed document as a single text string in
            reading order, the same text POST /v1/parse returns as `content`.
          default: false
      type: object
      required:
        - file
      title: Body_extract_schema_file_v1
    SchemaExtractResponse:
      properties:
        values:
          additionalProperties: true
          type: object
          title: Values
        evidence:
          additionalProperties:
            items:
              $ref: '#/components/schemas/FieldEvidence'
            type: array
          type: object
          title: Evidence
        ungrounded_fields:
          items:
            type: string
          type: array
          title: Ungrounded Fields
        page_count:
          type: integer
          title: Page Count
        generated_schema:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Generated Schema
        usage:
          anyOf:
            - $ref: '#/components/schemas/BillingUsage'
            - type: 'null'
        ocr_text:
          anyOf:
            - type: string
            - type: 'null'
          title: Ocr Text
      type: object
      required:
        - values
        - evidence
        - page_count
      title: SchemaExtractResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    FieldEvidence:
      properties:
        page:
          type: integer
          title: Page
        bbox:
          anyOf:
            - items:
                type: number
              type: array
            - type: 'null'
          title: Bbox
        text:
          type: string
          title: Text
        confidence:
          anyOf:
            - type: number
            - type: 'null'
          title: Confidence
        needs_review:
          type: boolean
          title: Needs Review
          default: false
        suggested_value:
          anyOf:
            - type: string
            - type: 'null'
          title: Suggested Value
      type: object
      required:
        - page
        - text
      title: FieldEvidence
      description: One grounding citation for an extracted value.
    BillingUsage:
      properties:
        pages:
          type: integer
          title: Pages
        credits:
          type: number
          title: Credits
        credits_per_page:
          type: number
          title: Credits Per Page
      type: object
      required:
        - pages
        - credits
        - credits_per_page
      title: BillingUsage
      description: >-
        What this request charged, in credits (plan 078 D6).


        Present only on responses whose request was actually charged — absent

        (never null) on unbilled lanes (demo, legacy-PHI ledger) so pre-credits

        response shapes stay byte-identical. ``credits = pages ×
        credits_per_page``

        at the v1 card: parse 1.0, schema extract 4.0 all-in.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-KEY

````