Updates a session's surface-owned truth: its status, its title, the run-target…
Updates a session's surface-owned truth: its status, its title, the run-target it is dispatched to, and the product it built plus whether that build's…
PATCH /v1/agents/sessions/{id}
| Address | https://api.hanzo.ai/v1/agents/sessions/{id} |
| Method | PATCH |
| Operation | patch_agents_sessions_by_id |
| Auth | Authorization: Bearer $HANZO_API_KEY |
Updates a session's surface-owned truth: its status, its title, the run-target it is dispatched to, and the product it built plus whether that build's story is public. A FINISHED session stays finished — reopening a done/error run would fabricate liveness — and publishing is refused unless the session names the project it built, because the public build route is keyed on (org, project).
Request
9 fields, body application/json (required).
| Field | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | ID is the session to update, from the path. |
cwd | body | string | — | Cwd is where the session is working NOW. It was write-once — captured at register and never again — which is right for a run that starts in a directory and… |
id | body | string | — | ID is the session to update, from the path. |
project | body | string | — | Project tags the product this session built; Published is the author's decision to let anyone read the story (provenance.go). |
published | body | boolean | — | Published opens the session's story to the public build route; false withdraws it, and withdrawing is always allowed. |
status | body | string | — | Status moves the session to running, paused, done or error. |
target | body | string | — | Target re-dispatches a session to a run-target (the #48 association). |
terminal | body | string | — | Terminal publishes (or, with "", withdraws) the URL this session's live terminal can be watched at. |
title | body | string | — | Title rewrites the human line, up to 512 characters — usually because the work turned out to be something other than what it was opened as. |
Response
| Status | Body | Meaning |
|---|---|---|
200 | sessionView | ok |
200 body — 31 fields.
| Field | In | Type | Always | Description |
|---|---|---|---|---|
account | body | string | — | Account is which subscription or API account under that provider served it. |
actor | body | string | — | Actor is WHO this session belongs to, as "org/sub" — the same identity a run is billed under. A register that names none takes the calling principal. |
agent | body | string | — | Agent is the label the surface running this session calls itself by ("hanzo-dev"), up to 128 characters. Required at register. |
children | body | integer | — | Children is the DIRECT fan-out — how many sessions name this one as parent — and not the size of the subtree. |
createdAt | body | string | — | CreatedAt is when the row was written, same format. |
cwd | body | string | — | Cwd is the directory the session is working in NOW, not the one it started in: a linked shell moves around, and a card showing where hanzo link was run… |
endedAt | body | string | — | EndedAt is when it reached done or error, same format. |
events | body | integer | — | Events is how many turns the session's log holds, counted at read time. |
host | body | string | — | Execution context (mission-control): the machine/repo/cwd a card shows and the run-target a session is dispatched to. |
id | body | string | — | ID is the session's handle, minted here as "sess_" + 32 hex characters. |
lastEvent | body | lastEventView | — | |
lastEvent.actor | body | string | — | Actor is who produced the turn, defaulted to the calling principal when the writer named nobody. |
lastEvent.at | body | string | — | At is when the turn was recorded, RFC 3339 in UTC to the second. |
lastEvent.kind | body | string | — | Kind is what the turn was, from the log's closed six: message, tool-call, spawn, log, status, control. |
lastEvent.preview | body | string | — | Preview is the first 240 bytes of the event's payload, cut without regard for the JSON inside it — it is a string to SHOW, never a value to parse. |
lastEvent.seq | body | integer | — | Seq is that event's position in the session's log — monotonic from 1, per session. |
org | body | string | — | Org is the caller's OWN tenant, echoed so a client can build the public build URL (/builds/:org/:project) without a second call or a guess. |
parentSessionId | body | string | — | ParentSessionID is the session that spawned this one, making this a subagent of it. Empty means this session is a root — a flow of its own. |
project | body | string | — | The readable build: the product this session built and whether its story is public (provenance.go). |
provider | body | string | — | Provider is the linked AI account's provider (claude | codex | hanzo | …) that served this run. |
published | body | boolean | — | Published is the author's decision to let anyone read this session's story at the public build route. |
repo | body | string | — | Repo is the code the session is working on, as the surface reported it. |
rootSessionId | body | string | — | RootSessionID is the top of this session's tree, inherited from the parent and shared by every node in one flow. |
startedAt | body | string | — | StartedAt is when the session opened, RFC 3339 in UTC to the second. |
status | body | string | — | Status is one of exactly four: running, paused, done, error. |
target | body | string | — | Target is the registered run-target this session is dispatched to — a machine the org claimed, resolved same-org when it was set, so it can never point at… |
taskRunId | body | string | — | TaskRunID is that workflow's particular run. |
taskWorkflowId | body | string | — | TaskWorkflowID is the hanzoai/tasks durable workflow that actually EXECUTES this session — this registry is the view, control and stream layer over it. |
terminal | body | string | — | Terminal is where this session can be WATCHED — the URL the machine published for its live terminal. |
title | body | string | — | Title is the human line a card shows ("ship the landing page"), up to 512 characters. |
updatedAt | body | string | — | UpdatedAt is the session's last-activity clock, same format. |
Failure carries the platform error shape — see Errors.
Examples
hanzo agents sessions update <id>import { Configuration, AgentsApi } from 'hanzoai';
const api = new AgentsApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.patchAgentsSessionsById({ id: 'id', cwd: "<cwd>", id: "<id>" });from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import AgentsApi
client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = AgentsApi(client).patch_agents_sessions_by_id(id='id', cwd="<cwd>", id="<id>")cfg := cloud.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := cloud.NewAPIClient(cfg)
resp, _, err := client.AgentsAPI.PatchAgentsSessionsById(context.Background()).Execute()
if err != nil {
return err
}use hanzo_cloud::apis::{configuration::Configuration, agents_api};
let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();
let result = agents_api::patch_agents_sessions_by_id(&cfg, Default::default()).await?;import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.AgentsApi;
ApiClient client = new ApiClient();
client.setRequestInterceptor(b -> b.header("Authorization", "Bearer " + System.getenv("HANZO_API_KEY")));
var result = new AgentsApi(client).patchAgentsSessionsById();curl -X PATCH https://api.hanzo.ai/v1/agents/sessions/<id> \
-H "Authorization: Bearer $HANZO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"cwd": "<cwd>",
"id": "<id>"
}'The door reaches agents through the agents tool, which names its 36 operations with its own verbs — this one among them, under a name only the door declares. describe explains any of them:
curl -X POST https://api.hanzo.ai/v1/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "describe",
"arguments": {
"op": "list_agent_conversations"
}
}
}'How is this guide?