{
  "openapi": "3.1.0",
  "info": {
    "title": "Hanji",
    "summary": "Parse documents into structured data. Text, tables, and figures in one call.",
    "version": "0.1.0"
  },
  "paths": {
    "/health": {
      "get": {
        "summary": "Health",
        "operationId": "health_health_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "title": "Response Health Health Get"
                }
              }
            }
          }
        }
      }
    },
    "/v1/parse": {
      "post": {
        "tags": [
          "v1"
        ],
        "summary": "Parse a document by URL",
        "description": "Download the document at `url`, parse it, and return text, table, and image chunks in reading order. Every chunk carries its page number and bounding box. Billed per page.",
        "operationId": "extract_v1",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExtractRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExtractResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/v1/parse/file": {
      "post": {
        "tags": [
          "v1"
        ],
        "summary": "Parse an uploaded document",
        "description": "Accept a document as ``multipart/form-data`` and return chunks.\n\nMirrors ``POST /v1/parse`` in every way except how the document\narrives: same auth, same billing, same response schema, same error\nmapping. The filename is advisory; magic bytes drive kind detection.\n``POST /v1/extract/file`` is a compatibility alias.",
        "operationId": "extract_file_v1",
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/Body_extract_file_v1"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExtractResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/v1/extract/schema": {
      "post": {
        "tags": [
          "v1"
        ],
        "summary": "Fill a schema from a document by URL",
        "description": "Fill an arbitrary user JSON schema from a document URL, with citations.",
        "operationId": "extract_schema_v1",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SchemaExtractRequest"
              }
            }
          },
          "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": []
          }
        ]
      }
    },
    "/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": []
          }
        ]
      }
    },
    "/v1/files": {
      "post": {
        "tags": [
          "v1",
          "async-batch"
        ],
        "summary": "Register a file for batch upload",
        "description": "Reserve a file slot and get back a `file_id` plus a presigned S3 PUT URL. PUT the file bytes to that URL (they go directly to S3, never through this API), then reference the `file_id` in `POST /v1/batches`. Uploads expire after 3 days.",
        "operationId": "create_file_v1",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateFileRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateFileResponse"
                }
              }
            }
          },
          "413": {
            "description": "`size_bytes` exceeds the upload cap."
          },
          "503": {
            "description": "Async batch uploads are not configured for this deployment."
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/v1/files/{file_id}": {
      "get": {
        "tags": [
          "v1",
          "async-batch"
        ],
        "summary": "Check upload status",
        "description": "Fetch a file's metadata and upload `status`. Useful to confirm a presigned PUT landed before submitting a batch, though `POST /v1/batches` re-checks S3 on submit, so this call is optional.",
        "operationId": "get_file_v1",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "file_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "File Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FileResource"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/batches": {
      "post": {
        "tags": [
          "v1",
          "async-batch"
        ],
        "summary": "Create a batch",
        "description": "Submit uploaded files as one batch job. Returns immediately with `status: \"pending\"`; poll `GET /v1/batches/{batch_id}` for per-item progress. Pass an `Idempotency-Key` header to make retries safe: the same key within 3 days returns the same batch instead of creating a duplicate.",
        "operationId": "create_batch_v1",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Idempotency-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateBatchRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchResource"
                }
              }
            }
          },
          "402": {
            "description": "Quota exceeded."
          },
          "404": {
            "description": "One or more `file_id`s don't exist for this account (or their 3-day TTL lapsed).",
            "content": {
              "application/json": {
                "example": {
                  "error": "file_not_found",
                  "file_ids": [
                    "file_abc123"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "One or more files have no bytes in storage: the upload never completed or expired. A *finished* upload does not 409.",
            "content": {
              "application/json": {
                "example": {
                  "error": "file_not_uploaded",
                  "file_ids": [
                    "file_abc123"
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "v1",
          "async-batch"
        ],
        "summary": "List your batches",
        "description": "Your account's batches, newest first, with cursor pagination and an optional `status` filter.",
        "operationId": "list_batches_v1",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Status"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Cursor"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1,
              "default": 50,
              "title": "Limit"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchListResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/batches/{batch_id}": {
      "get": {
        "tags": [
          "v1",
          "async-batch"
        ],
        "summary": "Poll a batch",
        "description": "Batch status plus paginated per-item statuses, ordered by last update. Pass back `next_cursor` as `cursor` to fetch only the items that changed since your previous poll.",
        "operationId": "get_batch_v1",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "batch_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Batch Id"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Cursor"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 500,
              "minimum": 1,
              "default": 100,
              "title": "Limit"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchPollResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/batches/{batch_id}/items/{item_id}/result": {
      "get": {
        "tags": [
          "v1",
          "async-batch"
        ],
        "summary": "Download an item result",
        "description": "Redirects (`302`) to a presigned S3 GET for the item's result JSON, so follow redirects. Results expire 3 days after item completion.",
        "operationId": "get_batch_item_result_v1",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "batch_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Batch Id"
            }
          },
          {
            "name": "item_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Item Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "302": {
            "description": "Redirect (`Location`) to a presigned S3 GET for the result blob."
          },
          "404": {
            "description": "Batch or item not found for this account."
          },
          "409": {
            "description": "Item hasn't reached `succeeded` yet; keep polling `GET /v1/batches/{batch_id}`.",
            "content": {
              "application/json": {
                "example": {
                  "error": "result_not_ready",
                  "status": "running"
                }
              }
            }
          },
          "410": {
            "description": "Result is gone; the 3-day retention window has passed."
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/batches/{batch_id}/cancel": {
      "post": {
        "tags": [
          "v1",
          "async-batch"
        ],
        "summary": "Cancel a batch",
        "description": "Flip the batch's remaining `pending` items to `cancelled`. Items already `running` finish on their own. Cancelled items are not billed.",
        "operationId": "cancel_batch_v1",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "batch_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Batch Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchResource"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    }
  },
  "webhooks": {
    "batch.update": {
      "post": {
        "summary": "Batch Update Webhook",
        "description": "Sent to your registered endpoint (`webhook: {\"mode\": \"svix\"}`) or inline\n`url` (`\"mode\": \"direct\"`) when a batch reaches a terminal status. Signed\ndeliveries are Svix-wire-compatible \u2014 verify with the `svix` library. See\nthe [Webhooks guide](https://docs.hanji.dev/guides/webhooks).",
        "operationId": "batch_update_webhookbatch_update_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BatchUpdateEvent"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "BatchCounts": {
        "properties": {
          "pending": {
            "type": "integer",
            "title": "Pending",
            "default": 0
          },
          "running": {
            "type": "integer",
            "title": "Running",
            "default": 0
          },
          "succeeded": {
            "type": "integer",
            "title": "Succeeded",
            "default": 0
          },
          "failed": {
            "type": "integer",
            "title": "Failed",
            "default": 0
          },
          "cancelled": {
            "type": "integer",
            "title": "Cancelled",
            "default": 0
          }
        },
        "type": "object",
        "title": "BatchCounts"
      },
      "BatchItemResource": {
        "properties": {
          "object": {
            "type": "string",
            "title": "Object",
            "default": "batch_item"
          },
          "id": {
            "type": "string",
            "title": "Id"
          },
          "batch_id": {
            "type": "string",
            "title": "Batch Id"
          },
          "file_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "File Id"
          },
          "url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Url",
            "description": "For URL-sourced items only (null for uploaded files). Query string stripped so a presigned signature never appears in the response. items[].error.message gets the same treatment for url_fetch_failed items."
          },
          "position": {
            "type": "integer",
            "title": "Position"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "page_count": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Page Count"
          },
          "attempts": {
            "type": "integer",
            "title": "Attempts"
          },
          "started_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Started At"
          },
          "completed_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Completed At"
          },
          "updated_at": {
            "type": "string",
            "title": "Updated At"
          },
          "result_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Result Url"
          },
          "error": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Error"
          }
        },
        "type": "object",
        "required": [
          "id",
          "batch_id",
          "position",
          "status",
          "attempts",
          "updated_at"
        ],
        "title": "BatchItemResource"
      },
      "BatchListResponse": {
        "properties": {
          "object": {
            "type": "string",
            "title": "Object",
            "default": "list"
          },
          "data": {
            "items": {
              "$ref": "#/components/schemas/BatchResource"
            },
            "type": "array",
            "title": "Data"
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Next Cursor"
          }
        },
        "type": "object",
        "required": [
          "data"
        ],
        "title": "BatchListResponse"
      },
      "BatchPollResponse": {
        "properties": {
          "object": {
            "type": "string",
            "title": "Object",
            "default": "batch"
          },
          "id": {
            "type": "string",
            "title": "Id"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "counts": {
            "$ref": "#/components/schemas/BatchCounts"
          },
          "total_items": {
            "type": "integer",
            "title": "Total Items"
          },
          "engine": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Engine"
          },
          "options": {
            "additionalProperties": true,
            "type": "object",
            "title": "Options"
          },
          "metadata": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Metadata"
          },
          "created_at": {
            "type": "string",
            "title": "Created At"
          },
          "started_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Started At"
          },
          "completed_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Completed At"
          },
          "expires_at": {
            "type": "string",
            "title": "Expires At"
          },
          "items": {
            "items": {
              "$ref": "#/components/schemas/BatchItemResource"
            },
            "type": "array",
            "title": "Items"
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Next Cursor"
          }
        },
        "type": "object",
        "required": [
          "id",
          "status",
          "counts",
          "total_items",
          "engine",
          "options",
          "created_at",
          "expires_at",
          "items"
        ],
        "title": "BatchPollResponse"
      },
      "BatchResource": {
        "properties": {
          "object": {
            "type": "string",
            "title": "Object",
            "default": "batch"
          },
          "id": {
            "type": "string",
            "title": "Id"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "counts": {
            "$ref": "#/components/schemas/BatchCounts"
          },
          "total_items": {
            "type": "integer",
            "title": "Total Items"
          },
          "engine": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Engine"
          },
          "options": {
            "additionalProperties": true,
            "type": "object",
            "title": "Options"
          },
          "metadata": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Metadata"
          },
          "created_at": {
            "type": "string",
            "title": "Created At"
          },
          "started_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Started At"
          },
          "completed_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Completed At"
          },
          "expires_at": {
            "type": "string",
            "title": "Expires At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "status",
          "counts",
          "total_items",
          "engine",
          "options",
          "created_at",
          "expires_at"
        ],
        "title": "BatchResource"
      },
      "BatchUpdateEvent": {
        "properties": {
          "type": {
            "type": "string",
            "const": "batch.update",
            "title": "Type",
            "description": "Event type. Only `batch.update` exists today.",
            "default": "batch.update"
          },
          "batch_id": {
            "type": "string",
            "title": "Batch Id",
            "description": "The batch that reached a terminal status."
          },
          "status": {
            "type": "string",
            "enum": [
              "completed",
              "partially_failed",
              "failed",
              "cancelled"
            ],
            "title": "Status",
            "description": "Terminal batch status. Treat `completed` AND `partially_failed` as 'results are ready' \u2014 `partially_failed` means some items succeeded and some failed (check `counts`), not a total failure."
          },
          "counts": {
            "$ref": "#/components/schemas/BatchCounts",
            "description": "Per-item-status counts at completion."
          },
          "total_items": {
            "type": "integer",
            "title": "Total Items",
            "description": "Number of items in the batch."
          },
          "metadata": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Metadata",
            "description": "The `metadata` you passed on `POST /v1/batches`, echoed verbatim."
          },
          "completed_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Completed At",
            "description": "ISO-8601 UTC timestamp when the batch reached its terminal status."
          },
          "results_expires_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Results Expires At",
            "description": "ISO-8601 UTC timestamp after which this batch's results are deleted (3-day default retention). Fetch results before then; a resend after this point is refused."
          }
        },
        "type": "object",
        "required": [
          "batch_id",
          "status",
          "counts",
          "total_items"
        ],
        "title": "BatchUpdateEvent",
        "description": "The webhook body delivered when a batch reaches a terminal status\n(plan 083). Documentation-only model \u2014 registered on ``app.webhooks`` so it\nrenders in the API reference; nothing calls this as an endpoint. The live\nserializer is ``extract.core.webhooks.build_batch_update_body``."
      },
      "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).\n\nPresent only on responses whose request was actually charged \u2014 absent\n(never null) on unbilled lanes (demo, legacy-PHI ledger) so pre-credits\nresponse shapes stay byte-identical. ``credits = pages \u00d7 credits_per_page``\nat the v1 card: parse 1.0, schema extract 4.0 all-in."
      },
      "Body_extract_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."
          },
          "extract_text": {
            "type": "boolean",
            "title": "Extract Text",
            "description": "Include text chunks in the response. Set false to skip text spans; table chunks (and figures, when extract_images is true) are still returned.",
            "default": true
          },
          "extract_images": {
            "type": "boolean",
            "title": "Extract Images",
            "description": "Include figure (image) chunks in the response. Set false to skip figure extraction; text and table chunks are still returned.",
            "default": true
          },
          "ocr": {
            "type": "string",
            "enum": [
              "auto",
              "never",
              "force"
            ],
            "title": "Ocr",
            "description": "Deprecated. Accepted for backward compatibility but currently has no effect.",
            "default": "auto"
          },
          "table_output_format": {
            "type": "string",
            "enum": [
              "markdown",
              "cell_grid",
              "html"
            ],
            "title": "Table Output Format",
            "description": "How table chunks are structured. 'markdown' (default) keeps the existing markdown-derived cells; 'html' renders those same cells as an HTML table in page_content, with row 0 emitted as the header row exactly as it is (an empty header stays empty, never promoted from the first body row); 'cell_grid' returns true per-cell bounding boxes on table chunks (cells become the primary representation; page_content remains a markdown render).",
            "default": "markdown"
          },
          "chunking": {
            "type": "string",
            "enum": [
              "none",
              "semantic"
            ],
            "title": "Chunking",
            "description": "'none' (default): response unchanged. 'semantic': additionally return `segments` \u2014 elements grouped toward chunk_size characters at semantic/structural boundaries (headings, gaps, page breaks), each segment carrying embed-ready markdown content plus member records with page numbers and bounding boxes.",
            "default": "none"
          },
          "chunk_size": {
            "type": "integer",
            "title": "Chunk Size",
            "description": "Target segment size in characters of segment content. Segments land in a +/-25% band around this target (default 750-1250). Only meaningful when chunking is enabled; validated (200-8000) only in that case and ignored otherwise.",
            "default": 1000
          },
          "include_content": {
            "type": "boolean",
            "title": "Include Content",
            "description": "false (default): response unchanged. true: additionally return `content` \u2014 the entire parsed document as a single text string, concatenated in reading order (not reformatted as structured markdown).",
            "default": false
          }
        },
        "type": "object",
        "required": [
          "file"
        ],
        "title": "Body_extract_file_v1"
      },
      "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` \u2014 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"
      },
      "CreateBatchRequest": {
        "properties": {
          "source": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/FilesSource"
              },
              {
                "$ref": "#/components/schemas/UrlSource"
              }
            ],
            "title": "Source",
            "description": "The documents to process: {\"type\": \"files\", \"file_ids\": [...]} for previously-uploaded files, or {\"type\": \"urls\", \"urls\": [...]} to have us fetch each URL directly (no upload step; source bytes never written to our storage).",
            "discriminator": {
              "propertyName": "type",
              "mapping": {
                "files": "#/components/schemas/FilesSource",
                "urls": "#/components/schemas/UrlSource"
              }
            }
          },
          "engine": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 64
              },
              {
                "type": "null"
              }
            ],
            "title": "Engine",
            "description": "Reserved for future engine selection. Leave unset; only the default engine is accepted today."
          },
          "extract_text": {
            "type": "boolean",
            "title": "Extract Text",
            "description": "Include text chunks in each item's result. Set false to skip text spans in every item.",
            "default": true
          },
          "extract_images": {
            "type": "boolean",
            "title": "Extract Images",
            "description": "Include figure (image) chunks in each item's result. Set false to skip figure extraction in every item.",
            "default": true
          },
          "ocr": {
            "type": "string",
            "enum": [
              "auto",
              "never",
              "force"
            ],
            "title": "Ocr",
            "description": "Deprecated. Accepted for backward compatibility but currently has no effect.",
            "default": "auto"
          },
          "table_output_format": {
            "type": "string",
            "enum": [
              "markdown",
              "cell_grid",
              "html"
            ],
            "title": "Table Output Format",
            "description": "How table chunks are structured in each item's result. 'markdown' (default) keeps the existing markdown-derived cells; 'cell_grid' returns true per-cell bounding boxes on table chunks.",
            "default": "markdown"
          },
          "chunking": {
            "type": "string",
            "enum": [
              "none",
              "semantic"
            ],
            "title": "Chunking",
            "description": "'none' (default): item results unchanged. 'semantic': each item's result additionally carries `segments` \u2014 elements grouped toward chunk_size characters at semantic/structural boundaries.",
            "default": "none"
          },
          "chunk_size": {
            "type": "integer",
            "title": "Chunk Size",
            "description": "Target segment size in characters. Segments land in a +/-25% band around this target. Only meaningful when chunking is enabled; validated (200-8000) only in that case and ignored otherwise.",
            "default": 1000
          },
          "metadata": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Metadata",
            "description": "Arbitrary JSON stored with the batch and echoed back on every poll, in the batch list, and in webhook event bodies. Put your own run ids, tenant ids, or job references here. It never affects processing. Maximum 16 KB serialized."
          },
          "webhook": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/WebhookConfig"
              },
              {
                "type": "null"
              }
            ],
            "description": "Optional completion webhook for this batch. Omitted means no webhook fires. `{\"mode\": \"svix\"}` delivers a signed `batch.update` event to your registered endpoints when the batch reaches a terminal status; `{\"mode\": \"direct\", \"url\": ...}` sends an unsigned event to the given HTTPS URL (prototyping)."
          }
        },
        "type": "object",
        "required": [
          "source"
        ],
        "title": "CreateBatchRequest"
      },
      "CreateFileRequest": {
        "properties": {
          "filename": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 512
              },
              {
                "type": "null"
              }
            ],
            "title": "Filename"
          },
          "content_type": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 128
              },
              {
                "type": "null"
              }
            ],
            "title": "Content Type"
          },
          "size_bytes": {
            "type": "integer",
            "exclusiveMinimum": 0.0,
            "title": "Size Bytes"
          }
        },
        "type": "object",
        "required": [
          "size_bytes"
        ],
        "title": "CreateFileRequest"
      },
      "CreateFileResponse": {
        "properties": {
          "object": {
            "type": "string",
            "title": "Object",
            "default": "file"
          },
          "id": {
            "type": "string",
            "title": "Id"
          },
          "customer_id": {
            "type": "string",
            "title": "Customer Id"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "filename": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Filename"
          },
          "content_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Content Type"
          },
          "size_bytes": {
            "type": "integer",
            "title": "Size Bytes"
          },
          "sha256": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sha256"
          },
          "created_at": {
            "type": "string",
            "title": "Created At"
          },
          "expires_at": {
            "type": "string",
            "title": "Expires At"
          },
          "upload": {
            "$ref": "#/components/schemas/UploadDescriptor"
          }
        },
        "type": "object",
        "required": [
          "id",
          "customer_id",
          "status",
          "size_bytes",
          "created_at",
          "expires_at",
          "upload"
        ],
        "title": "CreateFileResponse"
      },
      "ExtractRequest": {
        "properties": {
          "url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Url",
            "description": "HTTP(S) URL of the document to parse (URL route only). Input type is detected from the file itself; the extension is a hint."
          },
          "extract_text": {
            "type": "boolean",
            "title": "Extract Text",
            "description": "Include text chunks in the response. Set false to skip text spans; table chunks (and figures, when extract_images is true) are still returned.",
            "default": true
          },
          "extract_images": {
            "type": "boolean",
            "title": "Extract Images",
            "description": "Include figure (image) chunks in the response. Set false to skip figure extraction; text and table chunks are still returned.",
            "default": true
          },
          "ocr": {
            "type": "string",
            "enum": [
              "auto",
              "never",
              "force"
            ],
            "title": "Ocr",
            "description": "Deprecated. Accepted for backward compatibility but currently has no effect.",
            "default": "auto"
          },
          "table_output_format": {
            "type": "string",
            "enum": [
              "markdown",
              "cell_grid",
              "html"
            ],
            "title": "Table Output Format",
            "description": "How table chunks are structured. 'html' puts an HTML table in page_content; 'cell_grid' returns true per-cell bounding boxes. Echoed on each table chunk (falls back to 'markdown' if localization fails).",
            "default": "markdown"
          },
          "chunking": {
            "type": "string",
            "enum": [
              "none",
              "semantic"
            ],
            "title": "Chunking",
            "description": "'none' (default): response unchanged. 'semantic': additionally return `segments` \u2014 elements grouped toward chunk_size characters at semantic/structural boundaries (headings, gaps, page breaks), each segment carrying embed-ready markdown content plus member records with page numbers and bounding boxes.",
            "default": "none"
          },
          "chunk_size": {
            "type": "integer",
            "title": "Chunk Size",
            "description": "Target segment size in characters of segment content. Segments land in a +/-25% band around this target (default 750-1250). Only meaningful when chunking is enabled; validated (200-8000) only in that case and ignored otherwise.",
            "default": 1000
          },
          "include_content": {
            "type": "boolean",
            "title": "Include Content",
            "description": "false (default): response unchanged. true: additionally return `content` \u2014 the entire parsed document as a single text string, concatenated in reading order. Not reformatted as structured markdown; it is the document's own text content end to end.",
            "default": false
          }
        },
        "type": "object",
        "title": "ExtractRequest",
        "description": "Input to a parse request.\n\nServer-side limits (page count, file size) are not user-configurable.\nUnknown fields are accepted and ignored for backward compatibility.\nThe ``ocr`` knob is deprecated and currently has no effect."
      },
      "ExtractResponse": {},
      "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."
      },
      "FileResource": {
        "properties": {
          "object": {
            "type": "string",
            "title": "Object",
            "default": "file"
          },
          "id": {
            "type": "string",
            "title": "Id"
          },
          "customer_id": {
            "type": "string",
            "title": "Customer Id"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "filename": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Filename"
          },
          "content_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Content Type"
          },
          "size_bytes": {
            "type": "integer",
            "title": "Size Bytes"
          },
          "sha256": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sha256"
          },
          "created_at": {
            "type": "string",
            "title": "Created At"
          },
          "expires_at": {
            "type": "string",
            "title": "Expires At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "customer_id",
          "status",
          "size_bytes",
          "created_at",
          "expires_at"
        ],
        "title": "FileResource"
      },
      "FilesSource": {
        "properties": {
          "type": {
            "type": "string",
            "const": "files",
            "title": "Type",
            "default": "files"
          },
          "file_ids": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "maxItems": 10000,
            "minItems": 1,
            "title": "File Ids",
            "description": "Uploaded file ids (from POST /v1/files) to process, 1-10,000 per batch."
          }
        },
        "type": "object",
        "required": [
          "file_ids"
        ],
        "title": "FilesSource"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "SchemaExtractRequest": {
        "properties": {
          "url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Url",
            "description": "HTTP(S) URL of the document to extract from. PHI-enabled keys must use the file-upload route instead."
          },
          "schema": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Schema",
            "description": "JSON Schema describing the fields to extract; field descriptions are instructions the extractor follows. Required unless auto_schema is 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
          },
          "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
          },
          "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
          },
          "include_ocr_text": {
            "type": "boolean",
            "title": "Include Ocr Text",
            "description": "false (default): response unchanged. true: additionally return `ocr_text` \u2014 the whole parsed document as a single text string, concatenated in reading order (the same text POST /v1/parse returns as `content`).",
            "default": false
          }
        },
        "type": "object",
        "title": "SchemaExtractRequest",
        "description": "Input to a schema-extraction request.\n\nGiven a document and an arbitrary user JSON schema, fill the schema's\nfields from the document and cite where each value came from."
      },
      "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"
      },
      "UploadDescriptor": {
        "properties": {
          "method": {
            "type": "string",
            "title": "Method"
          },
          "url": {
            "type": "string",
            "title": "Url"
          },
          "expires_at": {
            "type": "string",
            "title": "Expires At"
          }
        },
        "type": "object",
        "required": [
          "method",
          "url",
          "expires_at"
        ],
        "title": "UploadDescriptor"
      },
      "UrlSource": {
        "properties": {
          "type": {
            "type": "string",
            "const": "urls",
            "title": "Type",
            "default": "urls"
          },
          "urls": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "maxItems": 100,
            "minItems": 1,
            "title": "Urls",
            "description": "Public or presigned HTTP(S) URLs to fetch and process, 1-100 per batch. Each URL becomes one item; we fetch it when that item starts processing, not when you submit the batch \u2014 a slow or large download doesn't block this request."
          }
        },
        "type": "object",
        "required": [
          "urls"
        ],
        "title": "UrlSource",
        "description": "Public or presigned URLs \u2014 no upload step. Source bytes are never\nwritten to our storage; only the extraction result is. Presigned URLs\nwork the same as public ones \u2014 pass the full URL through unmodified,\nincluding its signature query string."
      },
      "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"
      },
      "WebhookConfig": {
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "svix",
              "registered",
              "direct",
              "disabled"
            ],
            "title": "Mode",
            "description": "\"svix\": signed delivery to your registered endpoints. \"direct\": unsigned delivery to `url` (prototyping). \"disabled\": suppress for this batch (same as omitting `webhook`)."
          },
          "url": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 2048
              },
              {
                "type": "null"
              }
            ],
            "title": "Url",
            "description": "Destination URL. Required (HTTPS, public hostname) iff mode is \"direct\"."
          }
        },
        "type": "object",
        "required": [
          "mode"
        ],
        "title": "WebhookConfig",
        "description": "Per-batch webhook opt-in (plan 083 \u00a73.3). Shaped like Reducto's\n`async.webhook` so a ported request body maps directly. `registered` is\nan accepted alias of `svix`; only `svix` is documented."
      }
    },
    "securitySchemes": {
      "APIKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-KEY"
      }
    }
  },
  "security": [
    {
      "APIKeyHeader": []
    }
  ],
  "servers": [
    {
      "url": "https://api.hanji.dev",
      "description": "production"
    }
  ]
}