KsADK

Agent Web API

Sessions, runs, history, interactions, files, feedback, and MCP OAuth for Agent chat interfaces

Overview

Use this reference to build an Agent chat interface: initialize capabilities, manage sessions, read history, run conversations, resume execution, handle interactions, access files, submit feedback, and complete MCP OAuth authorization. Optional file-preview and native-terminal endpoints are documented separately.

Paths are relative to the Agent access URL supplied by the service. Read the capabilities first and use only features declared by the current deployment.

Requests and authentication

ItemConvention
Base URLUse the access URL provided by the Agent service
AuthenticationAutomation clients supply Authorization: Bearer API_KEY as required by the service; browser clients may use an established access session
JSONContent-Type: application/json
StreamingAccept: text/event-stream and Stream=true where required
Uploadmultipart/form-data; the HTTP client generates the boundary
Field namesJSON and query parameter names are case-sensitive

AgentId, UserId, and SessionId locate resources but do not grant authorization. Request, session, invocation, run, checkpoint, and model-response IDs have distinct meanings and are not interchangeable.

Responses and errors

Ordinary JSON Actions use this success envelope:

{"Code":0,"Message":"Success","RequestId":"req-example","Action":"CreateSession","Data":{"Session":{"SessionId":"session-example","AgentId":"agent-example","UserId":"user-example"}}}

Data depends on the operation. MCP OAuth success responses do not guarantee RequestId or Action. Downloads return raw bytes; SSE is an incremental event stream rather than one JSON response.

ResultClient handling
HTTP 400 / 422Check fields, types, bounds, and field combinations
HTTP 401 / 403Re-establish a valid access session or correct permissions; do not blindly replay operations
HTTP 404Check identifiers, ownership, and whether the feature is enabled
HTTP 409Refresh revision or history state; changing an idempotency key is not a safe automatic retry
HTTP 429Handle rate or queue limits using the service retry guidance
HTTP 503 / 504Retry eligible reads; establish the outcome of a write before repeating it
HTTP 200 with Code other than 0Treat as a business failure and inspect Message, ReasonCode, or detail

Errors may use Message, ReasonCode, detail, or error. An expired browser access session can also produce an HTML 401/403 response; do not treat it as normal API JSON.

Endpoint directory

Method and pathPurpose
POST /agentengine/api/v1/GetAgentUiBootstrapGet UI capabilities
POST /agentengine/api/v1/ListAgentModelsList models
POST /agentengine/api/v1/CreateSessionCreate a session
POST /agentengine/api/v1/ListSessionsList sessions
POST /agentengine/api/v1/GetSessionGet a session
POST /agentengine/api/v1/DeleteSessionDelete a session
POST /agentengine/api/v1/ListSessionMessagesRead chat history
POST /agentengine/api/v1/ListSessionEventsRead session events
POST /agentengine/api/v1/RunAgentRun an Agent
GET /agentengine/api/v1/SubscribeRunEventsSubscribe to run events
POST /agentengine/api/v1/CancelRunCancel a run
POST /agentengine/api/v1/ListSessionCheckpointsList checkpoints
POST /agentengine/api/v1/GetCheckpointResumePreviewPreview checkpoint recovery
POST /agentengine/api/v1/ResumeRunResume a run
POST /agentengine/api/v1/ListToolReceiptsList tool receipts
POST /agentengine/api/v1/SubmitInteractionSubmit an interaction
POST /agentengine/api/v1/UploadFileUpload an attachment
GET /agentengine/api/v1/AttachmentContentDownload an attachment
POST /agentengine/api/v1/ListWorkspaceFilesList workspace files
POST /agentengine/api/v1/AddWorkspaceFileUpload a workspace file
POST /agentengine/api/v1/DeleteWorkspaceFileDelete a workspace file
GET /agentengine/api/v1/GetWorkspaceFileContentDownload a workspace file
GET /agentengine/api/v1/ExportWorkspaceZipExport a workspace directory
POST /agentengine/api/v1/GetResponseFeedbackGet response feedback
POST /agentengine/api/v1/UpsertResponseFeedbackSave response feedback
POST /agentengine/api/v1/DeleteResponseFeedbackDelete response feedback
POST /agentengine/api/v1/GetMcpAuthorizationWaitGet authorization state
POST /agentengine/api/v1/OpenMcpAuthorizationOpen authorization
POST /agentengine/api/v1/RetryMcpAuthorizationRetry authorization
POST /agentengine/api/v1/RetryMcpConnectionRetry MCP connection
POST /agentengine/api/v1/CancelMcpAuthorizationWaitCancel authorization wait
POST /agentengine/aguiAG-UI conversation

