createRelation
Assert a typed, directed, time-bounded edge between two entities — and the cardinality rule that can reject it.
createRelation(input: CreateRelationInput): Promise<CreateRelationResult>createRelation(request: RelationCreateRequest): Promise<RelationCreateResponse>Parameters
relationTypestringrequiredMust be declared in the active schema — otherwise RelationTypeNotInSchema.
fromEntitystringrequiredSource entity id.
toEntitystringrequiredTarget entity id.
confidencefloatoptionalDefaults server-side.
validFromUnixNanos64-bit integeroptionalStart of the interval the relation holds over.
validToUnixNanos64-bit integeroptionalEnd of it.
extractorIdintegeroptionalAttribute it to an extractor.
sessionId64-bit integeroptionalAttribute it to a session.
evidencestring[]optionalMemory ids backing it.
propertiesstring (wire: bytes)optionalOpaque properties. Brain stores and never interprets them.
Returns
relationIdstringalwaysThe 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?