Entities and branches

Everything an organization configures or records in Hilus is an entity: an agent, a document, a workflow, a call, a conversation. This guide shows how to read an entity, find text inside it, create one, change it with the two writers, and use its history to see what changed and bring an old version back. Every example works the same over HTTP, from Python or JavaScript, and with the hilus CLI.

How entities are stored

Three facts explain every call in this guide.

An entity is identified by its type (the class name, such as Agent or Document) and its id. Where one entity points at another, the reference is a typed object, {"entity_type": "Agent", "id": "agt_123"}, never a bare id string: the type is needed to resolve it.

Find the type and its fields

If you do not know which type holds what you need, describe the model. With no arguments, describe returns every entity type with a one-line summary; with names it returns those types in full, with their fields, their relationships to other types, and their tools.

curl -X GET "https://api.hilus.ai/Platform/entities/entity-graph?names=%5B%22Document%22%5D&include_tools=false" \
  -H "Authorization: Bearer $HILUS_API_KEY"

A query searches every type, field and tool by intent instead, which is the fastest way in when you only know what you want to do:

curl -X GET "https://api.hilus.ai/Platform/entities/entity-graph?query=greeting+the+caller+hears+first&limit=5" \
  -H "Authorization: Bearer $HILUS_API_KEY"

Each hit in matches names its entity type and, for a nested field, its path. To see one part of a large type in detail, pass that path to form_schema rather than paging through the whole tree. Querying data covers discovery in more depth.

Read an entity

get returns an entity as YAML, together with the commit it was read at and who may access it.

curl -X GET "https://api.hilus.ai/Platform/entities/Document/doc_123?branch=main" \
  -H "Authorization: Bearer $HILUS_API_KEY"

Response:

{
  "entity_type": "Document",
  "entity_id": "doc_123",
  "commit_id": "c1f0a9e2b7d44e1c9a07",
  "branch": "main",
  "yaml_content": "id: doc_123\nname: Office hours\nlines: |\n  # Office hours\n\n  Monday to Friday, 8am to 6pm.\n  Saturday, 9am to 1pm.\n",
  "access": {
    "owner": "user:usr_42",
    "acl": null,
    "acl_write": null,
    "can_write": true,
    "locked": false
  }
}

The YAML is meant for editing top-level fields: nested entities appear as {entity_type, id} stubs, and computed (when present) holds read-only derived values such as live URLs that are never written back.

Read one field. A long entity is expensive to read whole. Pass paths to get only the fields you need; a single path comes back as clean, line-numbered text whose numbers match the rest of the tools.

curl -X GET "https://api.hilus.ai/Platform/entities/Agent/agt_123?branch=main&paths=system_prompt" \
  -H "Authorization: Bearer $HILUS_API_KEY"

Read an old version. Pass a commit_id from the entity's history to read exactly that commit.

curl -X GET "https://api.hilus.ai/Platform/entities/Agent/agt_123?commit_id=c1f0a9e2b7d44e1c9a07" \
  -H "Authorization: Bearer $HILUS_API_KEY"

List entities of a type. list takes an HQL filter and pages with limit and offset. A select stage in the filter returns only those fields, which is much faster on wide types.

curl -X GET "https://api.hilus.ai/Platform/entities/Agent?branch=main&filter=name+ilike+%27%25front+desk%25%27+%7C+select+id%2C+name&limit=20" \
  -H "Authorization: Bearer $HILUS_API_KEY"

Search inside an entity

Before you change text, find it. search runs a case-insensitive regular expression over one entity and returns each matching line with its line number and the path of the field it sits in.

curl -X POST "https://api.hilus.ai/Platform/entities/Document/doc_123/search" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "pattern": "saturday",
  "branch": "main"
}'

Response:

{
  "entity_type": "Document",
  "entity_id": "doc_123",
  "matches": [
    {
      "line": 7,
      "text": "  Saturday, 9am to 1pm.",
      "jsonpath": "$.lines[4]"
    }
  ],
  "context": []
}

The jsonpath is indexed, so it converts directly to a patch pointer ($.lines[4] is /lines/4) or serves as the anchor of a text edit. A plain string works as a literal search; a phrase that YAML folded across two lines still matches, because the pattern is also tried against each field's unfolded value.

[!NOTE] Search returns only the matching lines and a little context, never a whole field. To read a whole long field, use get with paths.

