Skip to content

Shared objects

Several endpoints take the same objects. They are described once here and linked from each endpoint.

Chunking options

How a document is split into chunks. Every upload, import, process, preview and reindex request takes these options, and a project stores its own defaults (chunking on create and update).

  • In JSON requests they go in a chunking object.
  • In multipart requests (POST /projects/{id}/documents, POST /data/preview) each option is a form field of its own.

Unknown fields are refused (422).

Field Type Allowed values Default
extractor string native, docling native (DOCUMENT_EXTRACTOR) How text is extracted from files. docling uses Docling for the types it reads and the native loaders for the rest; it needs the docling extra. A document extracted with the other one is extracted again from its kept file
strategy string auto, fixed, token, recursive, sentence, paragraph, page, markdown, code, semantic, table, json auto (CHUNKING_STRATEGY) How to split; see Strategies
chunk_size integer 20 to 100000 1000 (CHUNK_SIZE) Target chunk length, in length_unit
chunk_overlap integer 0 or more, and less than chunk_size 200 (CHUNK_OVERLAP) How much consecutive chunks share
length_unit string chars, tokens chars (CHUNK_LENGTH_UNIT) What chunk_size and chunk_overlap count. tokens needs the tiktoken extra. The token strategy always uses tokens
token_encoding string a tiktoken encoding such as cl100k_base or o200k_base, up to 64 characters cl100k_base (CHUNK_TOKEN_ENCODING) Used when counting tokens
separators list of strings 1 to 50 items, each up to 200 characters the recursive splitter's list Where recursive may split, tried in order. "" splits anywhere. In a multipart form, repeat the field once per separator; empty form items are ignored
separators_regex boolean false Read separators as regular expressions
language string up to 32 characters, such as python or javascript detected from the file extension The programming language for the code strategy: python, javascript, typescript, go, rust, java and others
rows_per_chunk integer 1 to 100000 as many rows as fit in chunk_size A fixed number of rows per chunk for the table strategy
table_format string csv, markdown, key_value csv How table writes the rows of each chunk
semantic_threshold_type string percentile, standard_deviation, interquartile, gradient percentile How semantic picks the breakpoints
semantic_threshold_amount number 0 or more 95 (percentile, gradient), 3 (standard_deviation), 1.5 (interquartile) The breakpoint threshold for the chosen type
semantic_buffer_size integer 0 to 10 1 Sentences on each side that are embedded with each sentence
contextual_header boolean false (CHUNK_CONTEXTUAL_HEADER) Embed each chunk with a header naming its file, title, page and section. The stored chunk text stays clean
llm_context boolean false (CHUNK_LLM_CONTEXT) Contextual retrieval: the LLM writes a short context that places each chunk in its document. It is embedded and keyword-indexed with the chunk, and returned as chunk_context. One LLM call per chunk; unchanged chunks reuse their context. Needs LLM_PROVIDER
parent_chunk_size integer 0, or more than chunk_size and at most 100000 none (PARENT_CHUNK_SIZE) Also build parent chunks of about this size, for small-to-big. 0 turns it off

Options are resolved field by field, in this order:

  1. the request's options
  2. the project's chunking
  3. the CHUNKING_* settings

A request can change one field and keep the rest. For example, {"chunk_size": 500} keeps the project's strategy.

Strategies

Strategy What it does
auto Picks by file type: markdown for Markdown, code for source code, table for CSV and spreadsheets, json for JSON, page for slides, recursive for the rest
fixed Fixed-size windows with overlap, ignoring the text's structure
token Fixed-size windows counted in tokens (tiktoken)
recursive Splits on paragraphs first, then sentences, lines and words, until each piece fits
sentence Packs whole sentences up to chunk_size
paragraph Packs whole paragraphs up to chunk_size
page One chunk per page, slide, sheet, chapter or message
markdown One chunk per heading section, split further when too long
code Splits at class and function boundaries
semantic Splits where the meaning changes between sentences. Needs embeddings, so it is slower
table Groups rows, repeating the header in each chunk
json Splits into valid JSON sub-objects

GET /data/file-types lists the strategies and the current defaults (Building blocks).

Example

{
  "chunking": {
    "strategy": "recursive",
    "chunk_size": 800,
    "chunk_overlap": 100,
    "contextual_header": true,
    "parent_chunk_size": 3000
  }
}

The same options as multipart form fields:

curl -X POST "$BASE/projects/1/documents" -H "Authorization: Bearer $KEY" \
     -F files=@handbook.pdf \
     -F strategy=recursive -F chunk_size=800 -F chunk_overlap=100 \
     -F separators=$'\n\n' -F separators=$'\n' -F separators='. '

Metadata

Your own fields on a document, such as a team, a year or tags. You can filter on them when listing and retrieving.

  • It is a JSON object.
  • Keys are 1 to 128 characters. They can't start with $ or contain control characters.
  • Values are strings, numbers, booleans, null, or lists of those.
  • A list has at most 100 items, and a string at most 4096 characters.
  • There are at most 64 keys, and at most 16 KB in all.
{"metadata": {"team": "legal", "year": 2025, "tags": ["contract", "nda"], "draft": false}}

When a new version of a document is ingested without metadata, it keeps the previous version's metadata. See Metadata and versions.

Metadata filters

A metadata filter selects documents by their metadata. It is used by the metadata query parameter of GET /projects/{id}/documents and by filters.metadata in retrieval.

A plain value means "equals". For a list field, it means "contains":

{"team": "legal", "tags": "nda"}

Several keys must all match. An operator object gives other comparisons:

