Stop sessions
Ends a running session. `message` is recorded as the cancellation reason, which is what a later reader of the transcript sees.
POST /v1/agents/sessions/{id}/stop
| Address | https://api.hanzo.ai/v1/agents/sessions/{id}/stop |
| Method | POST |
| Operation | post_agents_sessions_by_id_stop |
| Auth | Authorization: Bearer $HANZO_API_KEY |
Ends a running session. message is recorded as the cancellation
reason, which is what a later reader of the transcript sees.
STOPPING IS NOT DELETING: the session, its transcript and anything it produced stay readable. A session that has already finished is 409 rather than a second stop.
Request
4 fields, body application/json (required).
| Field | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | ID is the session to steer, from the path. |
id | body | string | — | ID is the session to steer, from the path. |
message | body | string | — | Message is free text for the running agent, up to 16 KiB. |
payload | body | any | — | Payload is a structured argument for the command: any valid JSON up to 64 KiB, scanned for credentials before it is stored (a hit refuses the command with 422… |
Response
| Status | Body | Meaning |
|---|---|---|
200 | controlResult | ok |
200 body — 10 fields.
| Field | In | Type | Always | Description |
|---|---|---|---|---|
command | body | string | — | Command is the verb that was recorded: pause, resume, stop or message. |
event | body | eventView | — | |
event.actor | body | string | — | Actor is who produced the turn. |
event.createdAt | body | string | — | CreatedAt is when the turn was recorded, RFC 3339 in UTC to the second. |
event.id | body | string | — | ID is the event's own handle, minted as "evt_" + 32 hex characters. |
event.kind | body | string | — | Kind is what the turn IS, from a closed six: message (a model turn), tool-call, spawn (a subagent started), log, status, control (a steering command the… |
event.payload | body | any | — | Payload is the turn's body, embedded as JSON rather than as a string — whatever the writer sent, up to 64 KiB, checked for well-formedness and scanned for… |
event.seq | body | integer | — | Seq is the turn's position in this session's log: monotonic from 1, assigned by the store inside the insert, and unique PER SESSION rather than globally. |
event.sessionId | body | string | — | SessionID is the session this turn belongs to. |
forwarded | body | boolean | — | Forwarded is whether the command also reached the durable-execution engine. |
Failure carries the platform error shape — see Errors.
Examples
hanzo agents sessions stop <id>import { Configuration, AgentsApi } from 'hanzoai';
const api = new AgentsApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postAgentsSessionsByIdStop({ id: 'id', id: "<id>", message: "<message>" });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).post_agents_sessions_by_id_stop(id='id', id="<id>", message="<message>")cfg := cloud.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := cloud.NewAPIClient(cfg)
resp, _, err := client.AgentsAPI.PostAgentsSessionsByIdStop(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::post_agents_sessions_by_id_stop(&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).postAgentsSessionsByIdStop();curl -X POST https://api.hanzo.ai/v1/agents/sessions/<id>/stop \
-H "Authorization: Bearer $HANZO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"id": "<id>",
"message": "<message>"
}'MCP reaches agents through the agents tool, which names its 36 operations with its own verbs — this one among them, under a name only MCP 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?