Skip to main content

Get Document Context

Get the full context of a document in a single request -- including document metadata, all chunks, and the concatenated full text. This is useful for building RAG prompts or pre-loading an entire document into an AI context window.

GET /api/v1/chunks/:document_id/context

Authentication

Requires an API key with the read permission.

HeaderValue
X-API-Keyink_live_abc123...

Path Parameters

ParameterTypeRequiredDescription
document_idstringYesThe unique identifier (UUID) of the document

Code Examples

curl https://api.inherent.systems/api/v1/chunks/a1b2c3d4-e5f6-7890-abcd-ef1234567890/context \
-H "X-API-Key: $INHERENT_API_KEY"

Response

Status: 200 OK

{
"document": {
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"name": "API Authentication Guide.md",
"workspace_id": "ws_abc123",
"source_type": "upload",
"mime_type": "text/markdown",
"size_bytes": 32768,
"chunk_count": 3,
"status": "completed",
"created_at": "2026-03-15T10:30:00Z",
"updated_at": "2026-03-15T10:31:45Z",
"metadata": {
"category": "documentation"
}
},
"chunks": [
{
"id": "c1d2e3f4-0001-4000-8000-000000000001",
"document_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"content": "# API Authentication\n\nAll API requests require authentication using a Bearer token or X-API-Key header.",
"chunk_index": 0,
"token_count": 128,
"metadata": {
"heading": "API Authentication"
}
},
{
"id": "c1d2e3f4-0001-4000-8000-000000000002",
"document_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"content": "## Creating an API Key\n\nTo create an API key, navigate to Settings > API Keys in the dashboard.",
"chunk_index": 1,
"token_count": 135,
"metadata": {
"heading": "Creating an API Key"
}
},
{
"id": "c1d2e3f4-0001-4000-8000-000000000003",
"document_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"content": "## Permissions\n\nEach API key can be scoped with permissions: read, write, and search.",
"chunk_index": 2,
"token_count": 98,
"metadata": {
"heading": "Permissions"
}
}
],
"full_text": "# API Authentication\n\nAll API requests require authentication using a Bearer token or X-API-Key header.\n\n## Creating an API Key\n\nTo create an API key, navigate to Settings > API Keys in the dashboard.\n\n## Permissions\n\nEach API key can be scoped with permissions: read, write, and search."
}

Response Fields

FieldTypeDescription
documentobjectDocument metadata
document.idstringUnique document identifier (UUID)
document.namestringOriginal filename
document.workspace_idstringID of the workspace
document.source_typestringHow the document was ingested (e.g., "upload")
document.mime_typestringMIME type of the document
document.size_bytesintegerFile size in bytes
document.chunk_countintegerTotal number of chunks
document.statusstringProcessing status
document.created_atstringISO 8601 upload timestamp
document.updated_atstringISO 8601 last-updated timestamp
document.metadataobject | nullUser-provided metadata
chunksarrayAll chunks in the document, ordered by chunk_index
chunks[].idstringUnique chunk identifier (UUID)
chunks[].document_idstringParent document ID
chunks[].contentstringText content of the chunk
chunks[].chunk_indexintegerZero-based position within the document
chunks[].token_countintegerNumber of tokens in the chunk
chunks[].metadataobject | nullChunk-level metadata
full_textstringAll chunk content concatenated in order, representing the full document text

Errors

StatusError TypeDescription
401unauthorizedMissing or invalid API key
403forbiddenAPI key does not have read permission
404not-foundNo document with the given ID exists in this workspace
429rate-limit-exceededRate limit exceeded

Example Error Response

{
"type": "https://api.inherent.systems/errors/not-found",
"title": "Not Found",
"status": 404,
"detail": "Document 'a1b2c3d4-e5f6-7890-abcd-ef1234567890' not found in this workspace.",
"instance": "/api/v1/chunks/a1b2c3d4-e5f6-7890-abcd-ef1234567890/context",
"trace_id": "01234567-89ab-cdef-0123-456789abcdef",
"timestamp": "2026-04-03T12:34:56.789Z"
}