Skip to content
中文

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

NameLocationTypeRequiredDescription
Idempotency-KeyheaderstringtrueUnique 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

NameTypeDescription
atstringWorld time the batch describes, in ISO 8601 UTC; operations without their own time are dated by it.
scopestringScope the batch came from, normally the session id it was observed in; it is stored with the operations for later reading.
opsarray<object>At most 500 operations, applied in order; each names its kind in op and the fields that kind requires.
ops[].opstringWhich operation to apply; the remaining required fields follow from this value.
ops[].keystringCaller-local name for the node or relation this operation creates, reused by later operations in the same batch; it is not an id.
ops[].typestringRegistered type name for upsert_node and relate; an unregistered name refuses the whole batch.
ops[].refstringMirrored record id for upsert_node, which must start with the type’s ref_prefix; omit for a concept.
ops[].namestringDisplay name for upsert_node, at most 200 characters.
ops[].sourcestringStart of a relate fact; a key from this batch or an existing node id.
ops[].targetstringEnd of a relate fact; a key from this batch or an existing node id.
ops[].factstringThe relationship in one sentence for relate, at most 280 characters.
ops[].originstringWhere a relate fact came from; the relation type must accept this origin.
ops[].edgestringRelation id an invalidate operation acts on, from relations.list or an earlier operation in this batch.
ops[].invalid_atstringWorld time an invalidate operation marks the fact as no longer true.
ops[].bystringRelation id that replaces the invalidated one, when a successor was recorded; omit when nothing replaced it.
ops[].reasonstringWhy the operation was applied, kept for people reading the history; not enforced.
ops[].fromstringNode id a merge operation folds away, resolving to the into node afterwards.
ops[].intostringNode id a merge operation keeps, receiving the merged node’s relations and aliases.
ops[].nodestringNode id an alias operation adds a name to.
ops[].aliasstringThe 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.