Skip to content
中文

Concepts

Ontology stores your organization’s structure as one graph: nodes are entities, relations are the facts connecting them. Read the types before you write, and read by point in time to recover history.

Types

A type is registered structure up front: it says which entities and which facts the graph accepts. Types are not created at runtime — the service that owns the record registers them when it deploys — so a name that is not in the type list cannot be written. Which types you can write is whatever GET /ontology/v1/types returns.

GET /ontology/v1/types lists every registration in force for your organization; GET /ontology/v1/types/{name} reads one type’s full definition. A type is either a node type or a relation type (kind is node or edge), returned with the owner and version it came from.

FieldMeaning
nameThe type name you use as type when creating a node or relation; a dotted name marks a namespaced subtype
ref_prefixOptional, node types only. A node carrying a ref must have an external record id starting with this prefix; pure concept types have none
weight0–1, how much reaching this type matters when ranking
passableFalse makes it a stopping point: reached, never expanded
source / targetNode type names a relation type admits at each end; a single * admits every type
directionforward reads from source to target only; both holds equally in both directions
functionalTrue means a source may hold at most one valid relation of this type at a time; a new one supersedes the old
persistenceOptional, 0–1: how strongly the relation holds while valid; 1 never fades, and omitting it uses the default decay
originsWhich origins a relation of this type may carry

weight, passable, persistence and origins are set by the service that registers the type and used by the platform when it reads and expands neighborhoods; you normally do not set them.

A relation’s origin is one of four values, seen when you read a relation. A changeset’s relate operation may set it, and it must then stay inside the set the type declares. On POST /ontology/v1/relations the platform writes platform — a registered service mirroring a record it owns — and does not read it from the request body.

ValueMeaning
platformA registered service mirrored a record it owns, so the fact is as authoritative as that record
statedA person said it: believable, and equally possible to be mistaken
observedThe platform watched it happen, so it is evidence rather than testimony
inferredDerived by reasoning over other facts: the weakest, and the first to be revised

Nodes

A node is one entity. Its id looks like ond_ plus 32 lowercase letters or digits — treat it as opaque and don’t parse it.

FieldMeaning
idNode id, used by relations, merges and later reads
typeThe registered node type it was created as; it never changes afterwards
refId of the mirrored record in the service that owns it, matching the type’s ref_prefix; null for a concept with no external record
nameDisplay name, at most 200 characters
aliasesOther names it is known by; search matches them alongside the name
descriptionProfile of the entity, at most 500 characters, null when none was recorded
ownerMember id whose content this is; null means readable organization-wide
merged_intoThe survivor’s id when this node was merged into another
created_at / updated_atWhen it was first recorded, and when its content last changed
deleted_atWhen the mirrored record is known to have been deleted, kept so history stays answerable

PATCH /ontology/v1/nodes/{node_id} changes the name, aliases or description. Send only what changes: omitted fields keep their values, and only an explicit null clears description. Type and identity are not changed here.

Permission: a node you may reach but not read comes back with only id, type, name and restricted: true. The name confirms you reached the entity you meant, while the content stays withheld.

Relations

A relation is one fact. Its id looks like oed_ plus 32 lowercase letters or digits — also opaque.

FieldMeaning
idRelation id, used by invalidation and later reads
typeThe registered relation type it was recorded as; it must admit both endpoints
source / targetNode ids the fact runs between
factThe relationship in one sentence, at most 280 characters, written to read back on its own
originWhere the fact came from; must be among the type’s origins
confidence0–1, how strongly the fact is held
ownerMember id whose content this fact is; null means readable organization-wide. Another member’s relation reads as not found
valid_at / invalid_atWhen it became true in the world, and when it stopped being true
created_at / expired_atWhen it was recorded, and when it was judged no longer true
superseded_byThe relation that replaced this one, when the invalidation named a successor
archived_atWhen it was archived out of spreading; reads by time still reach it

The two clocks

Every fact carries two clocks, and they are not the same thing:

  • World time, valid_at / invalid_at: when the fact became true in the world, and when it stopped being true. A null valid_at means it was never dated, so treat it as true since it was recorded.
  • System time, created_at / expired_at: when the platform recorded it, and when the platform judged it no longer true. expired_at always trails invalid_at.