Identifiers in the examples are placeholders; replace them with values returned by your service.

Initialization

Get UI capabilities

POST /agentengine/api/v1/GetAgentUiBootstrap

Initialize the client with Agent identity, available chat transports, history, recovery, file, OAuth, and terminal capabilities.

ParameterLocationTypeRequiredDefaultDescription
AgentIdbodystring / nullNonullTarget Agent identifier.
SessionIdbodystring / nullNonullSession identifier.

Example request:

{"AgentId":"agent-example"}

Response: Data.Agent contains Agent metadata; Capabilities contains feature declarations; HostedChat contains available transports; ApiFormats lists output formats; WorkspaceFiles describes file capabilities; SessionBackend describes session storage.

Use Capabilities to decide which controls to display. Obtain the AG-UI Endpoint from HostedChat.Transports.

List models

POST /agentengine/api/v1/ListAgentModels

Read the available model catalog and current selection.

ParameterLocationTypeRequiredDefaultDescription
AgentIdbodystring / nullNonullTarget Agent identifier.
Namebodystring / nullNonullCompatibility field; the current model catalog is determined by the Agent runtime configuration.

Example request:

{"AgentId":"agent-example"}

Response: Data.Models is the model array; Current is the current model; Source identifies the catalog origin.

Sessions and history

Create a session

POST /agentengine/api/v1/CreateSession

Create a session. An explicitly supplied existing SessionId is handled according to the service session policy.

ParameterLocationTypeRequiredDefaultDescription
AgentIdbodystringYes—Target Agent identifier.
UserIdbodystring / nullNo"user"Logical user identifier; authorization is still enforced by the authenticated identity.
SessionIdbodystring / nullNonullSession identifier.

Example request:

{"AgentId":"agent-example"}

Response: Data.Session is a Session object.

List sessions

POST /agentengine/api/v1/ListSessions

Read sessions for an Agent using page-based pagination.

ParameterLocationTypeRequiredDefaultDescription
AgentIdbodystringYes—Target Agent identifier.
UserIdbodystring / nullNonullLogical user identifier; authorization is still enforced by the authenticated identity.
PagebodyintegerNo1Page number, starting at 1. minimum 1.
PageSizebodyintegerNo20Number of sessions per page. minimum 1; maximum 1000.

Example request:

{"AgentId":"agent-example","Page":1,"PageSize":20}

Response: Data contains Sessions, Total, Page, and PageSize; it may also include DataSource, Degraded, and SessionContractVersion.

Keep AgentId, UserId, and PageSize consistent across pages. Omitting UserId does not grant cross-user access.

Get a session

POST /agentengine/api/v1/GetSession

Read session metadata and its current or most recent run information.

ParameterLocationTypeRequiredDefaultDescription
SessionIdbodystringYes—Session identifier.
AgentIdbodystring / nullNonullTarget Agent identifier.
UserIdbodystring / nullNonullLogical user identifier; authorization is still enforced by the authenticated identity.

Example request:

{"AgentId":"agent-example","SessionId":"session-example"}

Response: Data.Session is a Session object.

Delete a session

POST /agentengine/api/v1/DeleteSession

Delete a session and associated records, cancelling its outstanding detached streams.

ParameterLocationTypeRequiredDefaultDescription
SessionIdbodystringYes—Session identifier.
AgentIdbodystring / nullNonullTarget Agent identifier.
UserIdbodystring / nullNonullLogical user identifier; authorization is still enforced by the authenticated identity.

Example request:

{"AgentId":"agent-example","SessionId":"session-example"}

Response: Data.Deleted is true on successful deletion.

Read chat history

POST /agentengine/api/v1/ListSessionMessages

Read projected chat messages, with backward pagination and incremental queries.

ParameterLocationTypeRequiredDefaultDescription
AgentIdbodystring / nullNonullTarget Agent identifier.
UserIdbodystring / nullNonullLogical user identifier; authorization is still enforced by the authenticated identity.
SessionIdbodystringYes—Session identifier.
AfterSeqIdbodyinteger / nullNonullRead events or messages after this sequence number. minimum 0.
BeforeSeqIdbodyinteger / nullNonullRead events or messages before this sequence number. minimum 1.
LimitbodyintegerNo50Maximum number of returned items. minimum 1; maximum 200.
IncludeReasoningbodybooleanNofalseInclude reasoning content that the service permits returning.
IncludeToolEventsbodybooleanNofalseInclude tool execution events.
IncludeAttachmentsbodybooleanNotrueInclude attachment metadata.
HistoryEpochbodystring / nullNonullHistory epoch returned by the preceding response.
CursorSourcebodystring / nullNonullCursor source returned by the preceding response. allowed runtime, control.
SnapshotSeqIdbodyinteger / nullNonullHistory snapshot sequence returned by the preceding response. minimum 0.

