Search documentation
karat

+

K

User Documentation ↗

Cancel Session

POST/api/v2/aipAgents/agents/{agentRid}/sessions/{sessionRid}/cancel
Warning

This endpoint is in preview and may be modified or removed at any time. To use this endpoint, add preview=true to the request query parameters.

Cancel an in-progress streamed exchange with an Agent which was initiated with streamingContinue. Canceling an exchange allows clients to prevent the exchange from being added to the session, or to provide a response to replace the Agent-generated response. Note that canceling an exchange does not terminate the stream returned by streamingContinue; clients should close the stream on triggering the cancellation request to stop reading from the stream.

Third-party applications using this endpoint via OAuth2 must request the following operation scope: api:aip-agents-write.

Path parameters

agentRid
string

An RID identifying an AIP Agent created in AIP Agent Studio.

sessionRid
string

The Resource Identifier (RID) of the conversation session.

Query parameters

preview
boolean
optional

Enables the use of preview functionality.

Request body

CancelSessionRequest
object
Hide child attributes

Hide child attributes

messageId
string

The identifier for the in-progress exchange to cancel. This should match the messageId which was provided when initiating the exchange with streamingContinue.

response
string
optional

When specified, the exchange is added to the session with the client-provided response as the result. When omitted, the exchange is not added to the session.

Response body

CancelSessionResponse
object
Hide child attributes

Hide child attributes

result
object
optional

If the response field was specified, this returns the result that was added to the session for the canceled exchange, with the client-provided response. If no response was specified in the request, this returns an empty response, as no exchange was added to the session.

Show child attributes

Show child attributes

Examples

Request

Copied!
1 2 3 4 5 curl -X POST \ -H "Content-type: application/json" \ -H "Authorization: Bearer $TOKEN" \ "https://$HOSTNAME/api/v2/aipAgents/agents/ri.aip-agents..agent.732cd5b4-7ca7-4219-aabb-6e976faf63b1/sessions/ri.aip-agents..session.292db3b2-b653-4de6-971c-7e97a7b881d6/cancel?preview=true" \ -d '{"response":"The status of your order is **In Transit**.","messageId":"00f8412a-c29d-4063-a417-8052825285a5"}'

Response

Copied!
1 2 3 4 5 6 7 { "result": { "totalTokensUsed": 6448, "agentMarkdownResponse": "The status of your order is **In Transit**.", "interruptedOutput": false } }