Operator Matches when the field...
$eq equals the value (contains it, for a list)
$ne does not equal the value. Also matches documents without the field
$in equals one of the values in the list
$nin equals none of the values. Also matches documents without the field
$gt, $gte, $lt, $lte is greater, greater or equal, less, or less or equal (numbers, or strings such as ISO dates)
$exists true: the field is set. false: it is not

To combine conditions, use these:

Operator
$and A list of filters that must all match
$or A list of filters of which at least one must match
$not A filter that must not match. Also matches documents without the field

Limits: at most 6 levels of nesting and 200 conditions. A bad filter returns 400 with the reason.

{
  "$and": [
    {"year": {"$gte": 2024}},
    {"$or": [{"team": "legal"}, {"tags": {"$in": ["policy", "contract"]}}]},
    {"$not": {"draft": true}}
  ]
}

Document access

Who may see a document. Upload, import and update requests take it as access. For multipart uploads it goes in a form field, as JSON. See Document permissions.

Field Type Default
public boolean true when there are no users or groups, else false Visible to everyone. {"public": false} alone hides the document from every restricted caller
users list of strings [] User ids, such as an email or a subject claim. 1 to 256 characters each, with no control characters
groups list of strings [] Group names, 1 to 128 characters each, matching ^[A-Za-z0-9][A-Za-z0-9._:@/-]*$. Either stored groups or groups your callers send

Rules:

  • public: true together with users or groups is refused (400 or 422). Leave public out, or set it to false.
  • There are at most 1000 users and groups in all. Repeats are removed.
  • Unknown fields are refused.
  • When a new version of a document is ingested without access, it keeps the previous version's access.
{"access": {"users": ["ana@acme.com"], "groups": ["legal", "managers"]}}

Responses return the access as {"public": ..., "users": [...], "groups": [...]}. It is null for callers who are themselves restricted, so they can't learn who else may read a document.

Searching as a user

Read endpoints can be limited to what one user may see:

  • JSON bodies (retrieval) take a user object:

    Field Type
    id string, 1 to 256 characters The user's id. Their stored groups are added
    groups list of strings, at most 200 Groups the user is in, from your identity provider. They are added to the stored ones

    Give id, groups or both. Unknown fields are refused.

    {"query": "parental leave", "user": {"id": "ana@acme.com", "groups": ["hr"]}}
    
  • Query strings (listing documents, chunks, parents and the graph) take user=<id> and a repeated groups=<name> (at most 200):

    curl "$BASE/projects/1/documents?user=ana@acme.com&groups=hr&groups=legal" \
         -H "Authorization: Bearer $KEY"
    

Who the request runs as:

Caller Sees
A key bound to a user (user_id) Always what that user and their stored groups may see. Sending another user, or any groups, returns 403. Sending its own user id is allowed
Any other key, or no auth, with user and / or groups What that user may see: the documents they or their groups are listed on, plus public ones
Any other key, or no auth, with neither Everything

A document the user may not see is answered with 404, as if it did not exist.

Conflicts with existing documents

Every upload and import takes on_conflict. It decides what happens when the project already has a document with the same external_id but other content. The external_id defaults to the file name, the URL or the s3:// URI.

Value
new_version (default) Add the content as a new version. The older versions are deleted once the new one is indexed. Its result lists them in replaces
skip Keep the existing document. The result's status is skipped
keep_both Add it as a separate document with the same external_id

Content the project already has (the same file hash) is never stored twice. Its result is duplicate.

Upload and import response

All the endpoints that add documents (upload, text, url, s3, sync) answer with the same object, UploadResponse. One bad file never fails the request: each file, page or object gets its own result.

Field Type
project_id integer
results list One per file, page or object. Empty when the work runs in the background
counts object How many results have each status, for example {"indexed": 3, "duplicate": 1}
processing string inline (done in the request), background (a job is doing it) or none (process: false)
job_id integer or null The background job, with background: true. Poll it with GET /projects/{id}/jobs/{job_id}
stats object Web crawl, S3 listing and sync counters, such as fetched, checked, robots_blocked, excluded, external, noindex, not_fetched, redirect_duplicates and sitemaps
warnings list of strings For example, a max_pages above the server's limit that was lowered

Each item of results:

Field Type
file_name string
status string See below
file_size integer or null Bytes
archive string or null The uploaded ZIP or TAR it came from
source_uri string or null The URL or s3:// URI it was read from
replaces list of integers Older versions this document replaces, deleted once it is indexed
message string or null Why it was skipped, rejected or failed
document object or null The document
status Meaning
indexed Extracted, chunked, embedded and searchable
created Stored but not processed yet (process: false or background: true)
duplicate The project already has this exact content
skipped A document with this external_id exists and on_conflict is skip
unchanged The page or S3 object did not change since it was imported (sync and re-import)
missing The page answered 404 or 410, or the S3 key is gone
deleted Missing and removed, with delete_missing: true (sync)
unsupported A file type Pagelore can't read
rejected Refused before reading: too large, too many files, or an unsafe archive entry
failed Reading, chunking or embedding failed. See message
{
  "project_id": 1,
  "results": [
    {
      "file_name": "handbook.pdf",
      "status": "indexed",
      "file_size": 482113,
      "archive": null,
      "source_uri": null,
      "replaces": [12],
      "message": null,
      "document": {"document_id": 31, "status": "indexed", "chunk_count": 84, "version": 2}
    }
  ],
  "counts": {"indexed": 1},
  "processing": "inline",
  "job_id": null,
  "stats": {},
  "warnings": []
}

(The document object is shortened here.)