create_relation
Assert a typed, directed, time-bounded edge between two entities — and the cardinality rule that can reject it.
create_relation(relation_type: str, from_entity: str, to_entity: str, ...) -> CreateRelationResultcreate_relation(request: RelationCreateRequest) -> RelationCreateResponseParameters
relation_typestringrequiredMust be declared in the active schema — otherwise RelationTypeNotInSchema.
from_entitystringrequiredSource entity id.
to_entitystringrequiredTarget entity id.
confidencefloatoptionalDefaults server-side.
valid_from_unix_nanos64-bit integeroptionalStart of the interval the relation holds over.
valid_to_unix_nanos64-bit integeroptionalEnd of it.
extractor_idintegeroptionalAttribute it to an extractor.
session_id64-bit integeroptionalAttribute it to a session.
evidencestring[]optionalMemory ids backing it.
propertiesstring (wire: bytes)optionalOpaque properties. Brain stores and never interprets them.
Returns
relation_idstringalwaysThe new relation.
Cardinality is enforced, not reconciled
A schema can declare a relation type single-valued. Creating a second one
that violates it fails with CardinalityViolation — the write is rejected,
not silently reconciled.
Supersede the existing relation
instead.
On the wire
Entity ids are UUID bytes, properties is a propertiesBlob, and evidence
is a single reference rather than an array. Every request carries a
requestId plus an optional actAs.
Was this page helpful?