> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.itential.com/itential-cloud/api-reference/agent-session-manager/update-session-state/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.itential.com/_mcp/server. # Update session state POST https://example.itential.io/agent-session-manager/sessions/{sessionId} Content-Type: application/json Updates the state of an agent session, such as canceling, pausing, or resuming it. Reference: https://docs.itential.com/itential-cloud/api-reference/agent-session-manager/update-session-state ## Authentication - `Authorization` header (basic auth, required) — Basic authentication of the form `Basic `. ## Request ### Path parameters - `sessionId` (string, required) — sessionId ### Body (application/json) This endpoint expects an object. - `action` (enum, optional) — The action to perform on the session - Allowed values: `CANCEL`, `PAUSE`, `RESUME` - `canceledBy` (string, optional) — User performing the action - `correlationId` (string, optional) — Correlation ID for request tracing. ## Response ### 200 result - `agentDefinitionId` (string, required) — The agent definition ID - `status` (enum, required) — Current session status - Allowed values: `PENDING`, `RUNNING`, `PAUSING`, `PAUSED`, `COMPLETE`, `FAILED`, `CANCELING`, `CANCELED` - `createdAt` (string, required) — Session creation timestamp - `createdBy` (string, required) — User who created the session - `sessionId` (string, optional) — The session ID assigned by AEE - `agentSnapshot` (object, optional) — Snapshot of the agent configuration at session start time - `_id` (string, required) — Agent definition ID - `name` (string, required) — Agent name - `description` (string, required) — Agent description - `instructions` (string, required) — Agent instructions - `namespace` (object, optional) — Parent project namespace info - `_id` (string, required) — Project UUID - `name` (string, required) — Project name - `startedAt` (string, optional) — Session start timestamp (engine-authoritative) - `endTime` (string, optional) — Session end timestamp - `duration` (double, optional) — Session duration in milliseconds - `provider` (string, optional) — Infrastructure provider (e.g. aws, gcp) - `modelVersion` (string, optional) — Model version used - `sessionType` (enum, optional) — Session type - Allowed values: `root`, `child` - `trigger` (object, optional) — Trigger context for trigger-fired sessions. source is the name of the firing user for manual triggers, or set as the name of the trigger for all other trigger types. - `type` (enum, required) — Trigger type that started the session - Allowed values: `eventSystem`, `endpoint`, `schedule`, `manual`, `job`, `session` - `name` (string, required) — Name of the trigger that fired the session - `source` (string, required) — For manual and API triggers, the username of the person who started the session. For schedule and event triggers, the name of the trigger. - `canceledBy` (string, optional) — User who canceled the session - `errorMessage` (string, optional) — Error message if session failed - `errorCategory` (string, optional) — Error category if session failed - `durationMs` (double, optional) — Session duration in milliseconds - `iterationCount` (double, optional) — Number of inference iterations - `toolGroupCount` (double, optional) — Number of tool groups dispatched - `totalToolCallCount` (double, optional) — Total number of tool calls made - `totalInputTokens` (double, optional) — Total input tokens consumed across all inferences - `totalOutputTokens` (double, optional) — Total output tokens produced across all inferences - `totalTokens` (double, optional) — Combined total tokens consumed across all inferences (input + output) - `inputs` (object, optional) — Inputs passed when starting the session ## Errors ### 500 Internal Server Error Error response from API - `any` ## Examples **Request** ```json {} ``` **Response** ```json { "agentDefinitionId": "string", "status": "PENDING", "createdAt": "2024-01-15T09:30:00Z", "createdBy": "string", "sessionId": "string", "agentSnapshot": { "_id": "string", "name": "string", "description": "string", "instructions": "string", "namespace": { "_id": "string", "name": "string" } }, "startedAt": "2024-01-15T09:30:00Z", "endTime": "2024-01-15T09:30:00Z", "duration": 1.1, "provider": "string", "modelVersion": "string", "sessionType": "root", "trigger": { "type": "eventSystem", "name": "string", "source": "string" }, "canceledBy": "string", "errorMessage": "string", "errorCategory": "string", "durationMs": 1.1, "iterationCount": 1.1, "toolGroupCount": 1.1, "totalToolCallCount": 1.1, "totalInputTokens": 1.1, "totalOutputTokens": 1.1, "totalTokens": 1.1, "inputs": {} } ``` **SDK Code** ```python import requests url = "https://example.itential.io/agent-session-manager/sessions/sessionId" payload = {} headers = {"Content-Type": "application/json"} response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://example.itential.io/agent-session-manager/sessions/sessionId'; const options = {method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{}'}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://example.itential.io/agent-session-manager/sessions/sessionId" payload := strings.NewReader("{}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://example.itential.io/agent-session-manager/sessions/sessionId") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Content-Type"] = 'application/json' request.body = "{}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://example.itential.io/agent-session-manager/sessions/sessionId") .header("Content-Type", "application/json") .body("{}") .asString(); ``` ```php request('POST', 'https://example.itential.io/agent-session-manager/sessions/sessionId', [ 'body' => '{}', 'headers' => [ 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://example.itential.io/agent-session-manager/sessions/sessionId"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["Content-Type": "application/json"] let parameters = [] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://example.itential.io/agent-session-manager/sessions/sessionId")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```