Create an entity

The safe order is scaffold, validate, create.

scaffold returns a new entity's full YAML with every default filled in, correctly quoted, without storing anything:

curl -X POST "https://api.hilus.ai/Platform/entities/scaffold/Document" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "field_values": {
    "name": "Holiday closures"
  }
}'

Edit that YAML, then check it with validate, which runs the same validation as a real save and writes nothing:

curl -X POST "https://api.hilus.ai/Platform/entities/Document/doc_456/validate" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "yaml_content": "id: doc_456\nname: Holiday closures\nlines: |\n  # Holiday closures\n\n  Closed on public holidays.\n",
  "branch": "feature/new-hours"
}'

Then create it. Omit id to have one generated. A lines-based field such as a document's lines takes one block of text and is split into one line per newline, so you never build the array by hand. commit_message labels the commit in history.

curl -X POST "https://api.hilus.ai/Platform/entities/Document" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "branch": "feature/new-hours",
  "commit_message": "initial draft",
  "yaml_content": "name: Holiday closures\nlines: |\n  # Holiday closures\n\n  Closed on public holidays.\n"
}'

Response:

{
  "entity_id": "doc_456",
  "commit_id": "7b3c2d1e0f9a8b7c6d5e",
  "access": {
    "owner": "user:usr_42",
    "can_write": true,
    "locked": false
  }
}

[!WARNING] Some types cannot be created from YAML because creating them does something in the outside world: buying a phone number, registering a domain. create refuses them. Check the allocation block that describe returns for the type, then create it with allocate, which may purchase a real resource.

To start from an existing entity instead, copy makes an independent copy under a new id, on the same or another branch. Use it only when you want a second entity; to change an existing one, edit it on a branch.

Change a whole value with patch

There are two writers. patch is the default: it sets a value by JSON Pointer, with no text matching, so it is never ambiguous.

curl -X POST "https://api.hilus.ai/Platform/entities/Agent/patch" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ids": "agt_123",
  "branch": "feature/new-hours",
  "commit_message": "new voice",
  "ops": [
    {
      "op": "replace",
      "path": "/tts/voice_id",
      "value": "voice_calm_2"
    }
  ]
}'

Response:

{
  "entity_type": "Agent",
  "entity_id": "agt_123",
  "commit_id": "0a1b2c3d4e5f6a7b8c9d",
  "changed": true,
  "diff": [
    {
      "kind": "remove",
      "text": "-  voice_id: voice_warm_1"
    },
    {
      "kind": "add",
      "text": "+  voice_id: voice_calm_2"
    }
  ]
}

The ops are those of JSON Patch plus a few that avoid index counting:

Op Effect
replace, add Set path to value; add on a list index inserts, /list/- appends.
remove Delete what path points at, a key or a list index.
remove with value On a list, delete every element equal to value.
remove or replace with where On a list of objects, act on every element whose fields include where.
test Assert path equals value; a mismatch aborts the whole patch.

Removing list items by identity instead of position:

curl -X POST "https://api.hilus.ai/Platform/entities/Agent/patch" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ids": "agt_123",
  "branch": "feature/new-hours",
  "ops": [
    {
      "op": "remove",
      "path": "/documents",
      "where": {
        "id": "doc_789"
      }
    }
  ]
}'

Pass several ids to apply the same ops to each. The whole batch is validated first: if one entity fails, nothing is written.

Set a reference to another entity with the typed object, not a bare id:

curl -X POST "https://api.hilus.ai/Platform/entities/Agent/patch" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ids": "agt_123",
  "branch": "feature/new-hours",
  "ops": [
    {
      "op": "add",
      "path": "/documents/-",
      "value": {
        "entity_type": "Document",
        "id": "doc_456"
      }
    }
  ]
}'

[!NOTE] Always check changed in the response. An op that resolves to no actual change writes nothing and returns changed: false with commit_id: null; that is a successful call that stored nothing.

Change text inside a string with edit

edit is only for text within a string value: a sentence of a prompt, a line of a document. old must match exactly once; if it matches more often, pass anchor with the field (or the jsonpath from search) to scope it, or replace_all.

curl -X POST "https://api.hilus.ai/Platform/entities/Document/edit" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ids": "doc_123",
  "branch": "feature/new-hours",
  "anchor": "lines",
  "old": "Saturday, 9am to 1pm.",
  "new": "Saturday, 9am to 2pm.",
  "commit_message": "longer Saturday hours"
}'

