Run a tool on one or more entities
POST /Platform/entities/{entity_type}/{entity_id}/execute-tool
Run a tool on one or more entities.
Use it to act in a connected system through the entity that holds the
connection: look up open booking slots, find a client's record, create
a task. list_tools shows what an entity type can do.
entity_id is a single id OR a list of ids. ONE id (incl. a 1-element
list) returns an ExecuteToolResponse. MANY ids run the SAME tool
across every entity IN PARALLEL and return a list of
ExecuteToolResponse -- one per entity (each tagged with its
entity_id), in input order. Best-effort: one entity failing does NOT
abort the others (each item carries its own success/error).
If the tool returns a dtype (image/audio/pdf/file) -- at the top level
or nested in a dict/list/pydantic model -- each is stored and surfaced
as viewable media in parts (images inline as base64; pdf/audio/file
as short-lived signed URLs), and result becomes the JSON return with
<attachment id="hash"/> markers in place. Non-dtype results are
returned unchanged. Media results carry persisted saved-file metadata
alongside the inline parts.
EDITING TOOLS (@tool(persists=True)) — the line tools on
lines-based entities (append, insert, replace,
delete_lines, move, modify, find_and_replace) PERSIST:
after a successful run the entity is stored as a new commit on the
branch it was loaded from. Change-gated — a no-op run (content hash
unchanged) stores nothing (persisted: false, commit_id: null);
a real edit returns persisted: true + the new commit_id.
Because this is a WRITE, an explicit branch is REQUIRED for
persisting tools (non-persisting tools keep the main default), and
an optional commit_message labels the commit in history.
A failed tool never stores.
Bulk persistence semantics: many-ids execution stays BEST-EFFORT
(one entity failing does not abort the others) — unlike bulk
patch/edit, which validate all-or-nothing. A bulk persisting
call may therefore commit to a subset; read each result's
persisted/commit_id.
Path parameters
entity_type: str. Entity class name.entity_id: str. A single entity id, or a list of ids to run the tool across (parallel; returns a list of results).
Body parameters
tool_name: optional str. Name of the@tool()method to run on the entity.arguments: optional dict. Keyword arguments passed to the tool (JSON object).branch: optional str. Hilus branch. Optional (defaults tomain) for read-only tools; REQUIRED for persisting/editing tools.max_workers: optional int. Max parallel workers for the many-ids case (default 8).mock: optional bool. Dry run. Setsentity.mock = Truebefore invoking, which short-circuits tools with a declaredmock_responseand ALL irreversible tools (they return"Success (mocked)"instead of executing). Read-only tools still execute against the real backend; entity types that checkself.mockinternally do their own no-side-effect handling. The response echoesmocked: trueso output is never mistaken for a real run.commit_message: optional str. Optional commit label for persisting tools.
Returns
Union[ExecuteToolResponse, List[ExecuteToolResponse]]
Example request
curl -X POST "https://api.hilus.ai/Platform/entities/{entity_type}/{entity_id}/execute-tool" \
-H "Authorization: Bearer $HILUS_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'