Skip to main content
POST
/
ingest
/
document
/
query
JavaScript
import Morphik from 'morphik';

const client = new Morphik({
  apiKey: process.env['MORPHIK_API_KEY'], // This is the default and can be omitted
});

const response = await client.ingest.documentQuery({
  file: fs.createReadStream('path/to/file'),
  prompt: 'prompt',
});

console.log(response.combined_metadata);
{
  "structured_output": "<unknown>",
  "extracted_metadata": {},
  "text_output": "<string>",
  "ingestion_enqueued": false,
  "ingestion_document": {
    "content_type": "<string>",
    "external_id": "<string>",
    "filename": "<string>",
    "metadata": {},
    "metadata_types": {},
    "storage_info": {},
    "system_metadata": {},
    "additional_metadata": {},
    "chunk_ids": [
      "<string>"
    ],
    "summary_storage_key": "<string>",
    "summary_version": 123,
    "summary_bucket": "<string>",
    "summary_updated_at": "<string>",
    "folder_name": "<string>",
    "end_user_id": "<string>",
    "app_id": "<string>",
    "folder_path": "<string>",
    "folder_id": "<string>"
  },
  "input_metadata": {},
  "combined_metadata": {},
  "ingestion_options": {
    "ingest": false,
    "use_colpali": false,
    "folder_name": "<string>",
    "end_user_id": "<string>",
    "metadata": {}
  }
}

Headers

authorization
string

Body

multipart/form-data
file
file
required
prompt
string
required
response_schema
string | null
ingestion_options
string
default:{}

Response

Successful Response

Response model for document query with optional ingestion follow-up.

structured_output
any | null

Raw structured output returned from Morphik On-the-Fly (may be list/dict)

extracted_metadata
Extracted Metadata · object

Structured output coerced to metadata when possible

text_output
string | null

Raw text returned from Morphik On-the-Fly when no schema is provided

ingestion_enqueued
boolean
default:false

True when the document was queued for ingestion after extraction

ingestion_document
Document · object

Queued document stub when ingestion_enqueued is true

input_metadata
Input Metadata · object

Original metadata supplied alongside the request

combined_metadata
Combined Metadata · object

Metadata that would be used if ingestion is performed

ingestion_options
IngestionOptions · object

Normalized ingestion options applied to this request