Replace text inside entity fields
POST /Platform/entities/{entity_type}/edit
Replace text inside entity fields. Use it for text WITHIN a string
value; patch sets whole values.
Two writers exist; pick by what you're changing:
patch(structured) is the DEFAULT for setting a whole field/value (a scalar or nested field). Immune to YAML line-folding and never ambiguous.edit(this one) is ONLY for changing text inside a string value: prose, a substring, one HTML/Markdown block, one item in a list-of-strings.
old must match exactly once (per entity) unless replace_all is set.
When old is not unique, do NOT paste a huge block -- pass anchor
(a field name or JSONPath, e.g. a or $.a.b) to scope the
replacement to that field's region. Run search first to find the
anchor.
Multi-line / block-scalar text: a long string that YAML stores as a
| / > block scalar is written with every continuation line
indented to the block. You may pass a multi-line old exactly as
search shows it (the logical, unfolded value) -- edit matches it
against the field's logical value and re-serializes, so you never
hand-indent old to the YAML block.
A plain List[string] field renders as a single | literal block
scalar -- one physical line per list item, reading like a plain markdown
document (no - type: string / value: wrapper). To change one
line, edit that line's text with a unique old (use search
first); to add/remove/replace whole lines, prefer patch against the
array index. Authoring note: such a field may be written as one |
block and it is split into one line per newline on load.
Bulk: pass multiple ids to apply the SAME edit across all of them. The
edit is validated against EVERY entity first; if any fails validation
NOTHING is written (all-or-nothing at the validation boundary). Each
successful entity is its own commit.
Do not use text editing to retarget an entity reference. Use patch
with the typed object {"entity_type": "Agent", "id": "..."};
bare ID strings do not identify a concrete entity class.
Path parameters
entity_type: str. Entity class name.
Body parameters
ids: str. One or more entity IDs, single id or list (bulk = all-or-nothing validation).old: str. Exact text to replace.new: str. Replacement text.branch: optional str. Hilus branch (defaultmain).anchor: optional str. Optional field/JSONPath scope so a non-uniqueoldis disambiguated by naming the field.replace_all: optional bool. Replace every occurrence (default: require exactly one).commit_message: optional str. Optional commit label shown inhistory(e.g. "fixed voice_id typo"). Recommended for iterative document work so history reads as a change log.
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}/edit" \
-H "Authorization: Bearer $HILUS_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'