v1
latestOpenAPI 3.0.02026-07-26492143.5 KBSessions
Cancel session
Cancel an in-progress session. If the session is currently processing or queued, any running stream is aborted and the session is transitioned to failed. If the session is already completed or failed, its current state is returned unchanged.
The response carries a session envelope but only id, agent_id, and state are populated.
post/sessions/{session_id}/cancel
Path parameters
session_idstring required
ID of the session to cancel.
Response
Session state after the cancel attempt. Only id, agent_id, and state are populated on the session envelope.
Example response
{
"session": {
"id": "sess_xYz789AbCd",
"agent_id": "abc123DEFghiJKL",
"state": "failed",
"usage": {
"credit_cost": 12.5,
"tool_credit_cost": 4,
"flow_credit_cost": 1.5,
"input_tokens": 18432,
"output_tokens": 2043
}
}
}