Brain Docs

Reference

TypeScript SDKInstallationHTTP clientWire client
createStatementgetStatementlistStatementssupersedeStatementtombstoneStatementretractStatementstatementHistory
ErrorsRetriesPagination
Brain/Docs
✦ ASKBrain on GitHubDashboard
TypeScript SDKStatementscreateStatement

createStatement

Write a typed claim — subject, predicate, object — and learn what it automatically superseded.

PURPOSE

Write one typed claim into the graph. The predicate must be declared in the active schema; an undeclared one is PredicateNotInSchema, not a silent accept.

POST/v1/statementsBearer API keystable
createStatement(input: CreateStatementInput): Promise<CreateStatementResult>
Handshake credentialstable
createStatement(request: StatementCreateRequest): Promise<StatementCreateResponse>

Parameters

ParameterTypeRequired
kindFact | Preference | Eventrequired

What sort of claim this is. These three are the whole set — there is no custom kind.

subjectstringrequired

The entity the claim is about.

predicatestringrequired

Must be in the active schema.

objectStatementObjectrequired

One of the four kinds above.

confidencefloatoptional

Defaults server-side.

eventAtUnixNanos64-bit integeroptional

When the thing happened.

validFromUnixNanos64-bit integeroptional

Start of the interval the claim is asserted over.

validToUnixNanos64-bit integeroptional

End of it. Bitemporal, and separate from event time.

extractorIdintegeroptional

Attribute the claim to an extractor — see listExtractors.

schemaVersionintegeroptional

Pin the schema version the claim was written under.

sessionId64-bit integeroptional

Attribute it to a session.

evidencestring[]optional

Memory ids backing the claim.

Returns

FieldTypePresence
statementIdstringalways

The new statement.

autoSupersededstring

Present when this write automatically superseded an existing statement — a single-cardinality predicate getting a new value. The write succeeded and something else stopped being current; ignoring this field is how a caller loses track of what it replaced.

chainRootstringalways

The supersession chain this joined.

Example

const created = await brain.createStatement({
  kind: "Fact",
  subject: priyaId,
  predicate: "works_at",
  object: { kind: "entity", id: lisbonOfficeId },
  evidence: [memoryId],
});

if (created.autoSuperseded) console.log("replaced", created.autoSuperseded);

The object union

A statement's object is one of four kinds:

OptionTypeDefault / Env
entity{ id }
Points at an entity.
value{ value }
A typed literal — see below.
memory{ id }
Points at a memory.
statement{ id }
Points at another statement — a claim about a claim.

A value object carries one of six typed values: text, integer, float, bool, unix_nanos and blob. unix_nanos is distinct from integer so Brain can range-query it as a time.

Events never supersede

Supersession is for claims that can be corrected. An Event records that something happened; a later event does not make an earlier one false, so Brain never auto-supersedes one. See Supersession.

On the wire

subject is UUID bytes and kind is an integer discriminant rather than a string. evidence is a single reference, not an array of ids. Every request carries a requestId plus an optional actAs.

See also
supersedeStatementSupersession

Was this page helpful?

tombstoneEntity

Retire an entity — it leaves listings but its id keeps resolving.

getStatement

Read one statement — and the supersession-following default that can hand you a different one.

On this page

ParametersReturnsExampleThe object unionOn the wire
Suggest an editOpen in Playground