Example request:

{"AgentId":"agent-example","SessionId":"session-example","Limit":50,"IncludeReasoning":false}

Response: Data contains SessionId, Messages, LatestSeqId, HasMore, NextCursor, and history context such as HistoryEpoch, SnapshotSeqId, and CursorSource.

Reuse the returned CursorSource, HistoryEpoch, and SnapshotSeqId. When the service requires a history reload, discard the old cursor before querying again.

Read session events

POST /agentengine/api/v1/ListSessionEvents

Read events for progress recovery, tool results, and the event timeline.

ParameterLocationTypeRequiredDefaultDescription
AgentIdbodystring / nullNonullTarget Agent identifier.
SessionIdbodystring / nullNonullSession identifier.
UserIdbodystring / nullNonullLogical user identifier; authorization is still enforced by the authenticated identity.
CheckpointIdsbodyarray<string>No[]Filter by checkpoint identifiers.
EventTypesbodyarray<string>No[]Filter by event type; an empty array disables this filter.
Offsetbodyinteger / nullNonullResult offset, starting at 0. minimum 0.
LimitbodyintegerNo200Maximum number of returned items. minimum 1; maximum 2000.
AfterSeqIdbodyinteger / nullNonullRead events or messages after this sequence number. minimum 0.
BeforeSeqIdbodyinteger / nullNonullRead events or messages before this sequence number. minimum 1.
EventOrderbodystring / nullNonullEvent ordering.
CursorSourcebodystring / nullNonullCursor source returned by the preceding response. allowed runtime, control.
HistoryEpochbodystring / nullNonullHistory epoch returned by the preceding response.
SnapshotSeqIdbodyinteger / nullNonullHistory snapshot sequence returned by the preceding response. minimum 0.

Example request:

{"AgentId":"agent-example","SessionId":"session-example","AfterSeqId":0,"Limit":200}

Response: Data contains Events, Total, Offset, Limit, and optional HasMore and history context.

Events can represent tool activity, status changes, or interactions; do not append every raw event as a chat message.

Conversations and runs

Run an Agent

POST /agentengine/api/v1/RunAgent

Execute a conversation turn synchronously, as SSE, or in a supported background mode.

ParameterLocationTypeRequiredDefaultDescription
AgentIdbodystringYes—Target Agent identifier.
Messagesbodyarray<object>No[]Message array containing role and content.
UserIdbodystring / nullNo"user"Logical user identifier; authorization is still enforced by the authenticated identity.
AccountIdbodystring / nullNonullAccount correlation identifier; not an authentication credential.
SessionIdbodystring / nullNonullSession identifier.
InvocationIdbodystring / nullNonullInvocation identifier used for event subscription and cancellation.
ApiFormatbodystringNo"responses"Output format: responses or chat_completions.
StreambodybooleanNofalseRequest SSE output.
BackgroundbodybooleanNofalseRequest background execution when supported.
Modelbodystring / nullNonullModel identifier selected from the model catalog.
ModelMetadatabodyobject / nullNonullModel capability metadata.
ModelOptionsbodyobject / nullNonullInference options supported by the selected model.
Metadatabodyobject / nullNonullAdditional request metadata; it does not grant identity or permissions.
ResponsesInputbodyJSON value / nullNonullResponses-style input, including multimodal or continuation input.
PreviousResponseIdbodystring / nullNonullIdentifier of the preceding Responses response.

Example request:

{"AgentId":"agent-example","SessionId":"session-example","InvocationId":"inv-example","Messages":[{"role":"user","content":"Hello"}],"ApiFormat":"responses","Stream":true}

Response: A synchronous foreground call wraps a Responses or Chat Completions result in Data. Streaming branches return SSE. See execution modes below.

For ordinary foreground streaming set Stream=true. Use Background=true only when the service declares support. Messages and ResponsesInput follow the selected input protocol; continuation input may also require PreviousResponseId. Disconnecting HTTP does not itself cancel a run; use CancelRun to stop it.

