Create message

Sends a steering message to a running session — the endpoint a human or another agent interrupts through.

POST /v1/agent/sessions/{id}/message

Addresshttps://api.hanzo.ai/v1/agent/sessions/{id}/message
MethodPOST
Operationpost_agent_sessions_by_id_message
AuthAuthorization: Bearer $HANZO_API_KEY

Sends a steering message to a running session — the endpoint a human or another agent interrupts through. It requires a message or a payload; the other three commands do not.

A chat turn's run READS it: the message is handed to the model as the person's next words at its next step, and a message that arrives while the model is writing its answer gets a step of its own before the answer stands. A turn that has already answered takes no more and answers 409 — what is said after an answer is a new turn.

Request

4 fields, body application/json (required).

FieldInTypeRequiredDescription
idpathstringyesID is the session to steer, from the path.
idbodystring—ID is the session to steer, from the path.
messagebodystring—Message is free text for the running agent, up to 16 KiB.
payloadbodyany—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 and the findings).

Response

StatusBodyMeaning
200agent.controlResultok
defaultproblem-detailsrefused

200 body — 11 fields.

FieldInTypeAlwaysDescription
commandbodystring—Command is the verb that was recorded: pause, resume, stop or message.
eventbodyagent.eventView—
event.actorbodystring—Actor is who produced the turn.
event.createdAtbodystring—CreatedAt is when the turn was recorded, RFC 3339 in UTC to the second.
event.idbodystring—ID is the event's own handle, minted as "evt_" + 32 hex characters.
event.kindbodystring—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 running surface consumes).
event.payloadbodyany—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 credentials before it was stored.
event.seqbodyinteger (int64)—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.sessionIdbodystring—SessionID is the session this turn belongs to.
forwardedbodyboolean—Forwarded is whether the command also reached the durable-execution engine.
runbodystring—Run is the run a resume started, under the same session.

Failure carries the platform error shape — see Errors.

Examples

hanzo agent sessions message <id>
import { Configuration, AgentApi } from 'hanzoai';

const api = new AgentApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postAgentSessionsByIdMessage({ id: 'id', id: "<id>", message: "<message>" });
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import AgentApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = AgentApi(client).post_agent_sessions_by_id_message(id='id', id="<id>", message="<message>")
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.AgentAPI.PostAgentSessionsByIdMessage(context.Background()).Execute()
if err != nil {
	return err
}
use hanzo_client::apis::{configuration::Configuration, agent_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = agent_api::post_agent_sessions_by_id_message(&cfg, Default::default()).await?;
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.AgentApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new AgentApi(client).postAgentSessionsByIdMessage();
curl -X POST https://api.hanzo.ai/v1/agent/sessions/<id>/message \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "id": "<id>",
       "message": "<message>"
     }'

MCP reaches agent through the agent tool, which names its 38 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_agents"
         }
       }
     }'

Agent API · All Hanzo APIs · Interactive reference

Was this page useful?