Skip to main content
REST One HTTPS request, or two when you address the document by document_id.
Added in Python SDK 0.9.0 and JavaScript and TypeScript SDK 0.9.0. In TypeScript, pass the document_key as a string, or an options object; every option is accepted in snake_case or camelCase (documentId or document_id). The result is returned as the server sends it, with snake_case fields, typed as Record<string, unknown>.
Open a document’s outline before you read it. You get its title, a summary and the tree of sections, each with a section_key, heading and page range, so an agent can decide what to read and then call documents.read with a section_key. It is also how you check what a citation points at.
Enabled per instance, and needs a Pro plan or above. Where it is not enabled the call raises ContextNotFoundError, the same error as for a document that does not exist. A plan without it raises FeatureNotInPlanError. Each successful call uses credits.

Parameters

Address the document one way: pass either document_key or document_id.
string
The document’s address, from memories.create, a citation, or a knowledge.query result.
string
The id you gave the document at creation, with the scope it was created in.
integer
Open the outline of this version instead of the current one. List versions with documents.versions.
string
The user you read the document as. Pass the same user_id, customer_id and scope you use with context.fetch, also when you hold a document_key.
string
The customer you read the document as. A customer’s document opens only for a call that names that customer. Not accepted on B2C.
dict[str, str]
The deeper scope level you read at, as level name to id.

Returns

string
The document’s title.
string | None
A short summary of the whole document. Left out while any part of the document has been removed by a forget request.
integer | None
The number of pages, when the document has pages.
list[dict]
The sections in reading order. Each has section_key (what you pass to read), heading, level, parent_key (the enclosing section), section_path (the headings from the top down), page_start, page_end and a one-line summary. Empty while the document is still being processed. Sections removed by a forget request are not listed.
The result also repeats document_key, document_id, version, is_current, document_type and processing_stage.

Example

Raises

  • ContextNotFoundError: when the document does not exist or you cannot see it (another customer’s or user’s, outside your instance’s visibility, or deleted); these look the same on purpose. Also when the feature is not enabled on your instance.
  • FeatureNotInPlanError: when your plan does not include document navigation.
  • InvalidInputError: when version is not a positive integer, or you pass both or neither of document_key and document_id.
  • CustomerIdNotAcceptedError: when customer_id is passed on a B2C instance.

See also