Execution modeResponse
Synchronous foregroundJSON Action; Data contains a model response
Streaming foregroundSSE, including possible failure or interaction-wait events
Background returning a handleJSON Action; Data contains SessionId, InvocationId, Status, Background, SubscribeUrl
Kernel-admitted streaming or backgroundSSE using Responses event projection; a JSON handle is not guaranteed

Subscribe to run events

GET /agentengine/api/v1/SubscribeRunEvents

Subscribe to incremental events for one session and invocation after reconnecting or starting a background run.

ParameterLocationTypeRequiredDefaultDescription
SessionIdquerystringYes—Session identifier.
InvocationIdquerystringYes—Invocation identifier used for event subscription and cancellation.
AfterSeqIdqueryintegerNo0Read events or messages after this sequence number.
AgentIdquerystring / nullNonullTarget Agent identifier.
UserIdquerystring / nullNonullLogical user identifier; authorization is still enforced by the authenticated identity.

Example request:

GET /agentengine/api/v1/SubscribeRunEvents?SessionId=session-example&InvocationId=inv-example&AfterSeqId=0
Authorization: Bearer <API_KEY>

Response: text/event-stream. Each data frame contains a SessionEvent; data: [DONE] terminates the subscription. SSE comments beginning with a colon are heartbeats.

Cancel a run

POST /agentengine/api/v1/CancelRun

Request cancellation by InvocationId.

ParameterLocationTypeRequiredDefaultDescription
AgentIdbodystring / nullNonullTarget Agent identifier.
UserIdbodystring / nullNonullLogical user identifier; authorization is still enforced by the authenticated identity.
SessionIdbodystring / nullNonullSession identifier.
InvocationIdbodystringYes—Invocation identifier used for event subscription and cancellation.

Example request:

{"AgentId":"agent-example","SessionId":"session-example","InvocationId":"inv-example"}

Response: Data.Cancelled indicates cancellation was requested or accepted; Found indicates whether a run was located; Status and RuntimeCancelStatus describe the cancellation state. Cancelled=true does not guarantee the task has already stopped.

Use the actual InvocationId. Requests carrying a trusted business identity must also provide AgentId and SessionId; other requests should provide both to scope cancellation. A response ID or CheckpointId cannot replace InvocationId.

Recovery and interactions

List checkpoints

POST /agentengine/api/v1/ListSessionCheckpoints

Read checkpoints for an Agent or selected sessions, filtered by recovery conditions.

ParameterLocationTypeRequiredDefaultDescription
AgentIdbodystringYes—Target Agent identifier.
SessionIdbodyarray<string> / string / nullNonullSession identifier.
UserIdbodystring / nullNonullLogical user identifier; authorization is still enforced by the authenticated identity.
CheckpointIdbodyarray<string> / string / nullNonullCheckpoint identifier returned by the checkpoint listing.
RunIdbodystring / nullNonullRun identifier.
OnlyResumablebodybooleanNofalseReturn only resumable checkpoints.
Frameworkbodystring / nullNonullFilter by framework.
ResumeStatusbodyarray<string>No[]Filter by resume status.
ResumeTypesbodyarray<string>No[]Filter by resume type.
Offsetbodyinteger / nullNonullResult offset, starting at 0. minimum 0.
LimitbodyintegerNo100Maximum number of returned items. minimum 1; maximum 1000.

Example request:

{"AgentId":"agent-example","SessionId":"session-example","OnlyResumable":true}

Response: Data contains Checkpoints, Total, ResumableTotal, and HasResumableCheckpoint.

Preview checkpoint recovery

POST /agentengine/api/v1/GetCheckpointResumePreview

Check whether a checkpoint can be resumed and inspect blocking reasons before submitting recovery.

ParameterLocationTypeRequiredDefaultDescription
AgentIdbodystringYes—Target Agent identifier.
UserIdbodystring / nullNonullLogical user identifier; authorization is still enforced by the authenticated identity.
SessionIdbodystringYes—Session identifier.
RunIdbodystringYes—Run identifier.
CheckpointIdbodystringYes—Checkpoint identifier returned by the checkpoint listing.

Example request:

{"AgentId":"agent-example","SessionId":"session-example","RunId":"run-example","CheckpointId":"checkpoint-example"}

Response: Data.Preview contains the recovery preview and admission result.

Resume a run

POST /agentengine/api/v1/ResumeRun

Resume execution from the specified session checkpoint.

