Apply changeset
POST /ontology/v1/changesets
Apply a batch of node, relation and invalidation operations as one transaction, when a mirror has several records to write together and a partial write would leave the graph inconsistent. Every operation succeeds or none is applied. Send an Idempotency-Key header; the same key with the same content replays the first result, and the same key with different content is ONTOLOGY_CONFLICT.
Support: supported
Parameters
| Name | Location | Type | Required | Description |
|---|---|---|---|---|
| Idempotency-Key | header | string | true | Unique key for this batch, at most 255 characters; resend the same key to replay the first result instead of writing the batch twice. |
Request body (application/json)
Required: true
| Name | Type | Description |
|---|---|---|
| at | string | World time the batch describes, in ISO 8601 UTC; operations without their own time are dated by it. |
| scope | string | Scope the batch came from, normally the session id it was observed in; it is stored with the operations for later reading. |
| ops | array<object> | At most 500 operations, applied in order; each names its kind in op and the fields that kind requires. |
| ops[].op | string | Which operation to apply; the remaining required fields follow from this value. |
| ops[].key | string | Caller-local name for the node or relation this operation creates, reused by later operations in the same batch; it is not an id. |
| ops[].type | string | Registered type name for upsert_node and relate; an unregistered name refuses the whole batch. |
| ops[].ref | string | Mirrored record id for upsert_node, which must start with the type’s ref_prefix; omit for a concept. |
| ops[].name | string | Display name for upsert_node, at most 200 characters. |
| ops[].source | string | Start of a relate fact; a key from this batch or an existing node id. |
| ops[].target | string | End of a relate fact; a key from this batch or an existing node id. |
| ops[].fact | string | The relationship in one sentence for relate, at most 280 characters. |
| ops[].origin | string | Where a relate fact came from; the relation type must accept this origin. |
| ops[].edge | string | Relation id an invalidate operation acts on, from relations.list or an earlier operation in this batch. |
| ops[].invalid_at | string | World time an invalidate operation marks the fact as no longer true. |
| ops[].by | string | Relation id that replaces the invalidated one, when a successor was recorded; omit when nothing replaced it. |
| ops[].reason | string | Why the operation was applied, kept for people reading the history; not enforced. |
| ops[].from | string | Node id a merge operation folds away, resolving to the into node afterwards. |
| ops[].into | string | Node id a merge operation keeps, receiving the merged node’s relations and aliases. |
| ops[].node | string | Node id an alias operation adds a name to. |
| ops[].alias | string | The additional name an alias operation records for its node. |
{ "type": "object", "required": [ "at", "ops" ], "description": "A batch of graph operations applied as one transaction; every operation succeeds or none is applied.", "properties": { "at": { "type": "string", "format": "date-time", "description": "World time the batch describes, in ISO 8601 UTC; operations without their own time are dated by it.", "example": "2026-11-01T00:00:00.000Z" }, "scope": { "type": "string", "description": "Scope the batch came from, normally the session id it was observed in; it is stored with the operations for later reading.", "example": "sesn_0123456789abcdef" }, "ops": { "type": "array", "maxItems": 500, "description": "At most 500 operations, applied in order; each names its kind in op and the fields that kind requires.", "items": { "$ref": "#/components/schemas/ontology-ChangesetOp" } } }}Response
HTTP 200
The applied count, the ids assigned to the batch’s keys, and replayed true when the key had been seen before.
application/json
| Name | Type | Description |
|---|---|---|
| applied | integer | Number of operations that changed the graph; zero when the key had been seen before. |
| ids | object | Map from each key used in the batch to the node or relation id it produced or matched. |
| refreshed | array<string> | Relations that already held the same meaning and were refreshed instead of duplicated. |
| rejected | array<object> | Operations refused within the batch, each with its index and reason; empty when the batch applied whole. |
| rejected[].index | integer | Zero-based position of the operation in the submitted ops array. |
| rejected[].code | string | Failure category for this operation, such as ONTOLOGY_TYPE_UNKNOWN for an unregistered type. |
| rejected[].message | string | Why this operation was refused, naming the offending field. |
| replayed | boolean | True when the Idempotency-Key had been seen before, so nothing changed and the first result is returned. |