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>.context.fetch, which returns the best few passages, a query returns every match, so you can count and list with confidence. You send a structured request, never question text. Call knowledge.describe first for the names to use.
Facts (
Obligation, Commitment, Transaction, Decision) come from documents read in detail. By default that is contracts, financial records, tickets and profile records; a document read lightly contributes the entities it mentions but no facts. See How deeply a document is read.Parameters
What to return: a fact type (
Obligation, Commitment, Transaction or Decision) or an entity type from describe. An entity is returned only when a document you can read mentions it.Conditions on the target’s properties, all of which must hold. Give a value for equality, a list for “any of”, or a one-key dict with an operator:
{"due_at": {"before": "2027-03-01"}}. The operators a property accepts are in describe:between takes [low, high], in takes a list, and exists takes True or False. A date given as a calendar day, such as "2027-03-01", is that whole day for eq. Dates are ISO dates or datetimes.Follow a relation to what is at the other end and filter it. The key is a relation from
describe; the value takes type, name, where and a nested related for a further hop. A query follows at most two hops. For example, obligations whose counterparty is the organization Acme: {"COUNTERPARTY": {"type": "Organization", "name": "Acme"}}.An ISO date or datetime. Read documents as they stood then, for the document types your instance keeps history for (policies and contracts by default). Without it, or for other types, the current version is used.
Only facts and entities from these documents, by the
document_id values you gave them, as in context.fetch.{"count": True} for a count, or {"group_by": "<property>"} for a count per value of a property. The answer has no items.The
next_cursor of the previous page. Send the same request with it. A cursor from a different request is refused.The user you ask as. The query covers that user’s documents and client-wide documents, and the customer’s documents too when you also pass
customer_id.Returns
One page of matches. Each has
id, type, properties, related (the parties or related entities, as {"relation": ..., "name": ...}) and citations. Empty for an aggregate.On each item: where it was found. Each has
document_key, document_id, version, document_type, title, section_key, section_path and page. Pass a document_key to documents.read to check the source.True (true in TypeScript) when the result is the whole set. False when the set was larger than a query returns, so the matches you can page through are not all of them. Narrow the query with a filter rather than treating the result as the full answer.How much of your documents the answer could draw on, so you can say what is missing.
documents_in_scope is how many documents could hold the target. Of those, unprocessed are not processed yet, light_only are processed but were only lightly read, so they may hold facts the query cannot see yet, and failed did not process. A query is complete over what Synap has extracted, and coverage tells you what that leaves out.Example
Raises
InvalidInputError: when the request is refused. Checkcode(serverCodein TypeScript):unknown_type,unknown_property,unknown_relation,bad_condition(an operator that does not suit the property, or a bad value),too_many_hops,invalid_cursor, orquery_too_broad(too many matches with no filter; add one). Also raised before the request whentargetis empty orlimitis not a whole number from 1 to 500.ServiceUnavailableError: when the query takes too long. Nothing partial is returned; narrow it with a filter and retry.ContextNotFoundError: when the feature is not enabled on your instance.FeatureNotInPlanError: when your plan does not include knowledge queries.CustomerIdNotAcceptedError: whencustomer_idis passed on a B2C instance.