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.
| Header | Value |
|---|---|
X-API-Key | ink_live_abc123... |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
document_id | string | Yes | The unique identifier (UUID) of the document |
Code Examples
- cURL
- Python
- JavaScript
curl https://api.inherent.systems/api/v1/chunks/a1b2c3d4-e5f6-7890-abcd-ef1234567890/context \
-H "X-API-Key: $INHERENT_API_KEY"
import requests
document_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
response = requests.get(
f"https://api.inherent.systems/api/v1/chunks/{document_id}/context",
headers={"X-API-Key": "ink_live_abc123..."},
)
context = response.json()
print(f"Document: {context['document']['name']}")
print(f"Chunks: {len(context['chunks'])}")
print(f"Full text length: {len(context['full_text'])} characters")
# Use full_text directly as context for an LLM
prompt = f"Based on the following document:\n\n{context['full_text']}\n\nAnswer: ..."
const documentId = "a1b2c3d4-e5f6-7890-abcd-ef1234567890";
const response = await fetch(
`https://api.inherent.systems/api/v1/chunks/${documentId}/context`,
{
headers: {
"X-API-Key": "ink_live_abc123...",
},
}
);
const context = await response.json();
console.log(`Document: ${context.document.name}`);
console.log(`Chunks: ${context.chunks.length}`);
console.log(`Full text: ${context.full_text.length} characters`);
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
| Field | Type | Description |
|---|---|---|
document | object | Document metadata |
document.id | string | Unique document identifier (UUID) |
document.name | string | Original filename |
document.workspace_id | string | ID of the workspace |
document.source_type | string | How the document was ingested (e.g., "upload") |
document.mime_type | string | MIME type of the document |
document.size_bytes | integer | File size in bytes |
document.chunk_count | integer | Total number of chunks |
document.status | string | Processing status |
document.created_at | string | ISO 8601 upload timestamp |
document.updated_at | string | ISO 8601 last-updated timestamp |
document.metadata | object | null | User-provided metadata |
chunks | array | All chunks in the document, ordered by chunk_index |
chunks[].id | string | Unique chunk identifier (UUID) |
chunks[].document_id | string | Parent document ID |
chunks[].content | string | Text content of the chunk |
chunks[].chunk_index | integer | Zero-based position within the document |
chunks[].token_count | integer | Number of tokens in the chunk |
chunks[].metadata | object | null | Chunk-level metadata |
full_text | string | All chunk content concatenated in order, representing the full document text |
Errors
| Status | Error Type | Description |
|---|---|---|
401 | unauthorized | Missing or invalid API key |
403 | forbidden | API key does not have read permission |
404 | not-found | No document with the given ID exists in this workspace |
429 | rate-limit-exceeded | Rate 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"
}