ParameterLocationTypeRequiredDefaultDescription
AgentIdbodystringYes—Target Agent identifier.
UserIdbodystring / nullNonullLogical user identifier; authorization is still enforced by the authenticated identity.
SessionIdbodystringYes—Session identifier.
RunIdbodystringYes—Run identifier.
CheckpointIdbodystringYes—Checkpoint identifier returned by the checkpoint listing.
ResumeAttemptIdbodystring / nullNonullIdentifier for one resume attempt; reuse it when retrying the same attempt.
InvocationIdbodystring / nullNonullInvocation identifier used for event subscription and cancellation.
StreambodybooleanNofalseRequest SSE output.
BackgroundbodybooleanNofalseRequest background execution when supported.
Modelbodystring / nullNonullModel identifier selected from the model catalog.
ModelMetadatabodyobject / nullNonullModel capability metadata.
ModelOptionsbodyobject / nullNonullInference options supported by the selected model.
Metadatabodyobject / nullNonullAdditional request metadata; it does not grant identity or permissions.
ResumeInstructionEnabledbodybooleanNofalseEnable an additional resume instruction.
ResumeInstructionbodystring / nullNonullInstruction accompanying the resume request.

Example request:

{"AgentId":"agent-example","SessionId":"session-example","RunId":"run-example","CheckpointId":"checkpoint-example","ResumeAttemptId":"resume-example","Stream":true}

Response: Synchronous execution returns a JSON Action result; normal streaming recovery returns SSE. Background recovery returns a handle containing SessionId, RunId, CheckpointId, ResumeAttemptId, InvocationId, Status, Background, and SubscribeUrl. An already-processed retry can return Status=already_processed and AlreadyProcessed=true. A terminal checkpoint can return Status=noop and Reason. These branches can return JSON even when Stream=true; inspect Content-Type.

Call GetCheckpointResumePreview first. Use a new ResumeAttemptId for a distinct recovery attempt and keep it unchanged for retries of that same attempt.

List tool receipts

POST /agentengine/api/v1/ListToolReceipts

Read tool receipts associated with a run or checkpoint.

ParameterLocationTypeRequiredDefaultDescription
AgentIdbodystringYes—Target Agent identifier.
UserIdbodystring / nullNonullLogical user identifier; authorization is still enforced by the authenticated identity.
SessionIdbodystringYes—Session identifier.
RunIdbodystring / nullNonullRun identifier.
CheckpointIdbodystring / nullNonullCheckpoint identifier returned by the checkpoint listing.
OffsetbodyintegerNo0Result offset, starting at 0. minimum 0.
LimitbodyintegerNo200Maximum number of returned items. minimum 1; maximum 500.

Example request:

{"AgentId":"agent-example","SessionId":"session-example"}

Response: Data contains ToolReceipts, Total, Offset, and Limit. An uncertain receipt does not make replaying a side-effecting operation safe.

Submit an interaction

POST /agentengine/api/v1/SubmitInteraction

Submit an approval, rejection, structured answer, or cancellation decision.

ParameterLocationTypeRequiredDefaultDescription
AgentIdbodystringYes—Target Agent identifier.
UserIdbodystring / nullNonullLogical user identifier; authorization is still enforced by the authenticated identity.
SessionIdbodystringYes—Session identifier.
RunIdbodystringYes—Run identifier.
InteractionIdbodystringYes—Identifier of the pending interaction.
ExpectedRevisionbodyintegerYes—Current interaction or authorization-wait revision. minimum 1.
InteractionActionbodystringYes—Decision: approve, reject, submit, or cancel. allowed approve, reject, submit, cancel.
ResponsebodyJSON valueNonullAny valid JSON value; structured submission must explicitly include this field.
IdempotencyKeybodystringYes—Idempotency key; keep it unchanged when retrying the same submission. minLength 1; maxLength 256.

Example request:

{"AgentId":"agent-example","SessionId":"session-example","RunId":"run-example","InteractionId":"interaction-example","ExpectedRevision":1,"InteractionAction":"approve","Response":null,"IdempotencyKey":"interaction-example-approve"}

Response: Data is a command receipt with schema_version, command_id, status, and conditionally message_id, run_id, accepted_seq, or error.

This compatibility endpoint requires an active local Kernel; hosted deployments use their authorized interaction ingress. InteractionAction accepts approve, reject, submit, or cancel. Action is also accepted as a compatibility decision field. submit must explicitly include Response, including when its value is null. Use the current ExpectedRevision and preserve IdempotencyKey on retries. An accepted receipt can return HTTP 202 and a duplicate HTTP 200; accepted/duplicate means admitted, not fully executed.

Attachments and workspace

Upload an attachment

POST /agentengine/api/v1/UploadFile

Upload an image or document to obtain a reference usable in a later message.

