Documents¶
List, read, change and delete the documents of a project, and look at their chunks. To add documents, see Adding documents.
Paths are relative to /api/v1. GET endpoints need a read key, and the
others a write key. The examples use BASE=http://localhost:8000/api/v1
and an API key in $KEY.
The document object¶
| Field | Type | |
|---|---|---|
document_id |
integer | |
project_id |
integer | |
file_name |
string | |
file_extension |
string or null | Such as .pdf |
mime_type |
string or null | |
file_size |
integer | Bytes |
file_hash |
string | SHA-256 of the content. The same hash in a project is a duplicate |
loader |
string or null | The loader that read it, such as PDF, DOCX, HTML or DOCLING |
status |
string | pending (stored, not processed), processing, indexed or failed |
error |
string or null | Why it failed |
content_type |
string or null | The kind of text extracted, which auto chunking uses: text, markdown, code, table, json, slides or transcript |
page_unit |
string or null | What its page numbers count: page, slide, sheet, table, chapter, message, cell or frame |
document_metadata |
object or null | Metadata read from the file: title, author, page count, ... |
metadata |
object | Your metadata |
source |
string | upload, text, url or s3 |
source_uri |
string or null | The URL (after redirects) or s3://bucket/key it was read from |
source_info |
object or null | ETag, Last-Modified, content type, fetch time, ... |
external_id |
string or null | The key its versions share: your id, else the file name, URL or s3:// URI |
version |
integer | 1 for the first version |
chunk_count |
integer | |
job_id |
integer or null | The background job that last processed it. null: it was processed by a request |
chunking |
object or null | The chunking options used, with resolved_strategy (what auto picked) |
stale |
boolean or null | true: indexed into another collection than the one in use now (the vector DB or model changed), so search does not find it until it is reindexed. null: not indexed, or unknown |
access |
object or null | {public, users, groups}; see Document access. null for callers that are themselves restricted to a user or groups |
created_at, updated_at |
datetime | |
sections |
list or null | Only with with_sections=true: the extracted text, section by section, with each section's page, title or times |
{
"document_id": 31,
"project_id": 1,
"file_name": "handbook.pdf",
"file_extension": ".pdf",
"mime_type": "application/pdf",
"file_size": 482113,
"file_hash": "9f2c...e1",
"loader": "PDF",
"status": "indexed",
"error": null,
"content_type": "text",
"page_unit": "page",
"document_metadata": {"title": "Staff handbook", "pages": 48},
"metadata": {"team": "hr", "year": 2026},
"source": "upload",
"source_uri": null,
"source_info": null,
"external_id": "handbook.pdf",
"version": 2,
"chunk_count": 84,
"job_id": null,
"chunking": {"strategy": "auto", "resolved_strategy": "recursive", "chunk_size": 1000, "chunk_overlap": 200},
"stale": false,
"access": {"public": false, "users": [], "groups": ["staff"]},
"created_at": "2026-11-02T09:20:11.410Z",
"updated_at": "2026-11-02T09:20:19.902Z",
"sections": null
}
GET /projects/{project_id}/documents¶
List a project's documents, newest first, with every version of each.
Query:
| Parameter | Type | Allowed values | Default | |
|---|---|---|---|---|
page |
integer | 1 or more | 1 |
|
page_size |
integer | 1 to 200 | 50 |
|
status |
string | pending, processing, indexed, failed |
all | |
stale |
boolean | true, false |
all | true: only documents indexed into another collection than the one in use now. false: all others |
source |
string | upload, text, url, s3 |
all | |
external_id |
string | up to 2048 characters | all | Every version with this id |
metadata |
string | a JSON metadata filter | none | URL-encode it |
user |
string | 1 to 256 characters | none | Only documents this user may see; see Searching as a user |
groups |
string, repeated | at most 200 | none | Only documents these groups may see |
Response: 200 with {"documents": [...], "total": ..., "page": ..., "page_size": ...}.
Errors:
| Status | When |
|---|---|
| 400 | The metadata filter is not valid JSON, or not a valid filter |
| 403 | A key bound to a user sends another user, or groups |
| 404 | The project does not exist |
| 503 | stale was given and the vector DB can't be reached |
# Failed documents
curl "$BASE/projects/1/documents?status=failed" -H "Authorization: Bearer $KEY"
# Web pages from 2025 on, tagged "policy"
curl -G "$BASE/projects/1/documents" -H "Authorization: Bearer $KEY" \
--data-urlencode 'source=url' \
--data-urlencode 'metadata={"year": {"$gte": 2025}, "tags": "policy"}'
# What a user may see
curl "$BASE/projects/1/documents?user=ana@acme.com&groups=legal" -H "Authorization: Bearer $KEY"
GET /projects/{project_id}/documents/{document_id}¶
Get one document.
Query:
| Parameter | Type | Default | |
|---|---|---|---|
with_sections |
boolean | false |
Add sections: the extracted text, section by section |
user |
string | none | Answer 404 if this user may not see it |
groups |
string, repeated | none | The same, for these groups |
Response: 200 with the document. 404 when it does not exist, or the user may not see it.
PATCH /projects/{project_id}/documents/{document_id}¶
Change a document's metadata, external_id or access. Retrieval sees the
change at once; nothing is indexed again.
Body (JSON, unknown fields refused; give at least one of metadata,
external_id and access):
| Field | Type | Default | |
|---|---|---|---|
metadata |
object | Merged into the document's metadata. A null value removes that key |
|
replace_metadata |
boolean | false |
Replace the metadata with metadata instead of merging |
external_id |
string, 1 to 2048 characters | A new id that no other document of the project uses. The document becomes version 1 of it | |
access |
object | Replaces its access, on every version of the document |
Response: 200 with the document.
Errors: 400 (bad metadata or access, or the external_id is used by
another document), 404.
# Add a tag and remove the "draft" key
curl -X PATCH "$BASE/projects/1/documents/31" -H "Authorization: Bearer $KEY" \
-H 'Content-Type: application/json' \
-d '{"metadata": {"tags": ["policy"], "draft": null}}'
# Restrict it to two users and a group
curl -X PATCH "$BASE/projects/1/documents/31" -H "Authorization: Bearer $KEY" \
-H 'Content-Type: application/json' \
-d '{"access": {"users": ["ana@acme.com", "omar@acme.com"], "groups": ["legal"]}}'
# Make it public again
curl -X PATCH "$BASE/projects/1/documents/31" -H "Authorization: Bearer $KEY" \
-H 'Content-Type: application/json' -d '{"access": {"public": true}}'
PUT /projects/{project_id}/documents/access¶
Set the access of many documents at once, by document_id or
external_id. Each change applies to every version of the document. This
is what a permission sync from your source system sends. Retrieval sees the
change at once; nothing is indexed again.
Body (JSON, unknown fields refused):
| Field | Type | |
|---|---|---|
documents |
list, 1 to 1000 | Required |
Each item:
| Field | Type | |
|---|---|---|
document_id |
integer, 1 or more | Give this or external_id |
external_id |
string, 1 to 2048 characters | Give this or document_id |
access |
object | The new access. Required |
Response: 200
| Field | Type | |
|---|---|---|
project_id |
integer | |
results |
list | {document_id, external_id, updated} per item. updated lists the documents (versions) changed; empty when none matched |
updated |
integer | Documents changed in all |
not_found |
integer | Items that matched no document |
curl -X PUT "$BASE/projects/1/documents/access" -H "Authorization: Bearer $KEY" \
-H 'Content-Type: application/json' -d '{
"documents": [
{"external_id": "contract-2291", "access": {"groups": ["legal"]}},
{"document_id": 31, "access": {"public": true}},
{"external_id": "s3://acme-docs/hr/salaries.xlsx", "access": {"public": false}}
]
}'
{
"project_id": 1,
"results": [
{"document_id": null, "external_id": "contract-2291", "updated": [40, 52]},
{"document_id": 31, "external_id": null, "updated": [31]},
{"document_id": null, "external_id": "s3://acme-docs/hr/salaries.xlsx", "updated": []}
],
"updated": 3,
"not_found": 1
}
DELETE /projects/{project_id}/documents/{document_id}¶
Delete a document with its chunks, vectors and kept file.
Response: 204, no body. 404 when it does not exist.
POST /projects/{project_id}/documents/{document_id}/process¶
Chunk and index a document again, for example with other chunking options,
or index a document stored with process: false. Its old chunks and
vectors are replaced.
Body (JSON, every field optional, unknown fields refused):
| Field | Type | Default | |
|---|---|---|---|
chunking |
object | the project's | Chunking options, merged over the project's |
reload |
boolean | false |
Extract the text again from the kept file, instead of re-chunking the stored text |
force |
boolean | false |
Process it even if it is marked processing (a crash left it stuck) |
background |
boolean | false |
Return at once and process it as a job. The response's job_id is that job |
Response: 200 with the document.
Errors:
| Status | When |
|---|---|
| 404 | The project or document does not exist |
| 409 | It is being processed, or the collection belongs to another embedding model |
| 422 | The file can't be read, or invalid chunking options |
| 502 | The embedding provider (or the LLM, for llm_context) failed |
curl -X POST "$BASE/projects/1/documents/31/process" -H "Authorization: Bearer $KEY" \
-H 'Content-Type: application/json' \
-d '{"chunking": {"strategy": "markdown", "chunk_size": 600, "parent_chunk_size": 2400}}'
POST /projects/{project_id}/documents/{document_id}/preview¶
Show how other options would chunk the document's stored text. Nothing is
stored or embedded (except by the semantic strategy, which needs
embeddings to split).
Body (JSON, unknown fields refused):
| Field | Type | Default | |
|---|---|---|---|
chunking |
object | the project's | Chunking options to try |
limit |
integer, 1 to 500 | 20 |
Chunks returned |
Response: 200
| Field | Type | |
|---|---|---|
chunking |
object | The resolved options |
chunk_count |
integer | All the chunks it would make |
chars |
object | {min, max, avg} chunk length in characters |
chunks |
list | The first limit chunks: {chunk_index, chunk_text, chunk_metadata, parent_index} |
parent_count |
integer or null | With parent_chunk_size |
parent_chars |
object or null | {min, max, avg} parent length |
parents |
list or null | {parent_index, parent_text, parent_metadata} |
document |
object or null | The document it was run on |
curl -X POST "$BASE/projects/1/documents/31/preview" -H "Authorization: Bearer $KEY" \
-H 'Content-Type: application/json' \
-d '{"chunking": {"strategy": "sentence", "chunk_size": 400}, "limit": 5}'
GET /projects/{project_id}/documents/{document_id}/chunks¶
A document's chunks in reading order.
Query: page (default 1), page_size (1 to 200, default 50), user,
groups (404 when that user may not see the document).
Response: 200 with {"chunks": [...], "total", "page", "page_size"}.
Each chunk:
| Field | Type | |
|---|---|---|
chunk_id |
integer | |
project_id, document_id |
integer | |
parent_id |
integer or null | Its parent chunk, for documents chunked with parent_chunk_size |
chunk_index |
integer | Its position in the document, from 0 |
chunk_text |
string | |
chunk_context |
string or null | The LLM-written context indexed with it (llm_context) |
chunk_metadata |
object or null | Where it came from: page_start, page_end, page_unit, char_start, char_end, titles, headings, start_time, end_time, row_start, row_end, ... |
created_at |
datetime |
GET /projects/{project_id}/documents/{document_id}/parents¶
A document's parent chunks in reading order, for documents chunked with
parent_chunk_size. These are what small-to-big
retrieval returns.
Query: the same as for chunks.
Response: 200 with {"parents": [...], "total", "page", "page_size"}.
Each parent:
| Field | Type | |
|---|---|---|
parent_id |
integer | |
project_id, document_id |
integer | |
parent_index |
integer | From 0 |
parent_text |
string | |
parent_metadata |
object or null | Its chunks' locations combined, and chunk_start / chunk_end: the chunk_index range of its chunks |
created_at |
datetime |