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

const client = new Morphik({
  apiKey: 'My API Key',
});

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

console.log(response.combined_metadata);
{
  "structured_output": "<any>",
  "extracted_metadata": {},
  "text_output": "<string>",
  "ingestion_enqueued": false,
  "ingestion_document": {
    "external_id": "<string>",
    "content_type": "<string>",
    "filename": "<string>",
    "metadata": {},
    "storage_info": {},
    "storage_files": [
      {
        "bucket": "<string>",
        "key": "<string>",
        "version": 1,
        "filename": "<string>",
        "content_type": "<string>",
        "timestamp": "2023-11-07T05:31:56Z"
      }
    ],
    "system_metadata": {},
    "additional_metadata": {},
    "chunk_ids": [
      "<string>"
    ],
    "folder_name": "<string>",
    "end_user_id": "<string>",
    "app_id": "<string>"
  },
  "input_metadata": {},
  "combined_metadata": {},
  "ingestion_options": {}
}

Headers

authorization
string

Body

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

Response

Successful Response

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

structured_output
any

Raw structured output returned from Gemini (may be list/dict)

extracted_metadata
object | null

Structured output coerced to metadata when possible

text_output
string | null

Raw text returned from Gemini when no schema is provided

ingestion_enqueued
boolean
default:false

True when the document was queued for ingestion after extraction

ingestion_document
object | null

Queued document stub when ingestion_enqueued is true Represents a document stored in the database documents collection

input_metadata
object

Original metadata supplied alongside the request

combined_metadata
object

Metadata that would be used if ingestion is performed

ingestion_options
object

Normalized ingestion options applied to this request