Brain Docs

Reference

TypeScript SDKInstallationHTTP clientWire client
createRelationgetRelationlistRelationstraverseRelationssupersedeRelationtombstoneRelation
ErrorsRetriesPagination
Brain/Docs
✦ ASKBrain on GitHubDashboard
TypeScript SDKRelationscreateRelation

createRelation

Assert a typed, directed, time-bounded edge between two entities — and the cardinality rule that can reject it.

PURPOSE

Assert a relation between two entities. Unlike a memory edge it is schema-checked and versioned, and it carries a validity interval — which is what makes "worked at" different from "works at".

POST/v1/relationsBearer API keystable
createRelation(input: CreateRelationInput): Promise<CreateRelationResult>
Handshake credentialstable
createRelation(request: RelationCreateRequest): Promise<RelationCreateResponse>

Parameters

ParameterTypeRequired
relationTypestringrequired

Must be declared in the active schema — otherwise RelationTypeNotInSchema.

fromEntitystringrequired

Source entity id.

toEntitystringrequired

Target entity id.

confidencefloatoptional

Defaults server-side.

validFromUnixNanos64-bit integeroptional

Start of the interval the relation holds over.

validToUnixNanos64-bit integeroptional

End of it.

extractorIdintegeroptional

Attribute it to an extractor.

sessionId64-bit integeroptional

Attribute it to a session.

evidencestring[]optional

Memory ids backing it.

propertiesstring (wire: bytes)optional

Opaque properties. Brain stores and never interprets them.

Returns

FieldTypePresence
relationIdstringalways

The 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.

See also
supersedeRelationgetSchema

Was this page helpful?

statementHistory

Every version in a statement's supersession chain, oldest to newest.

getRelation

Read one relation, including its symmetry flag and its place in the supersession chain.

On this page

ParametersReturnsOn the wire
Suggest an editOpen in Playground