ParameterLocationTypeRequiredDefaultDescription
fileformbinaryYes—File content to upload.

Example request:

curl --fail-with-body "$BASE_URL/agentengine/api/v1/UploadFile" -H "Authorization: Bearer $API_KEY" -F "file=@./example.txt"

Response: Data.FileData contains fileUri, displayName, mimeType, and sizeBytes.

Download an attachment

GET /agentengine/api/v1/AttachmentContent

Read content referenced by an uploaded file URI.

ParameterLocationTypeRequiredDefaultDescription
FileUriquerystringYes—File reference returned by UploadFile.
SessionIdquerystring / nullNonullSession identifier.
AgentIdquerystring / nullNonullTarget Agent identifier.
UserIdquerystring / nullNonullLogical user identifier; authorization is still enforced by the authenticated identity.

Example request:

GET /agentengine/api/v1/AttachmentContent?FileUri=file-example
Authorization: Bearer <API_KEY>

Response: Raw file bytes. Render or save according to Content-Type; do not parse an Action envelope.

Use the exact fileUri returned by UploadFile, not an arbitrary file path or external URL. Isolated attachments may require AgentId or SessionId to locate their access scope.

List workspace files

POST /agentengine/api/v1/ListWorkspaceFiles

Read entries in a workspace directory.

ParameterLocationTypeRequiredDefaultDescription
AgentIdbodystring / nullNonullTarget Agent identifier.
PathbodystringNo"."Path relative to the workspace root.
RecursivebodybooleanNofalseInclude entries in subdirectories.

Example request:

{"AgentId":"agent-example","Path":".","Recursive":false}

Response: Data includes directory information and an Entries array. Entries contain Name, Path, Type, SizeBytes, MimeType, and ModifiedAt.

Upload a workspace file

POST /agentengine/api/v1/AddWorkspaceFile

Write a file to a relative workspace path.

ParameterLocationTypeRequiredDefaultDescription
fileformbinaryYes—File content to upload.
AgentIdformstring / nullNonullTarget Agent identifier.
PathformstringYes—Path relative to the workspace root.

Example request:

curl --fail-with-body "$BASE_URL/agentengine/api/v1/AddWorkspaceFile" -H "Authorization: Bearer $API_KEY" -F "file=@./example.txt" -F "Path=notes/example.txt"

Response: Data.Entry contains Path, Name, Type, SizeBytes, MimeType, and ModifiedAt.

Use multipart/form-data and let the HTTP client generate the boundary. Path is the destination relative path; file carries the content.

Delete a workspace file

POST /agentengine/api/v1/DeleteWorkspaceFile

Delete a file at a relative workspace path.

ParameterLocationTypeRequiredDefaultDescription
AgentIdbodystring / nullNonullTarget Agent identifier.
PathbodystringYes—Path relative to the workspace root.

Example request:

{"AgentId":"agent-example","Path":"notes/example.txt"}

Response: Data.Deleted is true on success.

Download a workspace file

GET /agentengine/api/v1/GetWorkspaceFileContent

Read raw workspace file content for document, image, or text previews.

ParameterLocationTypeRequiredDefaultDescription
FilePathquerystringYes—Relative workspace path of the requested file.
AgentIdquerystring / nullNonullTarget Agent identifier.

Example request:

GET /agentengine/api/v1/GetWorkspaceFileContent?FilePath=notes%2Fexample.txt
Authorization: Bearer <API_KEY>

Response: Raw file bytes. Use Content-Type and the returned Content-Disposition to render or save the response.

FilePath is relative to the workspace; absolute paths and traversal outside the workspace are not allowed.

Export a workspace directory

GET /agentengine/api/v1/ExportWorkspaceZip

Export a workspace directory as a ZIP archive.

ParameterLocationTypeRequiredDefaultDescription
AgentIdquerystring / nullNonullTarget Agent identifier.
PathquerystringNo"."Path relative to the workspace root.

Example request:

GET /agentengine/api/v1/ExportWorkspaceZip?Path=.
Authorization: Bearer <API_KEY>

Response: ZIP bytes returned as an attachment.

Feedback

Get response feedback

POST /agentengine/api/v1/GetResponseFeedback

Read feedback for an assistant response.

ParameterLocationTypeRequiredDefaultDescription
AgentIdbodystringYes—Target Agent identifier.
SessionIdbodystringYes—Session identifier.
ResponseIdbodystringYes—Identifier of the assistant response receiving feedback.

Example request:

