Brain Docs

Reference

Rust SDKInstallationHTTP clientWire client
create_relationget_relationlist_relationstraverse_relationssupersede_relationtombstone_relation
ErrorsRetriesPagination
Brain/Docs
✦ ASKBrain on GitHubDashboard
Rust SDKRelationscreate_relation

create_relation

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
async fn create_relation(&self, input: &CreateRelationInput) -> Result<CreateRelationResult, BrainHttpError>
Handshake credentialstable
async fn create_relation(&self, request: &RelationCreateRequest) -> Result<RelationCreateResponse>

Parameters

ParameterTypeRequired
relation_typestringrequired

Must be declared in the active schema — otherwise RelationTypeNotInSchema.

from_entitystringrequired

Source entity id.

to_entitystringrequired

Target entity id.

confidencefloatoptional

Defaults server-side.

valid_from_unix_nanos64-bit integeroptional

Start of the interval the relation holds over.

valid_to_unix_nanos64-bit integeroptional

End of it.

extractor_idintegeroptional

Attribute it to an extractor.

session_id64-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
relation_idstringalways

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
supersede_relationget_schema

Was this page helpful?

statement_history

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

get_relation

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