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 one options object; every option is accepted in snake_case or camelCase (customer_id or customerId). The result is returned as the server sends it, with snake_case fields, typed as Record<string, unknown>.
Read the document itself, not a ranked excerpt: one section by its section_key, or a range of pages. Use it to check what a cited section says, or to read around a passage that context.fetch returned. The call always reads the current version.
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; a refused call is not charged.

Parameters

Address the document one way: pass either document_key or document_id. Then pass exactly one of section_key or pages.
string
The document’s address, from a citation or a knowledge.query result.
string
The id you gave the document at creation, with the scope it was created in.
string
A section_key from documents.index.
string | tuple[int, int]
A page range, "3-5" or (3, 5) ([3, 5] in TypeScript): whole page numbers from 1, with the end not before the start. A read returns at most 20 pages.
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 text of the section or pages.
integer
The size of text in tokens.
dict
Where the text came from: document_key, document_id, version, section_key and section_path (for a section read), page and page_end, url and anchor when the source has a link, and added_at. source_disconnected is true when the document came from a connected source that has since been disconnected.
The result also repeats document_key and version, and carries section_key or pages as you asked.

Example

Raises

  • InvalidInputError: when you pass both or neither of section_key and pages, pages is malformed, or the request is too large (more than 20 pages, or more text than one call returns; ask for a smaller section or range). Also when the page range holds no text, for example past the last page. Check code (serverCode in TypeScript), read_too_large or invalid_read_request, to tell them apart. None of these is charged.
  • ContextNotFoundError: when the document or section does not exist or you cannot see it; these look the same on purpose. With code == "document_not_ready" (serverCode in TypeScript) the document is still being processed: try again shortly. Also when the feature is not enabled on your instance.
  • FeatureNotInPlanError: when your plan does not include document navigation.
  • CustomerIdNotAcceptedError: when customer_id is passed on a B2C instance.

See also