You may pass a multi-line old exactly as search shows it; edit matches it against the field's unfolded value, so you never re-indent text to fit the YAML.

Append to a document

Lines-based entities such as documents have editing tools that persist on their own: append, insert, replace, delete_lines, move, find_and_replace and modify. Run them with execute_tool. Because they write, they need branch; a run that changes nothing stores nothing.

These tools number lines from 1, and a range includes both its start and its end line: replace with start 4 and end 4 replaces the fourth line only. find returns those numbers, and each edit answers with a diff that shows the lines it changed at their new numbers; after a large edit it shows the first of them and says how many it left out. A position inside a path, such as /lines/3 in a patch, is a different thing: it counts from 0, so it names the fourth line.

The ChatGPT app does not offer the general tool runner, because ChatGPT lists every operation as its own tool. There, change a document's lines with patch or edit instead. Claude, other MCP clients, the CLI and the API run the editing tools as shown here.

curl -X POST "https://api.hilus.ai/Platform/entities/Document/doc_456/execute-tool" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "tool_name": "append",
  "branch": "feature/new-hours",
  "commit_message": "added winter closure",
  "arguments": {
    "lines": "## Winter\n\nClosed from December 24 to January 1."
  }
}'

Response:

{
  "toolName": "append",
  "persisted": true,
  "commit_id": "5e4d3c2b1a0f9e8d7c6b",
  "handle": "tree-9gVb2kQ1"
}

Draft on the entity rather than locally: every save is a commit, so the iterations stay visible in history. The same route runs any other tool a type has (list_tools lists them); a tool that returns a file, such as a document's export, comes back as a handle plus media parts.

Work on a branch

To see what a branch actually holds, rather than what shows through from main, use branch_contents:

curl -X GET "https://api.hilus.ai/Platform/entities/branches?branch=feature%2Fnew-hours" \
  -H "Authorization: Bearer $HILUS_API_KEY"

To compare a branch with main type by type, use diff_branches. It lists what exists on only one side and the unified diffs of what diverged.

curl -X POST "https://api.hilus.ai/Platform/entities/diff-branches" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "entity_types": [
    "Agent",
    "Document"
  ],
  "branch": "main",
  "compare_branch": "feature/new-hours"
}'

See history and restore

history lists an entity's commits, newest first, with who made each one and its message.

curl -X GET "https://api.hilus.ai/Platform/entities/Document/doc_123/history?branch=main&limit=10" \
  -H "Authorization: Bearer $HILUS_API_KEY"

Response:

{
  "entity_type": "Document",
  "entity_id": "doc_123",
  "history": [
    {
      "commit_id": "0a1b2c3d4e5f6a7b8c9d",
      "committed_at": "2026-09-24T16:02:11Z",
      "committed_by": "user:usr_42",
      "commit_message": "longer Saturday hours"
    },
    {
      "commit_id": "c1f0a9e2b7d44e1c9a07",
      "committed_at": "2026-09-01T09:15:40Z",
      "committed_by": "user:usr_42",
      "commit_message": "initial draft"
    }
  ]
}

diff shows what a commit changed. last=1 is what the latest commit did; since diffs the state at a moment against now, which answers "what changed since Tuesday?":

curl -X GET "https://api.hilus.ai/Platform/entities/Document/doc_123/diff?since=2026-09-22&branch=main" \
  -H "Authorization: Bearer $HILUS_API_KEY"

To bring an old version back, restore stores that commit's content as a new commit on the branch. History is never rewritten: the restore is itself a commit you can undo.

curl -X POST "https://api.hilus.ai/Platform/entities/Document/doc_123/restore" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "commit_id": "c1f0a9e2b7d44e1c9a07",
  "branch": "feature/new-hours"
}'

Delete an entity

delete soft-deletes by default: the entity disappears from the branch, its commits stay, and restore brings it back. hard deletes permanently.

curl -X POST "https://api.hilus.ai/Platform/entities/Document/delete" \
  -H "Authorization: Bearer $HILUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ids": [
    "doc_456"
  ],
  "branch": "feature/new-hours"
}'

[!WARNING] Deleting a branch is a different route. delete removes entities; removing an abandoned branch is delete_branch, which previews by default and never touches main.

Next steps