{"AgentId":"agent-example","SessionId":"session-example","ResponseId":"response-example"}

Response: Data.Feedback contains the feedback object or null when none exists.

Save response feedback

POST /agentengine/api/v1/UpsertResponseFeedback

Create or update an up/down rating and feedback text.

ParameterLocationTypeRequiredDefaultDescription
AgentIdbodystringYes—Target Agent identifier.
SessionIdbodystringYes—Session identifier.
ResponseIdbodystringYes—Identifier of the assistant response receiving feedback.
RatingbodystringYes—Feedback rating: up or down.
Commentbodystring / nullNo""Feedback text.
EventIdbodystring / nullNonullRelated event identifier.
TraceIdbodystring / nullNonullRelated trace identifier.
RootSpanIdbodystring / nullNonullRelated root-span identifier.

Example request:

{"AgentId":"agent-example","SessionId":"session-example","ResponseId":"response-example","Rating":"up","Comment":"Helpful answer"}

Response: Data.Feedback contains the saved feedback object.

Rating accepts only up or down. ResponseId must identify an actual assistant response in the session.

Delete response feedback

POST /agentengine/api/v1/DeleteResponseFeedback

Remove feedback for an assistant response.

ParameterLocationTypeRequiredDefaultDescription
AgentIdbodystringYes—Target Agent identifier.
SessionIdbodystringYes—Session identifier.
ResponseIdbodystringYes—Identifier of the assistant response receiving feedback.

Example request:

{"AgentId":"agent-example","SessionId":"session-example","ResponseId":"response-example"}

Response: Data.Deleted indicates whether an existing feedback record was removed.

MCP OAuth

Use these operations only when the service advertises MCP authorization. Local and hosted authorization state is not interchangeable. The service manages credentials; do not send secrets or access tokens as chat messages.

Method and pathPurpose
POST /agentengine/api/v1/GetMcpAuthorizationWaitRead the current authorization wait and its permitted actions.
POST /agentengine/api/v1/OpenMcpAuthorizationObtain the browser authorization URL for a pending MCP connection.
POST /agentengine/api/v1/RetryMcpAuthorizationRestart authorization after a failed or denied attempt when allowed.
POST /agentengine/api/v1/RetryMcpConnectionRetry the connection while valid credentials are still available.
POST /agentengine/api/v1/CancelMcpAuthorizationWaitCancel the wait and prevent a late callback from continuing that wait.

All five operations accept these fields:

ParameterLocationTypeRequiredDefaultDescription
WaitIdbodystringYes—Current MCP authorization-wait identifier. minLength 1; maxLength 64.
ExpectedRevisionbodyinteger / nullNonullCurrent interaction or authorization-wait revision. minimum 1.
AgentIdbodystring / nullNonullTarget Agent identifier.
SessionIdbodystring / nullNonullSession identifier.
IdempotencyKeybodystring / nullNonullOptional compatibility field. This group checks state using ExpectedRevision and does not promise deduplication by this field.

Query example:

{"WaitId":"wait-example","AgentId":"agent-example","SessionId":"session-example"}

For open, retry, or cancel, pass the revision obtained from the current state:

{"WaitId":"wait-example","ExpectedRevision":1,"AgentId":"agent-example","SessionId":"session-example"}
Data fieldTypeMeaning
wait_id / run_id / config_idstringWait, run, and connection identifiers
revisionintegerCurrent revision for subsequent operations
statusstringCurrent authorization/connection state
display_namestringMCP service display name
scopesstring[]Requested authorization scopes
allowed_actionsstring[]Actions currently permitted
requires_resumebooleanWhether continuation is associated with the wait
deadlinenumberWait deadline in Unix seconds
errorstring / nullFailure reason
authorization_urlstring, optionalBrowser URL returned by OpenMcpAuthorization

allowed_actions values query, open, retry_authorization, retry_connection, and cancel correspond to the five operations above. Perform only currently permitted actions. Refresh state after the browser completes actual authorization. A cancelled wait must not be completed by a late callback. A state conflict can return HTTP 409 with ReasonCode; refresh before deciding the next action.

AG-UI conversation

POST /agentengine/agui is the default endpoint; prefer the AG-UI Endpoint declared in HostedChat.Transports.

Send standard AG-UI input to receive text, tools, state, and structured interactions. A2UI cards are carried by messages/events and do not require a separate A2UI HTTP API.

