Set entity fields by JSON Pointer
POST /Platform/entities/{entity_type}/patch
Set entity fields by JSON Pointer. The DEFAULT writer for whole-value edits.
Use it to change a setting or a fact on an entity: an agent's opening hours, a workflow's answer, a document's title.
Sets a scalar or nested field to a new value by JSON Pointer (/a/b).
No text matching, so it's immune to YAML line-folding and never
ambiguous. Prefer over edit unless you're changing text inside a
string.
Ops — each is {"op", "path", "value"?, "match"?}:
replace / add: set path to value (add on a list index
inserts; /arr/- appends).
remove: delete what path points at — a dict key, or a list element by
index (e.g. /arr/2).
test: assert path equals value, changing nothing; a mismatch
aborts the WHOLE patch (even in bulk). Pair test + remove on an
index for a safe "remove only if it's the value I expect".
remove by value: on an ARRAY path, remove WITH a value deletes
every element equal to it, e.g.
{"op":"remove","path":"/arr","value":"foo"} (with NO value it
deletes the whole array).
replace by match: on an ARRAY path, replace WITH a match rewrites
every element equal to match to value (with only value it
overwrites the whole array). By-value ops raise if nothing matches.
remove/replace by where: on an ARRAY path, where is a dict of
top-level field values and matches every dict element whose fields are
a SUPERSET of it (shallow subset match). The index-free way to delete
list items by identity — no index counting, no shifting:
{"op":"remove","path":"/fields","where":{"group":"group_a"}}
or {"op":"remove","path":"/fields","where":{"id":"item_1"}}.
replace + where + value sets each matching element to
value. Raises if nothing matches.
Bulk (multiple ids): the same ops apply to all, validated
all-or-nothing before any write.
A string-array field that renders as a single | block scalar is still
indexed as its logical line array (/<field>/2, /<field>/-);
indexing is stable regardless of the rendered form.
Path checking: the FIRST segment must be a real field on the entity type
(or a key already present in its YAML). A misspelled or non-existent
field is rejected up front with the available field list, rather than
being silently dropped — entity models ignore unknown keys, so such an op
would otherwise store nothing. Deeper segments are not pre-checked
(sub-model fields, list indices, /arr/- and arbitrary keys inside
Dict[str, Any] fields are all legitimate), but after validation
each directly-addressed replace/add op is verified against the
stored result: an op whose effect was stripped (e.g. an unknown member
on a nested sub-model) fails the whole patch instead of landing as a
silent no-op.
Check changed on the response, not just success: an op that
survives path checking but still resolves to no actual change writes
nothing and returns changed: false with commit_id: null.
Entity references are JSON/YAML objects, never bare IDs:
{"entity_type": "Agent", "id": "..."}. Use the concrete type
required by the field; a bare string resolves without type information
and cannot satisfy fields such as Agent-or-SimpleAgent.
Path parameters
entity_type: str. Entity class name.
Body parameters
ids: str. One or more entity IDs (bulk = all-or-nothing).ops: List[Any]. List of{"op": "replace"|"add"|"remove"|"test", "path": "/a/b", "value"?: ..., "match"?: ...}.branch: optional str. Hilus branch (defaultmain).commit_message: optional str. Optional commit label shown inhistory.expected_commit_id: optional str. The commit you read (getreturns it). If set, the patch is refused unless it is still the entity's commit onbranch. Single id only.
Returns
EntityEditResponse
entity_type: optional str or null. Entity class name.entity_id: optional str or null. Entity id (single-id calls).commit_id: optional str or null. New commit; None when nothing was written.yaml_content: optional str or null. The entity's YAML after the write.diff: optional List[dict]. Structured diff hunks: kind, text.count: optional int or null. Replacements made (text edits).changed: optional bool. False when the write was a no-op: nothing was stored and commit_id is None.note: optional str or null. Why nothing changed, when changed is false.ignored_changes: optional List[dict]. Requested paths that validation ignored or normalized.access: optional EntityAccess or null. Access after the write (single-id calls).warnings: optional List[str]. Non-blocking problems the entity type reports about what was stored.results: optional List[dict] or null. Per-entity results when several ids were given: id, commit_id, changed, diff, note.
Example request
curl -X POST "https://api.hilus.ai/Platform/entities/{entity_type}/patch" \
-H "Authorization: Bearer $HILUS_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'