The read endpoints’ as_of (an ISO 8601 timestamp) reads by world time: a node recorded later is absent, and a relation invalidated later still counts.

Invalidate, never delete

There is no delete. When a fact stops being true, POST /ontology/v1/relations/{relation_id}/invalidate moves its invalid_at to that world time. The relation stays in the graph and still reads at an earlier as_of, so history stays answerable.

Only invalid_at is required. Use superseded_by to name the relation that replaced it, and reason to say why — reason is not enforced, but whoever reads the history later will be grateful.

GET /ontology/v1/relations returns only currently valid relations by default; pass include_invalid=true to see the invalidated ones too.

Merge

When two records turn out to be the same entity, POST /ontology/v1/nodes/{node_id}/merge folds the duplicate into the node that should survive, with a body of {"into": "<survivor node id>"}. The merged node’s relations and aliases move to the survivor, and later reads of the duplicate id resolve to it.

Merge is idempotent: resending the same idempotency key replays the first result. Splitting it apart again is a staff operation and is not offered here.

Changesets

When a batch of records has to be written together and a partial write would leave the graph inconsistent, POST /ontology/v1/changesets applies the batch as one transaction: every operation succeeds, or none is applied.

The body carries at (the world time the batch describes) and ops (at most 500 operations, applied in order). Each operation names its kind in op:

opWhat it does
upsert_nodeCreate or match a node by its key, with type, name and optional ref, aliases, owner
relateRecord a fact with type, source, target, fact and origin; either end may be a key from this batch or an existing node id
invalidateMove a relation’s invalid_at to the given world time, naming it with edge
mergeFold the from node into the into node, with a reason kept for readers of the history
aliasAdd one alias to an existing node, naming it with node and alias

A key is a caller-local name for the node or relation this operation creates, reused by later operations in the same batch — it is not an id.

In the response, applied counts the operations that actually changed the graph; ids maps each key used in the batch to the id it produced or matched; refreshed lists relations that already held the same meaning and were refreshed rather than duplicated; and rejected lists refused operations with their index, code and reason. replayed true means the idempotency key had been seen before, nothing changed, and the first result came back.

Idempotency keys

Five writes require an Idempotency-Key header (at most 255 characters): create node, merge node, create relation, invalidate relation and apply changeset. The same key with the same content replays the first result instead of writing twice; the same key with different content answers ONTOLOGY_CONFLICT with 409 — reuse the original request for that key, or send a new key. A missing or blank key is refused.

Reading a neighborhood

GET /ontology/v1/nodes/{node_id}/neighborhood is the read to use when a screen or an agent needs one entity’s context. It returns the start node, every node within depth hops, the relations whose both ends are in that set, and a truncated flag.

ParameterValuesDefault
depth1–3, how many hops to walk1
limit1–500, maximum nodes returned200
directionout follows facts this node states, in follows facts others state about it, both follows eitherboth
as_ofread by world time instead of nowcurrent state
include_invalidtrue counts relations whose invalid_at has passedvalid relations only

When the walk reaches limit nodes it stops and reports truncated: true, so nodes is a sample of the neighborhood rather than all of it — raise limit or lower depth. A neighborhood is not a page: there is no cursor to resume from. A depth or limit outside its range is refused rather than clamped to a smaller answer.

POST /ontology/v1/search resolves text to the nodes it most likely names — the call to use when you hold a name and need the node id behind it. What comes back is ranked candidates, not an answer: each gives a node id, a 0–1 score, and where the match came from — name, alias, description, or the fact of a relation around the node.

Compare scores within one response, never across queries. Narrow with types, and cap the count with limit (1–50, default 20). Confirm a candidate with GET /ontology/v1/nodes/{node_id} before writing with it.

Pagination

The list endpoints (nodes, relations) order by id and return data with next_cursor. Omit cursor for the first page, then pass next_cursor back unchanged until it is null.

Walk through it with curl and the SDK → · Range limits and error codes →