ParameterLocationTypeRequiredDefaultDescription
threadIdbodystringYes—AG-UI conversation identifier.
runIdbodystringYes—AG-UI run identifier.
protocolVersionbodystring / nullNonullAG-UI protocol version.
parentRunIdbodystring / nullNonullParent run identifier.
statebodyJSON value / nullNonullInitial or current graph state.
messagesbodyarray<JSON value>Yes—AG-UI message array.
toolsbodyarray<object> / nullNonullClient tool declarations.
contextbodyarray<object> / nullNonullContext entries.
forwardedPropsbodyJSON value / nullNonullAdditional Agent properties.
resumebodyarray<object> / nullNonullResponses for pending interactions.

Response: text/event-stream. Process the AG-UI start, text, tool, state, interaction, completion, and error events.

messages contains AG-UI messages; tools contains tool declarations; context contains context entries; forwardedProps carries additional properties. threadId associates the session and runId identifies the AG-UI run. Do not substitute IDs from another transport. If AG-UI is unavailable, choose an allowed transport from the capability response.

Shared response objects

Session

FieldMeaning
SessionId / AgentId / UserIdSession and ownership identifiers
Title / TitleSource / SummaryTitle, title source, and summary
FirstPrompt / LastPromptFirst and latest user-input previews
ActiveInvocationId / ActiveRunStatusCurrent or most recent invocation and run state
ActiveRunMode / ActiveRunTriggerExecution mode and trigger
CreatedAt / UpdatedAt / VersionCreation/update time in Unix seconds and integer version
StatePublicly permitted session state
ContinuityRuntime continuity information

Message

FieldMeaning
MessageId / Role / ContentMessage identifier, role, and content
Timestamp / SeqId / InvocationIdTime, sequence, and invocation
Reasoning / BlocksPermitted reasoning and ordered content blocks
ToolEventsTool execution and approval state
AttachmentsReferences, names, media types, sizes, and access URLs

SessionEvent

FieldMeaning
EventId / SessionIdEvent and session identifiers
Author / EventTypeProducer and event type
ContentEvent-type-specific payload
Timestamp / SeqIdTime and sequence
InvocationIdAssociated invocation when available

Feedback

FieldMeaning
AgentId / SessionId / ResponseIdFeedback target
Rating / Commentup/down rating and text
EventId / TraceId / RootSpanIdRelated event and trace
CreatedAt / UpdatedAtCreation and update timestamps

SSE conventions

Use an incremental HTTP reader and split frames on blank lines. One network chunk is not one JSON object. Lines beginning with a colon are comments/heartbeats. SubscribeRunEvents data frames contain events and [DONE] ends that subscription. Non-Kernel RunAgent streams follow ApiFormat; Kernel streams use named Responses events such as response.completed, response.failed, and response.canceled. An interaction can produce response.incomplete and close the foreground stream; connection closure is not necessarily success. Parse AG-UI streams according to AG-UI.

Reconnect using the same SessionId, InvocationId, and the last confirmed AfterSeqId. Do not replay user input to simulate continuation. HTTP 200 alone does not mean the streamed run succeeded.

Optional file previews and local native terminals

Use these endpoints only when enabled. Native terminals are not a generic remote shell for every hosted user.

File preview resource

GET /_ksadk/workspace/v1/files/{file_path}

file_path is relative to the workspace and may contain multiple segments. URL-encode segments separately. Render returned bytes using Content-Type; HTML previews can resolve their relative assets through the same workspace path.

Create or reuse a terminal session

POST /_ksadk/terminal/sessions

ParameterTypeRequiredDefaultMeaning
session_idstringNoemptyAssociated chat session
modestringNotuiTerminal mode supported by the runtime
cols / rowsintegerNo80 / 24Terminal dimensions
force_newbooleanNofalseForce a new terminal session
cwdstringNounspecifiedWorking directory subject to runtime restrictions
{"session_id":"session-example","mode":"tui","cols":80,"rows":24,"force_new":false}

Returns {"session":{...}}. Use terminal_session_id from that object for attachment and closure.

List terminal sessions

GET /_ksadk/terminal/sessions

Optional query fields session_id and mode filter the result. Returns {"sessions":[...]}.

Close a terminal session

DELETE /_ksadk/terminal/sessions/{terminal_session_id}

Returns deleted and terminal_session_id. A missing session can return HTTP 404.

Attach terminal WebSocket

WS /_ksadk/terminal/ws?terminal_session_id=<TERMINAL_SESSION_ID>

Use WSS for a remote secure connection and negotiate Sec-WebSocket-Protocol: ks-terminal.v1. The terminal identifier comes from session creation. Stop on a capability or identity denial; do not attempt to bypass authorization.

On this page