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

Body parameters

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 '{}'