---
title: "Query Document"
method: POST
path: "/ingest/document/query"
tags: ["Ingestion"]
---

# Query Document

`POST /ingest/document/query`

## Request

- Base URL: `https://api.morphik.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.morphik.ai/ingest/document/query`
- Auth: none declared

Execute a one-off analysis for a document using Morphik On-the-Fly, optionally enforcing structured output and
scheduling a follow-up ingestion.

`ingestion_options` is a JSON string controlling post-analysis ingestion behaviour via keys such as `ingest`,
`metadata`, `use_colpali`, `folder_name`, and `end_user_id`. Additional keys are ignored. A
:class:`DocumentQueryResponse` describing the inline analysis and any queued ingestion is returned.

## Headers

- `authorization` string, nullable

## Request body `multipart/form-data`

- BodyQueryDocumentIngestDocumentQueryPost
  - `file` string, binary, required
  - `prompt` string, required
  - `response_schema` string, nullable
  - `ingestion_options` string

## Response `200`

Successful Response

- DocumentQueryResponse: Response model for document query with optional ingestion follow-up.
  - `structured_output` unknown
  - `extracted_metadata` object, nullable: Structured output coerced to metadata when possible
  - `text_output` string, nullable: Raw text returned from Morphik On-the-Fly when no schema is provided
  - `ingestion_enqueued` boolean: True when the document was queued for ingestion after extraction
  - `ingestion_document` Document: Represents a document stored in the database documents collection
    - `external_id` string
    - `content_type` string, required
    - `filename` string, nullable
    - `metadata` object
    - `metadata_types` object
    - `storage_info` object
    - `system_metadata` object
    - `additional_metadata` object
    - `chunk_ids` string[]
    - `summary_storage_key` string, nullable
    - `summary_version` integer, nullable
    - `summary_bucket` string, nullable
    - `summary_updated_at` string, nullable
    - `folder_name` string, nullable
    - `end_user_id` string, nullable
    - `app_id` string, nullable
    - `folder_path` string, nullable
    - `folder_id` string, nullable
  - `input_metadata` object: Original metadata supplied alongside the request
  - `combined_metadata` object: Metadata that would be used if ingestion is performed
  - `ingestion_options` IngestionOptions: Normalized options controlling post-analysis ingestion.
    - `ingest` boolean: Whether to enqueue ingestion after metadata extraction.
    - `use_colpali` boolean: Whether to use Morphik's ColPali-style embeddings during ingestion (recommended for quality).
    - `folder_name` string, nullable: Optional target folder path for the ingested document. Only a single folder is supported.
    - `end_user_id` string, nullable: Optional end-user scope for the operation.
    - `metadata` object: Metadata to merge into the ingested document when ingestion is triggered.

## Other responses

- `422`: Validation Error

## Changes

- **2026-01-22** `2d9291c3821d`: 2 info
  - `header` request parameter `authorization` list-of-types was widened by adding types `null`
  - for the `header` request parameter `authorization`, the type was generalized from `string` to no type
- **2025-12-18** `4b79c3821a17`: 1 warning, 10 info
  - removed the optional property `ingestion_document/anyOf[subschema #1: Document]/storage_files` from the response with the `200` status
  - added the optional property `ingestion_document/anyOf[subschema #1: Document]/folder_id` to the response with the `200` status
  - added the optional property `ingestion_document/anyOf[subschema #1: Document]/summary_bucket` to the response with the `200` status
  - added the optional property `ingestion_document/anyOf[subschema #1: Document]/summary_storage_key` to the response with the `200` status
  - …7 more
- **2025-12-06** `e185c542e939`: 1 warning, 2 info
  - removed the request property `schema`
  - added the new optional request property `response_schema`
  - added the optional property `ingestion_document/anyOf[subschema #1: Document]/folder_path` to the response with the `200` status
- **2025-11-13** `b9ae748cb938`: 1 info
  - added the optional property `ingestion_document/anyOf[subschema #1: Document]/metadata_types` to the response with the `200` status
- **2025-11-05** `9ade02dd7b1d`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/morphik-org/apis/morphik-api/changes/ingest/document/query/post.md)

---

[API](https://skmtc.dev/morphik-org/apis/morphik-api.md) - [All operations](https://skmtc.dev/morphik-org/apis/morphik-api/llms.txt) - [OpenAPI document](https://skmtc.dev/morphik-org/apis/morphik-api/revisions/45d77e08d406?raw)
