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.retrieve.chunks.createGrouped();
console.log(response.chunks);curl https://api.morphik.ai/retrieve/chunks/grouped \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $MORPHIK_API_KEY" \
-d '{}'{
"chunks": [
{
"content": "<string>",
"score": 123,
"document_id": "<string>",
"chunk_number": 123,
"metadata": {},
"content_type": "<string>",
"filename": "<string>",
"download_url": "<string>",
"is_padding": false
}
],
"groups": [
{
"main_chunk": {
"content": "<string>",
"score": 123,
"document_id": "<string>",
"chunk_number": 123,
"metadata": {},
"content_type": "<string>",
"filename": "<string>",
"download_url": "<string>",
"is_padding": false
},
"total_chunks": 123,
"padding_chunks": [
{
"content": "<string>",
"score": 123,
"document_id": "<string>",
"chunk_number": 123,
"metadata": {},
"content_type": "<string>",
"filename": "<string>",
"download_url": "<string>",
"is_padding": false
}
]
}
],
"total_results": 123,
"has_padding": true
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Retrieve Chunks Grouped
Retrieve relevant chunks with grouped response format.
Uses the same filter operators as /retrieve/chunks (equality, $eq/$ne, $gt/$gte/$lt/$lte, $in/$nin,
$exists, $type, $regex, $contains, and the logical $and/$or/$nor/$not), with arbitrary nesting
supported inside request.filters.
Returns both flat results (for backward compatibility) and grouped results (for UI). When padding > 0, groups chunks by main matches and their padding chunks.
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.retrieve.chunks.createGrouped();
console.log(response.chunks);curl https://api.morphik.ai/retrieve/chunks/grouped \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $MORPHIK_API_KEY" \
-d '{}'{
"chunks": [
{
"content": "<string>",
"score": 123,
"document_id": "<string>",
"chunk_number": 123,
"metadata": {},
"content_type": "<string>",
"filename": "<string>",
"download_url": "<string>",
"is_padding": false
}
],
"groups": [
{
"main_chunk": {
"content": "<string>",
"score": 123,
"document_id": "<string>",
"chunk_number": 123,
"metadata": {},
"content_type": "<string>",
"filename": "<string>",
"download_url": "<string>",
"is_padding": false
},
"total_chunks": 123,
"padding_chunks": [
{
"content": "<string>",
"score": 123,
"document_id": "<string>",
"chunk_number": 123,
"metadata": {},
"content_type": "<string>",
"filename": "<string>",
"download_url": "<string>",
"is_padding": false
}
]
}
],
"total_results": 123,
"has_padding": true
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Headers
Body
Base retrieve request model
Natural-language query used to retrieve relevant chunks or documents.
1Base64-encoded image to use as query for Morphik multimodal retrieval. Requires use_colpali=True. Mutually exclusive with 'query'.
Metadata filters supporting logical operators ($and/$or/$not/$nor) and field predicates ($eq/$ne/$gt/$gte/$lt/$lte/$in/$nin/$exists/$type/$regex/$contains).
Maximum number of chunks or documents to return.
Minimum similarity score a result must meet before it is returned.
When provided, overrides the workspace reranking configuration for this request.
When provided, uses Morphik's finetuned ColPali style embeddings (recommended to be True for high quality retrieval).
How to return image chunks: base64 (default), url, or text (markdown format)
base64, url, text Number of additional chunks/pages to retrieve before and after matched chunks (ColPali only)
x >= 0Optional folder scope. Accepts a folder PATH (e.g., '/Company/Reports') or list of paths.
Folder scope depth. 0 or None = exact folder only, -1 = include all descendants, n > 0 = include descendants up to n levels deeper.
Optional end-user scope for the operation
Response
Successful Response
Response that includes both flat results and grouped results for UI
Flat list of all chunks (for backward compatibility)
Show child attributes
Show child attributes
Grouped chunks for UI display
Show child attributes
Show child attributes
Total number of unique chunks
Whether padding was applied to any results
Was this page helpful?

