Create relation
POST /ontology/v1/relations
Record one fact between two existing nodes, for a system mirroring a relationship it owns. type must be registered and must admit these endpoints; fact states the relationship in one sentence. Send an Idempotency-Key header; repeating the same key returns the first result instead of writing a second relation. This writes structure only; it does not give any agent a memory.
Support: supported
Parameters
| Name | Location | Type | Required | Description |
|---|---|---|---|---|
| Idempotency-Key | header | string | true | Unique key for this write, at most 255 characters; resend the same key to replay the first result instead of writing twice. A missing or blank key is refused 400. |
Request body (application/json)
Required: true
| Name | Type | Description |
|---|---|---|
| type | string | Registered relation type name from types.list; it must admit both endpoints or the write is refused. |
| source | string | Node id the fact starts from, from nodes.list or nodes.create. |
| target | string | Node id the fact points at, from nodes.list or nodes.create. |
| fact | string | The relationship in one sentence, at most 280 characters, written to read back on its own. |
| valid_at | string | World time the fact became true, when the mirrored record dates it; omit to leave it undated. |
| owner | string | Member id whose content this fact is, restricting it to that member; omit or null for organization-wide. |
{ "type": "object", "required": [ "type", "source", "target", "fact" ], "description": "The fact to record between two existing nodes of this organization.", "properties": { "type": { "type": "string", "description": "Registered relation type name from types.list; it must admit both endpoints or the write is refused.", "example": "references" }, "source": { "type": "string", "description": "Node id the fact starts from, from nodes.list or nodes.create.", "example": "ond_0123456789abcdef0123456789abcdef" }, "target": { "type": "string", "description": "Node id the fact points at, from nodes.list or nodes.create.", "example": "ond_fedcba9876543210fedcba9876543210" }, "fact": { "type": "string", "maxLength": 280, "description": "The relationship in one sentence, at most 280 characters, written to read back on its own.", "example": "李总的报价单" }, "valid_at": { "type": "string", "format": "date-time", "nullable": true, "description": "World time the fact became true, when the mirrored record dates it; omit to leave it undated.", "example": "2026-11-01T00:00:00.000Z" }, "owner": { "type": "string", "nullable": true, "description": "Member id whose content this fact is, restricting it to that member; omit or null for organization-wide.", "example": null } }}Response
HTTP 201
The recorded relation, with the id later reads and invalidation use.
application/json
| Name | Type | Description |
|---|---|---|
| id | string | Relation id, used by invalidation and later reads; treat it as opaque and do not parse it. |
| type | string | Registered relation type this fact was recorded as; it must admit both endpoints. |
| source | string | Node id the fact starts from. |
| target | string | Node id the fact points at. |
| fact | string | The relationship in one sentence, at most 280 characters, as it should be read back. |
| episodes | array<object> | Where this fact was learned, oldest first; each entry names the scope it came from and an optional time range. |
| episodes[].scope | string | Scope the experience belonged to, normally a session id. |
| episodes[].from | string | Start of the period the experience covered, when known; omit for a single moment. |
| episodes[].to | string | End of the period the experience covered, when known; omit for a single moment. |
| origin | string | Where the fact came from; the relation type must list this origin among the ones it accepts. |
| confidence | number | How strongly the fact is held, from 0 to 1; 1 is fully held and lower values fade faster. |
| owner | string | Member id whose content this fact is; null means it is readable organization-wide. Another member's relation reads as not found. |
| valid_at | string | World time the fact became true; null when it was never dated, in which case treat it as true since it was recorded. |
| invalid_at | string | World time the fact stopped being true; null while it still holds. The relation is kept and reads at an earlier as_of. |
| created_at | string | System time the fact was recorded, in ISO 8601 UTC. |
| expired_at | string | System time the fact was judged no longer true, which trails invalid_at; null while it still holds. |
| superseded_by | string | Relation id that replaced this one, when the invalidation named a successor; null when nothing replaced it. |
| archived_at | string | System time the fact was archived out of spreading; null while it still spreads, and reads by time still reach it either way. |